From patchwork Fri Jun 2 13:52:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 101259 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp205135obc; Fri, 2 Jun 2017 06:55:41 -0700 (PDT) X-Received: by 10.84.238.203 with SMTP id l11mr42061pln.17.1496411741615; Fri, 02 Jun 2017 06:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496411741; cv=none; d=google.com; s=arc-20160816; b=md7NUKBy+W2OS9CbvY3bcuV2IsspXqYEBmSXnTSXtTNST5hu1qMVJmhmb+Y4DH3rNL YhDEicb4+Yjqa3vFGCoZHMHcFGDii/cfQdlbLHddaTwGrBr+Ed5+hz7cF1/dEoqmRNbP SEMWhg2xvCxmtK4396dhZiDry/1dJGl6Ul8Z8+CjdS673UoEmmDVx2wWU0de6TmtKvf1 IdtM8FjAxHb4CISsWfK0JH4aKCFbtYpbfn45xep2T12mD/tF+ojByoKRHKsraTJJ3oyr q1t5RRb8yZuJpnHk1qYZVPZeNByxI5QBMxWdabMI2wj3qaa3kT1SrZWBbSr5pMNEQrNc iopA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=bT6LesnTJwJpD0pkH2Wp0wRTMF+iplSJ0m2phDFk9u4=; b=dqrUEq3AkP6PIPfoPEb0BYewk3q9YwDFSWruV3Y8o+piYTDpKH5A88SWOZfRpf6sKW a2BjSEOW8aMC2ySnoLIHYkqNF3G/YfZfXMRdIQtnnb+tyBulr3+cZyXEkNK1UmxHNpAd zNN1C3JO2uKm/t1dtwe8sauUaab3srcaaa9jlEpZorLqMjCVsRBFcpruZmq1pYPNs7hp jLPpvhkZToB0XoyXbqX7AW21GfA6j90p9xcSn+itLCIiRA1ESvUpnKeWZAdY1SU3WNTp y4FybbKk+j5bIslpTgvKmnRLD0QXtgbdZ07K2KQQvGoLpqmXK5vIXDyEWSQEFbHHNxG/ saqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 l17si3183385pgj.43.2017.06.02.06.55.41; Fri, 02 Jun 2017 06:55:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751630AbdFBNzT (ORCPT + 25 others); Fri, 2 Jun 2017 09:55:19 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:38684 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751595AbdFBNzO (ORCPT ); Fri, 2 Jun 2017 09:55:14 -0400 Received: by mail-wm0-f45.google.com with SMTP id n195so27636586wmg.1 for ; Fri, 02 Jun 2017 06:55:13 -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:in-reply-to:references; bh=bT6LesnTJwJpD0pkH2Wp0wRTMF+iplSJ0m2phDFk9u4=; b=XCZZHdTVYyfElRDjZ9IoQQa9z6iMFHdNLGEv//HFZIthLzaVwj1MQ+kSHy/HnG60c4 FmcUwO1Ca/2gT8JN3j6NKh8jV/u7ATXadAqqrlfjboRdIUS5/46uGVEdr5fk2rgfhyrW 5FcYRAWpUYDlrPC4J0v279oj6KsJf4RHrd6nM= 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:in-reply-to :references; bh=bT6LesnTJwJpD0pkH2Wp0wRTMF+iplSJ0m2phDFk9u4=; b=tEw/0vgd9M4+h8FgzrrDN/Qbyr+GlUWpreBf5KDxedG+8zty9mwBqHNwcpCGkHqjMO 665ThIyZ4G7c8hYBb4oIeCoUCHGNe46KClaYqONeGF8doh0GLTkmK1Gt9S0ivkqRvmuW k62EbWS6APA4cFviKaRwuAlNXLTHtdLHRx08hf9FNeq5DGBp05N3bI9531sis3728iAj J1N2Frwe5WC5VCYMNPqg2w6fl8KY+0kR15OsAj04tBYi317M6zeg55Pka58p42kLXzyx g1LriYwnW0RiOKyrx0gI+EE+IABRmpHR5PHTi6LWorMqw2gQWEYca9e/tCYMxSyiEWpP 84ug== X-Gm-Message-State: AODbwcBcNtWAcrrfh687Ppd9E/M2WXcV8LiVLV0kTwxnULGenq75JWr+ 65Py2t12OK0brnEV X-Received: by 10.80.193.130 with SMTP id m2mr6193943edf.85.1496411712918; Fri, 02 Jun 2017 06:55:12 -0700 (PDT) Received: from localhost.localdomain ([105.151.155.95]) by smtp.gmail.com with ESMTPSA id g48sm9756076edc.8.2017.06.02.06.55.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 06:55:11 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Matt Fleming Subject: [PATCH 13/13] efi: arm: enable DMI/SMBIOS Date: Fri, 2 Jun 2017 13:52:07 +0000 Message-Id: <20170602135207.21708-14-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602135207.21708-1-ard.biesheuvel@linaro.org> References: <20170602135207.21708-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wire up the existing arm64 support for SMBIOS tables (aka DMI) for ARM as well, 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 Acked-by: Russell King Signed-off-by: Ard Biesheuvel --- arch/arm/Kconfig | 17 +++++++++++++++++ arch/arm/include/asm/dmi.h | 19 +++++++++++++++++++ arch/arm64/kernel/efi.c | 15 --------------- drivers/firmware/efi/arm-runtime.c | 16 ++++++++++++++++ 4 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 arch/arm/include/asm/dmi.h -- 2.9.3 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 4c1a35f15838..dabcaeb2ee3e 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -2061,6 +2061,23 @@ 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. + + 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. + 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);