From patchwork Thu Jun 1 10:45:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100875 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp739257qge; Thu, 1 Jun 2017 03:46:07 -0700 (PDT) X-Received: by 10.98.58.195 with SMTP id v64mr423630pfj.237.1496313967527; Thu, 01 Jun 2017 03:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496313967; cv=none; d=google.com; s=arc-20160816; b=gCogU8RkgR10pgz6xV7eFysr0eJR+K8cGQLQwAf3vl0OwePQmuTY5FNv7Sj6ZdNxfM 3NEB7PhY98wUWC/yKZQ//tqgatbHw5+PEPD7tb4RZAGnaQOlGT9IEgsUtDNdBBQlJ4pg 9lHNHQ95Svi4W8fTd5LEuvq9m5aA5uuahcljcbAF/mkJukQ91ioZ8wGCHmlZ+96gRnR/ nUMcnj7bM94A1AoWGV/xg9UMZNb5XxnK4nzbl5Z0gkGQjaWJzrVNaIGK+AwGeEYk3cCw 0rlIMQQNhrKVblgHINc4ghf5KuWIMyGzatE7maCdODZKUAH+GstGTnCxdfnFAh7SuBhf 7H0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=aniHvI2oeu87st/0b9DOe8K8mnkd3jlkIfnFsUpQAQk=; b=zVXssrDpJMSHaKSf8l5/I5VwT99FfScPhFJGuQgfoD114hJYs55iqzPcvUCTLTQymc Ibpg/v3UymJXDVMxGxx3NWr6vHAfbOGTk1x7una/2SMk5GxqktxZatxqjyuU/YVa75OQ KylQQJv3DI1Lrhi9TfJ/Ba5rgW1Z5nqr4DBCLCpafPZmrUZdnP2DSuJsfjhRsecOJgz2 mhbaMtmAKRiAtoNRkS6auIH127UlXRz+5gz5mF5kCoNdi9WQfZXn2gZFlCgFf0BXdYdo ecGM1o+Qy/1jzWFZSjsgVAVrJ7G0Kl0QlMYAHzgB39MTDF59M0SCHlk1Xz4+6enXOg+5 gccw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u132si19067861pgb.272.2017.06.01.03.46.07; Thu, 01 Jun 2017 03:46:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751435AbdFAKqH (ORCPT + 2 others); Thu, 1 Jun 2017 06:46:07 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:35737 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369AbdFAKqG (ORCPT ); Thu, 1 Jun 2017 06:46:06 -0400 Received: by mail-wm0-f54.google.com with SMTP id b84so153222160wmh.0 for ; Thu, 01 Jun 2017 03:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=aNAEYNJeAMN+lD2tkiT7wjUNKo5L2U203Rpn9JH0tdk=; b=UTQfVljNOMtiICPur+fhz/Upuc1CsnD2IQgbmseq2faS0Gjpv0ohOhApB3m5NwmjpN wAegL7t3DCT0/6327a7VsjshJYQZVJzdHfphrBXinV2ja6CxETr4ejtHirzFH4qNfAVG pS0eAaN3/SRx5j0FUPomjFzK8B20PgaagE6Mc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aNAEYNJeAMN+lD2tkiT7wjUNKo5L2U203Rpn9JH0tdk=; b=fPgljHHZ9S7l70zFBnBpz/ofAyfeWCaG37igcloowzf2BLLr7KNnYwzZJVFU1CoL3f DFlpMT/HvhQ+fM68/sgL6dPZpRc57DQt0Yt4cRLYu6P+hYBeOEKgpMX8TRLr+EL15z6z MNKBQhIoUQBoBsQVtw8oupAOuFLZsyLuY08jV4mO0jlQ7FfXs7KKh1qThjvk0aXpb6zX hhlFupNiC6Wf0UrKnfD7pgSG7zOYSfSDH6QoS9LC0W5tP0qIjziMULqA18A1vrj2/jMp +PSwm2QEnvsWHaN3F+K8qIWYeljaZPrpH/fkAdSBEBW0GU8q4yALGpSBg8XWiQDXF0gT F6Pg== X-Gm-Message-State: AODbwcAhZ1Nx0UaOSxZZVfXBfe6gwVCz+hiUhPZRoyvEs06tlbGD0kSL fco5yxAAVyeG5Hk4 X-Received: by 10.28.63.9 with SMTP id m9mr1263026wma.87.1496313964780; Thu, 01 Jun 2017 03:46:04 -0700 (PDT) Received: from localhost.localdomain ([196.71.200.86]) by smtp.gmail.com with ESMTPSA id b30sm22540919wra.6.2017.06.01.03.46.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 03:46:03 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org Cc: matt@codeblueprint.co.uk, leif.lindholm@linaro.org, mark.rutland@arm.com, graeme.gregory@linaro.org, linux@armlinux.org.uk, Ard Biesheuvel Subject: [PATCH v2] efi: arm: enable DMI/SMBIOS Date: Thu, 1 Jun 2017 10:45:54 +0000 Message-Id: <20170601104554.21267-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Wire up the existing support for SMBIOS tables (aka DMI), by moving the arm64 init code to drivers/firmware/efi/arm-runtime.c (which is shared between ARM and arm64), and adding a asm/dmi.h header to ARM that defines the mapping routines for the firmware tables. This allows userspace to access these tables to discover system information exposed by the firmware. It also sets the hardware name used in crash dumps, e.g., Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = ed3c0000 [00000000] *pgd=bf1f3835 Internal error: Oops: 817 [#1] SMP THUMB2 Modules linked in: CPU: 0 PID: 759 Comm: bash Not tainted 4.10.0-09601-g0e8f38792120-dirty #112 Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 ^^^ NOTE: This does *NOT* enable or encourage the use of DMI quirks, i.e., the the practice of identifying the platform via DMI to decide whether certain workarounds for buggy hardware and/or firmware need to be enabled. This would require the DMI subsystem to be enabled much earlier than we do on ARM, which is non-trivial. Cc: Matt Fleming Cc: Russell King Signed-off-by: Ard Biesheuvel --- v2: add missing include of rebase onto v4.12-rc3 arch/arm/Kconfig | 11 +++++++++++ arch/arm/include/asm/dmi.h | 19 +++++++++++++++++++ arch/arm64/kernel/efi.c | 15 --------------- drivers/firmware/efi/arm-runtime.c | 16 ++++++++++++++++ 4 files changed, 46 insertions(+), 15 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Russell King diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 4c1a35f15838..268f46bfc4d9 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -2061,6 +2061,17 @@ config EFI is only useful for kernels that may run on systems that have UEFI firmware. +config DMI + bool "Enable support for SMBIOS (DMI) tables" + depends on EFI + default y + help + This enables SMBIOS/DMI feature for systems. + + This option is only useful on systems that have UEFI firmware. + However, even with this option, the resultant kernel should + continue to boot on existing non-UEFI platforms. + endmenu menu "CPU Power Management" diff --git a/arch/arm/include/asm/dmi.h b/arch/arm/include/asm/dmi.h new file mode 100644 index 000000000000..df2d2ff06f5b --- /dev/null +++ b/arch/arm/include/asm/dmi.h @@ -0,0 +1,19 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_DMI_H +#define __ASM_DMI_H + +#include +#include + +#define dmi_early_remap(x, l) memremap(x, l, MEMREMAP_WB) +#define dmi_early_unmap(x, l) memunmap(x) +#define dmi_remap(x, l) memremap(x, l, MEMREMAP_WB) +#define dmi_unmap(x) memunmap(x) +#define dmi_alloc(l) kzalloc(l, GFP_KERNEL) + +#endif diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 5d17f377d905..82cd07592519 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -11,7 +11,6 @@ * */ -#include #include #include @@ -117,20 +116,6 @@ int __init efi_set_mapping_permissions(struct mm_struct *mm, set_permissions, md); } -static int __init arm64_dmi_init(void) -{ - /* - * On arm64, DMI depends on UEFI, and dmi_scan_machine() needs to - * be called early because dmi_id_init(), which is an arch_initcall - * itself, depends on dmi_scan_machine() having been called already. - */ - dmi_scan_machine(); - if (dmi_available) - dmi_set_dump_stack_arch_desc(); - return 0; -} -core_initcall(arm64_dmi_init); - /* * UpdateCapsule() depends on the system being shutdown via * ResetSystem(). diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 974c5a31a005..1cc41c3d6315 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -11,6 +11,7 @@ * */ +#include #include #include #include @@ -166,3 +167,18 @@ void efi_virtmap_unload(void) efi_set_pgd(current->active_mm); preempt_enable(); } + + +static int __init arm_dmi_init(void) +{ + /* + * On arm64/ARM, DMI depends on UEFI, and dmi_scan_machine() needs to + * be called early because dmi_id_init(), which is an arch_initcall + * itself, depends on dmi_scan_machine() having been called already. + */ + dmi_scan_machine(); + if (dmi_available) + dmi_set_dump_stack_arch_desc(); + return 0; +} +core_initcall(arm_dmi_init);