From patchwork Wed Mar 1 23:24:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94758 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp66407qgi; Wed, 1 Mar 2017 15:35:23 -0800 (PST) X-Received: by 10.84.135.34 with SMTP id 31mr13822409pli.50.1488411323671; Wed, 01 Mar 2017 15:35:23 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si5836371pgc.308.2017.03.01.15.35.23; Wed, 01 Mar 2017 15:35:23 -0800 (PST) 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 S1753720AbdCAXfN (ORCPT + 2 others); Wed, 1 Mar 2017 18:35:13 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38577 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753507AbdCAXet (ORCPT ); Wed, 1 Mar 2017 18:34:49 -0500 Received: by mail-wm0-f54.google.com with SMTP id u199so48657589wmd.1 for ; Wed, 01 Mar 2017 15:33:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Z4iH5bXs7LTTJCUDcMRr1LTq5HaX7M5uq9+O+9vTkN0=; b=bt8NNE3BjGpQGXcEuXopJEuBUa0dYzQUyxBa2fuIPafD1ez57gM1ir8zpv5GSKiQtG dGi7ZHiiiENa2u+oL8zAvW+FlqbXF0tGa0sjSBNoRGP1cq/uWZrMQboG+sLmjwCY/qkn ThR8LUdUt6QRDC/8ewpXLS6My+2+iXg1nMX/E= 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=Z4iH5bXs7LTTJCUDcMRr1LTq5HaX7M5uq9+O+9vTkN0=; b=Iqpe0hT3s2gexkcwDjbwX9jgeUjr/zB/qL+j1fxcDBfWISlxCzPt4iCYaO5E/p6j1X Vpp1Ddgmdd16IJgjE6OSyEw5qtfJCUIQNqkPFJ2EVoDuQ54AlNscifX0u8UdlppoSZI1 EP1fcD6iEDM5B+C6in1B7jVlg5HNCyYWKHSyWzZgjk4Je2lMG1xClul9JRIu39xIWMBA /YGbd6cVSiX10vM32wxjqv/2PL3aoFGsgoBzDaLD6S5Wf7ZvbxDIYbEcAcSTepI4Z7N9 98gDbk5ekXz8yex8tfn5NV3WIvADrr1YA7RtW40SjbsRQp8cavoRfXQpLi3u0yu88VAR ZeFw== X-Gm-Message-State: AMke39k2EP1oUozroHogpsIRLKeTVtgryVG40tZ7hUn/fUxDkBWDhjUIBVwmYoqJCO8BRVh3 X-Received: by 10.28.125.20 with SMTP id y20mr5545606wmc.123.1488410654077; Wed, 01 Mar 2017 15:24:14 -0800 (PST) Received: from localhost.localdomain ([105.147.1.203]) by smtp.gmail.com with ESMTPSA id l138sm2466029wmd.7.2017.03.01.15.24.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Mar 2017 15:24:13 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, linux@armlinux.org.uk Cc: matt@codeblueprint.co.uk, leif.lindholm@linaro.org, graeme.gregory@linaro.org, mark.rutland@arm.com, Ard Biesheuvel Subject: [PATCH] efi: arm: enable DMI/SMBIOS Date: Wed, 1 Mar 2017 23:24:02 +0000 Message-Id: <1488410642-13176-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 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. Signed-off-by: Ard Biesheuvel --- arch/arm/Kconfig | 11 +++++++++++ arch/arm/include/asm/dmi.h | 19 +++++++++++++++++++ arch/arm64/kernel/efi.c | 15 --------------- drivers/firmware/efi/arm-runtime.c | 15 +++++++++++++++ 4 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 arch/arm/include/asm/dmi.h -- 2.7.4 -- 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 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index fda6a46d27cf..8214ea99b2f3 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -2089,6 +2089,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 349dc3e1e52e..7149d2f48bb1 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -165,3 +165,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);