From patchwork Fri May 4 05:59:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134957 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp440384lji; Thu, 3 May 2018 23:05:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpivsXi1Rm0KERwIRThwR4mfshcbXrdpiBv8nBfFCZnW5sSFK+ap+/PqnL8MqktNkm4tJ8S X-Received: by 10.98.74.136 with SMTP id c8mr25700629pfj.23.1525413906629; Thu, 03 May 2018 23:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413906; cv=none; d=google.com; s=arc-20160816; b=DxUYXnhxh9RmDvl6pwpKSKGuGwLuT5T/bFUWl0xpbt8Uy10EV9Y901MvZc4JPsW0cs UjAIX/HvCWBj685Io766lAofRFBSW1/MimgwDWPHtsa9gkjeDxB6yuR6Fz0+6sJzgUWh aDUELbxJsOrgw+O+OLLhfopi7XYg9vXBgRQ7vlscjx4JUokz6PNUTKT/cfc98CoGe5ug JCoNra4E/ifz1C7yf7CAVRMCcU0wASzJrx7h3IvMsI9MtKCG4vllXxxPa2HJlyJjZXMa znUF4VjWOCQaoThlVSDE5GT2gBp+Qry5mDecxFzDIIK2luSMfWeyEq6npecqyYe2Aan0 UoXQ== 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=Z4r2NQZwKVNvxrX5BnSLUF3DoIt5BmU8wuRSbOhkgYA=; b=bXZFiGX9DGIdO63hxD00nm2LfHNJlMxwmeVwkJYYFWYka3K5hNNyzMFR6Dra1olz07 mg1rNB9lyyV6s2uNSYjP/WZ6WsRLOUkoDJTere1zPxOB+RC4FJZFfPBZo2lNBDKrvmeg aEmy/b7JSIqSk1QP3otUCeqwBARkDIrG9bIFAPS/y5ooytt3DV9AbA4OfWAyaKeZ/ipf /+ZQgxs81R2jQxsTo2UrS34a5STl6MyEWo4J40s6vacOrbOQ5DaILx5NSUpW/crXuUho l4kuBPhO5Qnfl8qiNypZrBB8w/xp056akw3WsHsUSEvFJ37WLMItL3fsbORdhq42oowz dZRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=T5Bde6ww; 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 202si15758960pfx.61.2018.05.03.23.05.06; Thu, 03 May 2018 23:05:06 -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 header.s=google header.b=T5Bde6ww; 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 S1750774AbeEDGFF (ORCPT + 2 others); Fri, 4 May 2018 02:05:05 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:40725 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751394AbeEDGBE (ORCPT ); Fri, 4 May 2018 02:01:04 -0400 Received: by mail-wr0-f194.google.com with SMTP id v60-v6so19766340wrc.7 for ; Thu, 03 May 2018 23:01:03 -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=YSRxmjrrmzsG8nmkS9VVjgihVs6uFWq2LNl+IHpQ/ns=; b=T5Bde6wwDSmScsuHUH/9tjQtB78QxNm8QmVsCTlOarNFRR/zYgqH1Q2WS3lbOAYkdq IyfSpTmn6HBurEZFkISOEe1i4FgHH+aEyAdUoosK/6I+nahC01IktrZr5+CQ8XaPnED2 YCyCmwCXjQ/FiT9r6CzTbgLdxVAONIBY4xU1Q= 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=YSRxmjrrmzsG8nmkS9VVjgihVs6uFWq2LNl+IHpQ/ns=; b=s3AsOdr/Mg8+Tl4Vx9a7pB/d8rtkLw5TMXgpLElrYJkKqJnnysBO/KLAQDFgEQlJ2q wDOTZ8QiGPTjNg3+Z+n3ODtfWVBvtZ6LntMLI6Y5JoZBswY+mNhFdQwnSeWnLIT4kY1p JIzH256L6qgQKn3Fpm+Q7GuqQauUGg/dqlcOi9QyTnhCCrQSONHqXwdUH6Pl3FYA3lCN 3GOckaYH+r+dTgjSfYr3sMcRveD7KSoV32xY0NALZhjiYTYeWUkF46dUDsNyFRYo1qHQ ZJROwrf03T73Fzq+kwcI56IKhPg2jSn5WfpFecKKh5UjZwDWYC4QyYIumDn85J6lwv6V 4kGQ== X-Gm-Message-State: ALQs6tB6IiQM1QKEto6Wxjl84cfxbIfAxcHzTzPSefskzFJ5m3ycSN3Z KBZFOca9bYJOC5wY0iJomdqU4yJoq1Y= X-Received: by 2002:adf:e943:: with SMTP id m3-v6mr18927816wrn.185.1525413662949; Thu, 03 May 2018 23:01:02 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:02 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Daniel Kiper , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 01/17] x86/xen/efi: Initialize UEFI secure boot state during dom0 boot Date: Fri, 4 May 2018 07:59:47 +0200 Message-Id: <20180504060003.19618-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Daniel Kiper Initialize UEFI secure boot state during dom0 boot. Otherwise the kernel may not even know that it runs on secure boot enabled platform. Note that part of drivers/firmware/efi/libstub/secureboot.c is duplicated by this patch, only in this case, it runs in the context of the kernel proper rather than UEFI boot context. The reason for the duplication is that maintaining the original code to run correctly on ARM/arm64 as well as on all the quirky x86 firmware we support is enough of a burden as it is, and adding the x86/Xen execution context to that mix just so we can reuse a single routine just isn't worth it. Signed-off-by: Daniel Kiper [ardb: explain rationale for code duplication] Signed-off-by: Ard Biesheuvel --- arch/x86/xen/efi.c | 57 +++++++++++++++++++++++ drivers/firmware/efi/libstub/secureboot.c | 3 ++ 2 files changed, 60 insertions(+) -- 2.17.0 -- 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/x86/xen/efi.c b/arch/x86/xen/efi.c index a18703be9ead..1804b27f9632 100644 --- a/arch/x86/xen/efi.c +++ b/arch/x86/xen/efi.c @@ -115,6 +115,61 @@ static efi_system_table_t __init *xen_efi_probe(void) return &efi_systab_xen; } +/* + * Determine whether we're in secure boot mode. + * + * Please keep the logic in sync with + * drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot(). + */ +static enum efi_secureboot_mode xen_efi_get_secureboot(void) +{ + static efi_guid_t efi_variable_guid = EFI_GLOBAL_VARIABLE_GUID; + static efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID; + efi_status_t status; + u8 moksbstate, secboot, setupmode; + unsigned long size; + + size = sizeof(secboot); + status = efi.get_variable(L"SecureBoot", &efi_variable_guid, + NULL, &size, &secboot); + + if (status == EFI_NOT_FOUND) + return efi_secureboot_mode_disabled; + + if (status != EFI_SUCCESS) + goto out_efi_err; + + size = sizeof(setupmode); + status = efi.get_variable(L"SetupMode", &efi_variable_guid, + NULL, &size, &setupmode); + + if (status != EFI_SUCCESS) + goto out_efi_err; + + if (secboot == 0 || setupmode == 1) + return efi_secureboot_mode_disabled; + + /* See if a user has put the shim into insecure mode. */ + size = sizeof(moksbstate); + status = efi.get_variable(L"MokSBStateRT", &shim_guid, + NULL, &size, &moksbstate); + + /* If it fails, we don't care why. Default to secure. */ + if (status != EFI_SUCCESS) + goto secure_boot_enabled; + + if (moksbstate == 1) + return efi_secureboot_mode_disabled; + + secure_boot_enabled: + pr_info("UEFI Secure Boot is enabled.\n"); + return efi_secureboot_mode_enabled; + + out_efi_err: + pr_err("Could not determine UEFI Secure Boot status.\n"); + return efi_secureboot_mode_unknown; +} + void __init xen_efi_init(void) { efi_system_table_t *efi_systab_xen; @@ -129,6 +184,8 @@ void __init xen_efi_init(void) boot_params.efi_info.efi_systab = (__u32)__pa(efi_systab_xen); boot_params.efi_info.efi_systab_hi = (__u32)(__pa(efi_systab_xen) >> 32); + boot_params.secure_boot = xen_efi_get_secureboot(); + set_bit(EFI_BOOT, &efi.flags); set_bit(EFI_PARAVIRT, &efi.flags); set_bit(EFI_64BIT, &efi.flags); diff --git a/drivers/firmware/efi/libstub/secureboot.c b/drivers/firmware/efi/libstub/secureboot.c index 8f07eb414c00..72d9dfbebf08 100644 --- a/drivers/firmware/efi/libstub/secureboot.c +++ b/drivers/firmware/efi/libstub/secureboot.c @@ -30,6 +30,9 @@ static const efi_char16_t shim_MokSBState_name[] = L"MokSBState"; /* * Determine whether we're in secure boot mode. + * + * Please keep the logic in sync with + * arch/x86/xen/efi.c:xen_efi_get_secureboot(). */ enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table_arg) { From patchwork Fri May 4 05:59:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134955 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp439934lji; Thu, 3 May 2018 23:04:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpVt7mIoTSfcnwfraPAfrS0tjlg7tnA7gg34r8Ax+lRgog7LTlMIPSXmX2c6W++PCvOrX12 X-Received: by 10.98.11.3 with SMTP id t3mr25781601pfi.32.1525413875646; Thu, 03 May 2018 23:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413875; cv=none; d=google.com; s=arc-20160816; b=klj43GGRWb8jlNmb7T+R5wziAfU5CQ/mOGKUemkSPnP3Kbx+W9b1q8Jd5b/5d0Ylma 9Z+LSf/SuWRs4A4Wd0zWpus3Bkhu/aA1pbWTUXoxAxNPaQjTR7PcvSg8wadzmyvqtJgm Nq1QsjA/dyFk1aOzYFNFz8/g7puJa5FVbo2FrNnTtaFOFma9McyokMc8Vw1K6jaDmQ3w 1gvg9XJA8+efEXSoh4DvoKkazFjawMg62vlH03x0G5O81KD5QqwoXkUvZe0130h/kT3O UyPZFckLGSOovZfn3Uc3HH/HlbEks5k5ffPnNjrIHwCEsOJWF2pVg7UutbjLljTP8UTh 6s/Q== 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=KvCxDSRHdOyHoYgKRF2IbBwEBUVlnXJv6YDuHIuwOUo=; b=nrOxRPnpQddBNjLD5O4Dn6phi9lRWaXcGpuzOCe7/mr1cTyqt+ges/a7nUzzsA3AXq RSlfq0QP+6TwhwAeAb52nGUwhH/QM618aidEz7jkEBSeit8wZs+2O4pEMggMqo1QD4X9 RXA24wfvB7ObVBf4jS+mIc6O7DPYxzL96nIKAH1sS/rXPsyNdE5daW7ZRtmoa2l9DaLO hSF2mBFauNPNmfsk0P0soQwxU9UcEWTDsjIbfUHGU6hBQknTwEgTfjb2rFOcvyBAXxth ACsfpRep6xvA9kdzhswvqjwcgkEiJLEv4t/xe6/o7F6+g/HWQrWyktiJwuN+Jf7qR3WL ksJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TOkTKS2L; 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 u8-v6si15687131plm.134.2018.05.03.23.04.35; Thu, 03 May 2018 23:04:35 -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 header.s=google header.b=TOkTKS2L; 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 S1751704AbeEDGEd (ORCPT + 2 others); Fri, 4 May 2018 02:04:33 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36148 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751455AbeEDGBK (ORCPT ); Fri, 4 May 2018 02:01:10 -0400 Received: by mail-wm0-f68.google.com with SMTP id n10-v6so2568244wmc.1 for ; Thu, 03 May 2018 23:01:09 -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=4kYvxvaCIBrrdSstTEOT+7ONeGYF0WWkfOJyKh52j0k=; b=TOkTKS2LwLrAehTTwLeK3/33HAiubtubYvUK66lVI+NAFuO2rI3lhSeJy/GMgwqJte 4nO4FumQmwGn5ovggU8jnR5ll53PZ9DQy2OsF2LK9t6SBh11oUIrfZ89BqonfWzdjNcn Cv8A9GbXLRg9BRW/f2fWgOJFnqeXrbI4xBQvA= 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=4kYvxvaCIBrrdSstTEOT+7ONeGYF0WWkfOJyKh52j0k=; b=X17LmMeUOGv0USrMlHXoeW4pNN9WSfzTpUpS2bLE/000LrHpMYbXWuE2ZaM9S+fB4I C838/U07NlNhWBP7SF5QnVqE/pakrZfSfMpPOpB9GVskPxQ+lJcIQLrVBfbQY3okCzdb D3n01Eoh3yEyns+svUdJLTkIQKyLEbRFJneKZtCJNfk14+KCc9Iu2M+HbN3aRV3xLGZK htmkRa4SW7OHt2DdYfIF1vzCBlpC1cHd8b7OIrVMelwDHneJdrY8K+60jzxuOOCoLG45 YWsM3vo5aHhDeuFVjSrkeJKVOvofWSL5Uxf7RZtQPenwjeko1y1G2XHf6rHDfrOlci6K wPaw== X-Gm-Message-State: ALQs6tALQpCtwQKsGRh9skmaQUc1YrHjOaxNJxglbGmdFduX3pK16g1S N4WYIuTu+nHSumZdgTBUceGGmXSADXM= X-Received: by 10.28.203.136 with SMTP id b130mr9389041wmg.78.1525413668978; Thu, 03 May 2018 23:01:08 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:08 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Yazen Ghannam , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 04/17] efi: Decode IA32/X64 Processor Error Section Date: Fri, 4 May 2018 07:59:50 +0200 Message-Id: <20180504060003.19618-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Yazen Ghannam Recognize the IA32/X64 Processor Error Section. Do the section decoding in a new "cper-x86.c" file and add this to the Makefile depending on a new "UEFI_CPER_X86" config option. Print the Local APIC ID and CPUID info from the Processor Error Record. The "Processor Error Info" and "Processor Context" fields will be decoded in following patches. Based on UEFI 2.7 Table 252. Processor Error Record. Signed-off-by: Yazen Ghannam Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/Kconfig | 5 +++++ drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/cper-x86.c | 23 +++++++++++++++++++++++ drivers/firmware/efi/cper.c | 10 ++++++++++ include/linux/cper.h | 2 ++ 5 files changed, 41 insertions(+) create mode 100644 drivers/firmware/efi/cper-x86.c -- 2.17.0 -- 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/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index 3098410abad8..781a4a337557 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -174,6 +174,11 @@ config UEFI_CPER_ARM depends on UEFI_CPER && ( ARM || ARM64 ) default y +config UEFI_CPER_X86 + bool + depends on UEFI_CPER && X86 + default y + config EFI_DEV_PATH_PARSER bool depends on ACPI diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index cb805374f4bc..5f9f5039de50 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -31,3 +31,4 @@ obj-$(CONFIG_ARM) += $(arm-obj-y) obj-$(CONFIG_ARM64) += $(arm-obj-y) obj-$(CONFIG_EFI_CAPSULE_LOADER) += capsule-loader.o obj-$(CONFIG_UEFI_CPER_ARM) += cper-arm.o +obj-$(CONFIG_UEFI_CPER_X86) += cper-x86.o diff --git a/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c new file mode 100644 index 000000000000..863f0cd2a0ff --- /dev/null +++ b/drivers/firmware/efi/cper-x86.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018, Advanced Micro Devices, Inc. + +#include + +/* + * We don't need a "CPER_IA" prefix since these are all locally defined. + * This will save us a lot of line space. + */ +#define VALID_LAPIC_ID BIT_ULL(0) +#define VALID_CPUID_INFO BIT_ULL(1) + +void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) +{ + if (proc->validation_bits & VALID_LAPIC_ID) + printk("%sLocal APIC_ID: 0x%llx\n", pfx, proc->lapic_id); + + if (proc->validation_bits & VALID_CPUID_INFO) { + printk("%sCPUID Info:\n", pfx); + print_hex_dump(pfx, "", DUMP_PREFIX_OFFSET, 16, 4, proc->cpuid, + sizeof(proc->cpuid), 0); + } +} diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c index ab21f1614007..3bf0dca378a6 100644 --- a/drivers/firmware/efi/cper.c +++ b/drivers/firmware/efi/cper.c @@ -467,6 +467,16 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata cper_print_proc_arm(newpfx, arm_err); else goto err_section_too_small; +#endif +#if defined(CONFIG_UEFI_CPER_X86) + } else if (guid_equal(sec_type, &CPER_SEC_PROC_IA)) { + struct cper_sec_proc_ia *ia_err = acpi_hest_get_payload(gdata); + + printk("%ssection_type: IA32/X64 processor error\n", newpfx); + if (gdata->error_data_length >= sizeof(*ia_err)) + cper_print_proc_ia(newpfx, ia_err); + else + goto err_section_too_small; #endif } else { const void *err = acpi_hest_get_payload(gdata); diff --git a/include/linux/cper.h b/include/linux/cper.h index 4b5f8459b403..9c703a0abe6e 100644 --- a/include/linux/cper.h +++ b/include/linux/cper.h @@ -551,5 +551,7 @@ const char *cper_mem_err_unpack(struct trace_seq *, struct cper_mem_err_compact *); void cper_print_proc_arm(const char *pfx, const struct cper_sec_proc_arm *proc); +void cper_print_proc_ia(const char *pfx, + const struct cper_sec_proc_ia *proc); #endif From patchwork Fri May 4 05:59:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134941 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp436815lji; Thu, 3 May 2018 23:01:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqP+vDqWVG4qK1WDP5RKWkJTTSLn7U4tQh9JKoCozORDMyUtwFdWaxdX79Ye0CIj5R2O4dD X-Received: by 2002:a63:69c3:: with SMTP id e186-v6mr21290988pgc.353.1525413675399; Thu, 03 May 2018 23:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413675; cv=none; d=google.com; s=arc-20160816; b=GcQ97p0wZnVg+XisIaU6MWvYR/5h8QUo3llgBFai3Yc16BAK82Io+7gK0Kt92SCjex 5IKIYAz0Zs5r+6Jq0MSvirRn3qDUFSG3kbrmBBkb/+n/4C4hgt93Yihjzdr6DGgZBGCW 8yHTP8wjBXrOCpE5NPFBWiuaI9Da02m9KTK+Qfw7q/PE1xYOXkdgEDJixUSkWTJOTo+t RPXvetguRdutSLthXNjMCaPAhxBxJeeiaCQKKgOHm+P+klaHZv3phm4A+TkJMRX6p1Tg 9M3ZFWTbbUJ7iaKHPHnqm95z4w0vHdnOOkH5YayndUWLIzAa3SK2xMUGajWqQ+lLqRDV pOkg== 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=xPnWiymo7jyjUO31pkHyhT1jxuRfcYXb6BfF3fzVUCs=; b=zMY2bJcKOd8mqTGmtV/lV6hEKoZEzrbPpbXu1nXuHKsT9a5ld4flVOh23LnNxf3kx9 aJZKgchmzzq/1ynWuLRno++SLk6G2hLB3+YxggETuSkjkZTyslAw7rH4vrOlD9R6Z3cn FBduahwaonBy3yBBLbtPUIPenUttdrJJmInps6lDEhZzn1U5Akk09S2ACgPp96FTCvdt g4M1hL0jBDDk3IRBF4TuZDXtx+yBmggUiPw0Tog21K42JYxhbybvVAf23C4fZaOUldQe FsRWt23af8rdDGIk1m+lBdJdJ8TFooKb3Pi6OQRvfjQO9Ol8IKo0oxwegAy24ELBMiYe 94IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EF93XU8e; 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 b11-v6si5404750pgt.629.2018.05.03.23.01.15; Thu, 03 May 2018 23:01:15 -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 header.s=google header.b=EF93XU8e; 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 S1751522AbeEDGBO (ORCPT + 2 others); Fri, 4 May 2018 02:01:14 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:41391 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751484AbeEDGBM (ORCPT ); Fri, 4 May 2018 02:01:12 -0400 Received: by mail-wr0-f195.google.com with SMTP id g21-v6so19755289wrb.8 for ; Thu, 03 May 2018 23:01:11 -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=04YzESrWSqCb1wPHUOkcSLeeXaR7ExOS522dozm70w4=; b=EF93XU8eUb51+9Yswic7ejYtTPCiU0PHEwYi2HybtjVABrOaN7LW0ReG8bKlinkQP9 UfYFHYIcW9Xs84YBg2xW0WLyGzJJWtVkUPIlvBbnjU4y/lhDQpshRrz15DkHAmR6W4Cm CuAyQIVivp6l4tYs2rhRD6ZO3jXueyn4eJVNA= 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=04YzESrWSqCb1wPHUOkcSLeeXaR7ExOS522dozm70w4=; b=gUuVOFwA6gD9tU1PMF5Kk7066OIvmapFG6jXvp9I4b0XnFoINVIbTvdgaKW3/FS7IV CMKU/6pcyc+zvR8DdhVLvuOIeIQ0PzLrU8r+XjJpAtSi/+XFV6qTxviDAA/AMcVDD+uR r/Bm0Kc2Hp+/hralU8p9JhMgoPNvNw2x4bHC7L9vSC3sNEkI46C5sprFlRBZB/q0w8t+ J6F22trp63sMUTS0LZ8pYHYOhH/OILAcexa7S8zssXmnfwLZSJUDvuzyiLUUNbQFNPM6 cb792utXr9PlnsD9NfqzQQXgTbUZXASKu4to7T+80VS7GxXhXlJZ3SkMaXuLy19A2ARr FJdg== X-Gm-Message-State: ALQs6tBsdXTLPa2hMVR01Z1eoYpqWHLMmw9PImhUY/QKKWCTXBCBLLXH hkHQRnUgK6Ps3yaHerZZjm/NhKlFQYI= X-Received: by 2002:adf:a805:: with SMTP id l5-v6mr18701029wrc.97.1525413671030; Thu, 03 May 2018 23:01:11 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:10 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Yazen Ghannam , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 05/17] efi: Decode IA32/X64 Processor Error Info Structure Date: Fri, 4 May 2018 07:59:51 +0200 Message-Id: <20180504060003.19618-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Yazen Ghannam Print the fields in the IA32/X64 Processor Error Info Structure. Based on UEFI 2.7 Table 253. IA32/X64 Processor Error Information Structure. Signed-off-by: Yazen Ghannam Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/cper-x86.c | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) -- 2.17.0 -- 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/drivers/firmware/efi/cper-x86.c b/drivers/firmware/efi/cper-x86.c index 863f0cd2a0ff..e0633a103fcf 100644 --- a/drivers/firmware/efi/cper-x86.c +++ b/drivers/firmware/efi/cper-x86.c @@ -9,9 +9,20 @@ */ #define VALID_LAPIC_ID BIT_ULL(0) #define VALID_CPUID_INFO BIT_ULL(1) +#define VALID_PROC_ERR_INFO_NUM(bits) (((bits) & GENMASK_ULL(7, 2)) >> 2) + +#define INFO_VALID_CHECK_INFO BIT_ULL(0) +#define INFO_VALID_TARGET_ID BIT_ULL(1) +#define INFO_VALID_REQUESTOR_ID BIT_ULL(2) +#define INFO_VALID_RESPONDER_ID BIT_ULL(3) +#define INFO_VALID_IP BIT_ULL(4) void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) { + int i; + struct cper_ia_err_info *err_info; + char newpfx[64]; + if (proc->validation_bits & VALID_LAPIC_ID) printk("%sLocal APIC_ID: 0x%llx\n", pfx, proc->lapic_id); @@ -20,4 +31,41 @@ void cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc) print_hex_dump(pfx, "", DUMP_PREFIX_OFFSET, 16, 4, proc->cpuid, sizeof(proc->cpuid), 0); } + + snprintf(newpfx, sizeof(newpfx), "%s ", pfx); + + err_info = (struct cper_ia_err_info *)(proc + 1); + for (i = 0; i < VALID_PROC_ERR_INFO_NUM(proc->validation_bits); i++) { + printk("%sError Information Structure %d:\n", pfx, i); + + printk("%sError Structure Type: %pUl\n", newpfx, + &err_info->err_type); + + if (err_info->validation_bits & INFO_VALID_CHECK_INFO) { + printk("%sCheck Information: 0x%016llx\n", newpfx, + err_info->check_info); + } + + if (err_info->validation_bits & INFO_VALID_TARGET_ID) { + printk("%sTarget Identifier: 0x%016llx\n", + newpfx, err_info->target_id); + } + + if (err_info->validation_bits & INFO_VALID_REQUESTOR_ID) { + printk("%sRequestor Identifier: 0x%016llx\n", + newpfx, err_info->requestor_id); + } + + if (err_info->validation_bits & INFO_VALID_RESPONDER_ID) { + printk("%sResponder Identifier: 0x%016llx\n", + newpfx, err_info->responder_id); + } + + if (err_info->validation_bits & INFO_VALID_IP) { + printk("%sInstruction Pointer: 0x%016llx\n", + newpfx, err_info->ip); + } + + err_info++; + } } From patchwork Fri May 4 05:59:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134951 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp438169lji; Thu, 3 May 2018 23:02:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpXGlNW9IN9TGbKuu9jdZ3Vb8ThgSl/blw48KoNT3Frvm27Dc3JkrvA1NmZMKBZKFpjA8W0 X-Received: by 2002:a63:7351:: with SMTP id d17-v6mr20778134pgn.297.1525413761924; Thu, 03 May 2018 23:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413761; cv=none; d=google.com; s=arc-20160816; b=DnhOIlE/v/cIV/LfpGpvhjRxqnSNqb3pZ1heXRuKXOX8bj7zNkn4gOpB9s4HOsqStz nTQjI9dcYYHQRqLKjAsQDBwQELWBt5dFgk9HsVmpgUW0DddREcfJjNhblQoVKodl+sTY vnKk5pV7oLyLlrurFSvvcZCwZWMXrrCDfx3C/imXFqc1PWHT38V5Lh9BCeYbp/Crmh3s 2jDnm+7kU/zLKazAxvck2wtQZYPMv4lUnhpt+3c2gVqq1z5k6XLPp5PRcaGpJWCoZA7f 3/isjDSWzuk4Mp41AEpLIAx1AV/wUi8K9isKJlcVBqgPdz0DasMPd2AUK6DwHzoygRCB Wckw== 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=DP4JkgWAtbOlIPVGPptEC9kcOHFugAy9oPZiXyvto8A=; b=aWVdU59cHofsNl50govtnlYSIZzPgdAvZSWd5X+ial6ecQUgd4qfzahwPWb80W126W QKHLf7xgsJQZuAcHR9rtbPkc/BEMbS/IjRlJGhE/TQdEMmSlP73qcvZHDdTusGAA5PPg O5LXwgxP3emfV28prDDrJxGTMKVuhEp/XbbUrXFkKx4nyNsNvd5IGQcTB6azxlZVNtwl iLN7NJ6xOgVqt4zaWP9V2hxlmYus+NZ82l4FgBWoke658+KRW1p4/baA/e0asMzKvyxo RQzSTwwFIZVlwhidZXwS42iY7nwjexophEmD+Tm313sdcPF1sd3rH/vZLpN6/NyIIF7Q 9y3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NSkhG80N; 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 t85-v6si12394942pgb.42.2018.05.03.23.02.41; Thu, 03 May 2018 23:02:41 -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 header.s=google header.b=NSkhG80N; 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 S1751864AbeEDGCk (ORCPT + 2 others); Fri, 4 May 2018 02:02:40 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38707 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751701AbeEDGB0 (ORCPT ); Fri, 4 May 2018 02:01:26 -0400 Received: by mail-wm0-f68.google.com with SMTP id m198-v6so1808358wmg.3 for ; Thu, 03 May 2018 23:01:25 -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=Xw4qET6IJgIK2jUX6OwtXxw2asqgqhwFZVNmX4x/bfM=; b=NSkhG80NNcpYmGYaTzmnKh0Cbm+kXZA8GHaCIu2BpG5wDoSbx0OQHAd3OKI8E6n+Rw OipWLyZVfXO9iGLCz1kldqsQD+BKdXXYJAAOOCN3bANMyzFHDtwPclJZVUnqVVRmrtbh 5NGhVjouATAORQoKLZ1AB8y8TR08fM/PeC0bY= 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=Xw4qET6IJgIK2jUX6OwtXxw2asqgqhwFZVNmX4x/bfM=; b=DA5d1/W2Wn2bmm39+KJsm0d2el+izMIVllILLgYG7PKx5ao2fmZCfdIdc79aVZMq1v sRKmIS1cAa+LBj7Xy6RYN/meEY2YtAriWsslY4js3qtUi65Pjy5U/AFSutIHvcqBd7lD ry3nghIZUODWKE7eG+69oFZRFkw2ukRwC6rLnykq71bUo1c2/JP7tJa5eSCJ4+/ISL1O ecOu7RxEfORgrPmjwifvXL2/dif37tUohpaC2D5GWAwQ2z8vDArwdM8u/Ti/RBVdd82x xBzXqiFJP5MF2Srtsw0Xg/YISH2ptxpSYxXEBCMrTjU10zU8t4AMZNfwNP6zK1keMjkU FSNw== X-Gm-Message-State: ALQs6tAEjcODvXEuY08+TuDGRyHv2T5DZyxQQoStSov1YJQJUkgX0PKI S+eJkAt0+VBD1oI58OXD5K1iphKzlmg= X-Received: by 10.28.146.196 with SMTP id u187mr12154413wmd.78.1525413684681; Thu, 03 May 2018 23:01:24 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:24 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 12/17] efi: fix efi_pci_io_protocol32 prototype for mixed mode Date: Fri, 4 May 2018 07:59:58 +0200 Message-Id: <20180504060003.19618-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Mixed mode allows a kernel built for x86_64 to interact with 32-bit EFI firmware, but requires us to define all struct definitions carefully when it comes to pointer sizes. efi_pci_io_protocol32 currently uses a void* for the 'romimage' field, which will be interpreted as a 64-bit field on such kernels, potentially resulting in bogus memory references and subsequent crashes. Cc: Tested-by: Hans de Goede Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 6 ++++-- include/linux/efi.h | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) -- 2.17.0 -- 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/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 47d3efff6805..09f36c0d9d4f 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -163,7 +163,8 @@ __setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom) if (status != EFI_SUCCESS) goto free_struct; - memcpy(rom->romdata, pci->romimage, pci->romsize); + memcpy(rom->romdata, (void *)(unsigned long)pci->romimage, + pci->romsize); return status; free_struct: @@ -269,7 +270,8 @@ __setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom) if (status != EFI_SUCCESS) goto free_struct; - memcpy(rom->romdata, pci->romimage, pci->romsize); + memcpy(rom->romdata, (void *)(unsigned long)pci->romimage, + pci->romsize); return status; free_struct: diff --git a/include/linux/efi.h b/include/linux/efi.h index f1b7d68ac460..3016d8c456bc 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -395,8 +395,8 @@ typedef struct { u32 attributes; u32 get_bar_attributes; u32 set_bar_attributes; - uint64_t romsize; - void *romimage; + u64 romsize; + u32 romimage; } efi_pci_io_protocol_32; typedef struct { @@ -415,8 +415,8 @@ typedef struct { u64 attributes; u64 get_bar_attributes; u64 set_bar_attributes; - uint64_t romsize; - void *romimage; + u64 romsize; + u64 romimage; } efi_pci_io_protocol_64; typedef struct { From patchwork Fri May 4 06:00:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134950 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp437803lji; Thu, 3 May 2018 23:02:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZotZZmKWFt8hDfaiv7ati60N/mm7PoGIWnapj4nGxPGjgY2R9crB78O05iDknDgSMkDWZWQ X-Received: by 2002:a17:902:9344:: with SMTP id g4-v6mr5462330plp.10.1525413735907; Thu, 03 May 2018 23:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413735; cv=none; d=google.com; s=arc-20160816; b=N+0LAsfs9NRG6v20k+NZ46pAVc5+kEORib6E+BVSrFO3f/EMW7AtuwrpU66QRQiU3r VqsrPc/xjvbAB34ketaOKg9cbI2JvHCZCk9TKBpqwkE08xtczpxZ4A73qLmw5jk5hxhJ dXTJByZqEGxaBbwDS0/DVig+DdSN6+jszIV2aXQkDfVP4H7SwZrLdnwdWpG9V3SEpqpz 7pVU8XFTIPhjpd77D4GbX6X1QgzKCpVksb/5rlaAYuR6FE7vQdFzXdqLSNUt39vMOTUA VgfBwqO2cF3G40GSajzntHnFpe0MmxI8Xm+ZIXNweieNrHAV08+6ZIWLn4odn7RA109+ +e7g== 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=ZneFtIyMB166cKy4GiIBqgNuibXNV+32TEioqc1Ngj8=; b=UndECkU9qDGPH7m4bnzy79zv+aKcnfzKp47n6PdIhNQRE8FYeUu14ub/dBDLbgQ03j FnUR17M3UElFhpe05vfBJiuVzytfkSqiYMfaa2t1EGL3BeKhyd0Gu/tyIjw/Jxhqu7G3 wQck13CIu1IBL1bgLG/8tzaU9MpOObESJHBcws4HCKPp2ic+7tcep/9lfOH+DIsX1FsR cnDRtzxGvXiVRDwikLzV70ThASZbbYOTx87eaHDwe05bhRhnWP+FmveryMZqZgEma4lI jihtU0WWrs1L2JIOi8OehN1oJ6gM/6TrkBkChpkkTvHAESDq0Y3I6I/zPdyyJXhT46Ta xi4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cDUzg2O8; 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 w16-v6si15270939plk.79.2018.05.03.23.02.15; Thu, 03 May 2018 23:02:15 -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 header.s=google header.b=cDUzg2O8; 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 S1751838AbeEDGCN (ORCPT + 2 others); Fri, 4 May 2018 02:02:13 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38717 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751753AbeEDGBc (ORCPT ); Fri, 4 May 2018 02:01:32 -0400 Received: by mail-wm0-f68.google.com with SMTP id m198-v6so1808697wmg.3 for ; Thu, 03 May 2018 23:01:31 -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=XE1a7gnnfTllM3Yx/f6JMoC5+8afwXHt17si3UFIAIg=; b=cDUzg2O8UXX5z5GiXTYYcG9WlM33bX3FksX3vHB6bVUODLZovC0Zb3zx8vDqIbuQvh bGkZDtoWpZ80XT2sqoJx39WsaHEsAkv1/epr1tYiAE4ajXZNJbo07b49We8HbvrjBVf2 um1aoZ9bbnmpb8eDIMZmONXvucp7OI03k3+Ow= 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=XE1a7gnnfTllM3Yx/f6JMoC5+8afwXHt17si3UFIAIg=; b=Jhh/EvRoVsJPRTD8g6TMhb82t50XG4aMdh3yJJdteaHoFjhqR+fHjT4un4XyiPdbE0 3G/YVdMwlc07Yk5dKPqKChKbOlfWpDxFCZtCNxjEjE7pGVLm+ttBPrTb28Ydzmb5jfJ6 aVyyDZnR2kpYJpNdbQwCh6kXUVC/0VYEF743sJPFhiXihircIVLpIj5cbttvWeYv8Y0x +zzpoPHsArGcTSoIqnDhSDzdRxgYEjsi3Mw9IEArc0ZpEmq/1JYuG0n9qnIu/3E3pKFo PxZoG2jxqMnZ+dK3I3NO/Vf5JWkglo7PoRRzPol7eplC/mcN4IQsX2QU6/9KkRcc+Ywb v0Fg== X-Gm-Message-State: ALQs6tBSkkECb7mzO4REJ9i+5FJ9tODM9dTx7UxL399lWL1GoybXmaZM gtk2KDt/MaBzTP4qebn9/Y4tnqfxspg= X-Received: by 10.28.174.12 with SMTP id x12mr8566969wme.133.1525413690488; Thu, 03 May 2018 23:01:30 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:29 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Hans de Goede , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 15/17] efi/x86: Ignore unrealistically large option roms Date: Fri, 4 May 2018 08:00:01 +0200 Message-Id: <20180504060003.19618-16-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Hans de Goede setup_efi_pci() tries to save a copy of each PCI option ROM as this may be necessary for the device driver for the PCI device to have access too. On some systems the efi_pci_io_protocol's romimage and romsize fields contain invalid data, which looks a bit like pointers pointing back into other EFI code or data. Interpreting these pointers as romsize leads to a very large value and if we then try to alloc this amount of memory to save a copy the alloc call fails. This leads to a "Failed to alloc mem for rom" error being printed on the EFI console for each PCI device. This commit avoids the printing of these errors, by checking romsize before doing the alloc and if it is larger then the EFI spec limit of 16 MiB silently ignore the ROM fields instead of trying to alloc mem and fail. Signed-off-by: Hans de Goede [ardb: deduplicate 32/64 bit changes, use SZ_16M symbolic constant] Tested-by: Hans de Goede Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.17.0 -- 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 Reviewed-by: Ard Biesheuvel diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index dadf32312082..720b06e86698 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -123,10 +123,17 @@ __setup_efi_pci(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) if (status != EFI_SUCCESS) return status; + /* + * Some firmwares contain EFI function pointers at the place where the + * romimage and romsize fields are supposed to be. Typically the EFI + * code is mapped at high addresses, translating to an unrealistically + * large romsize. The UEFI spec limits the size of option ROMs to 16 + * MiB so we reject any roms over 16 MiB in size to catch this. + */ romimage = (void *)(unsigned long)efi_table_attr(efi_pci_io_protocol, romimage, pci); romsize = efi_table_attr(efi_pci_io_protocol, romsize, pci); - if (!romimage || !romsize) + if (!romimage || !romsize || romsize > SZ_16M) return EFI_INVALID_PARAMETER; size = romsize + sizeof(*rom); From patchwork Fri May 4 06:00:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134948 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp437425lji; Thu, 3 May 2018 23:01:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpFIIes69/kJpHR/OJPLebpEsptFGpgW72pGqakI+PgF8psNBrUZNa9fHRWHkrzfO5vQg3v X-Received: by 10.98.9.145 with SMTP id 17mr25823240pfj.34.1525413714564; Thu, 03 May 2018 23:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413714; cv=none; d=google.com; s=arc-20160816; b=PS2MiDKwt4ldLRA1n94LKl6gboTkXqdY6DbE9KpKx0gZByJatY5UqjM7LJiCVLRZVo VBAwZyDumGg3LfA5BwLX9SlsoLUHcfsgoMxf2MCXw/T/8QWTnnz9r+3lVtQRfixFi40H UdkPHEXSDY9ecQ+Q8OKOD6ncgfshG1s76sdp6Uq5UXDoN7gHrK77XV7W6WEFaViMlqMh LpRhhAmXbKri9I1tTHnlLezEaylCMTo5yGPxERUbC3oP1av+nfyhvjSI8+VtISuP1qgZ gBdmfwwfaBGebzDchX+E1eVeACoapVXxUhB3HtedrfV1aJprQvuF/2n+sNFJ1zoA2xO9 1Xpw== 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=nLeVeiKyGsEeMoTHvhs17H07m/H0FKm9ciRx+OxuJsM=; b=PKUIf/v4pq0vAopR11CRW8OdvdR00jDyk+VES4LIla/PcOZghx+k7pWg/Tr3kNwJQJ DeVV2tUCsuaF3/5YgVUEuKl7/VkzDZJnvYNZ4Cz/BrjLvBvm8Q83Xb5ozGbCIAMK9Ws3 418RzRNehxPvac6zRJUKX/aMiLzPD114Zl+Go/gCfDW+nb5xmdUquoVWy+YSsBD41Bq0 tJDRVSItjVakzt4ybtOM07A5dlXbYQSZCzMXrPv3BdsV2UzBlQV18g4PDSCgwk61I2ZU NnGCxXwRZZIrPKxBob0BvEA8WizI6sCii4gvTLQ096GIoXzhlma+COelZkLTdbr0iE1c VP6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=T3fB0vup; 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 m2-v6si12958816pgm.360.2018.05.03.23.01.54; Thu, 03 May 2018 23:01:54 -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 header.s=google header.b=T3fB0vup; 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 S1751268AbeEDGBx (ORCPT + 2 others); Fri, 4 May 2018 02:01:53 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40474 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751777AbeEDGBd (ORCPT ); Fri, 4 May 2018 02:01:33 -0400 Received: by mail-wm0-f68.google.com with SMTP id j5-v6so2532364wme.5 for ; Thu, 03 May 2018 23:01:33 -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=Pd8vuiUTQlz4ADaoQal5KRfctP9hcRTl0q3Xn9YsCZY=; b=T3fB0vupdy9LPbqDgDaG2XnnNaJfDoTexx0UjqwRoYgG8ngXO84vwyPIrX7xj7+lLn cEsLUh67hZ83vFq/HGTBnRZXSJKGkNWkcrqfeuCqtm38Ua6hrFq43BqZU+SthWrzlHKe +zhTN2HyLypejpIGPvTnveVrm34h9DnEDCLfc= 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=Pd8vuiUTQlz4ADaoQal5KRfctP9hcRTl0q3Xn9YsCZY=; b=fXLOGN9iEof5NealZEj2cXeQT8yE1mrJ3C6C4e2NS6KUH5z08iECGd235TOzzWeyyX ukj0IppyswEw4wUkFaslh6gSR0MR5Oyvfm1/2Biqs330PROcVWFi49XZSEr7tY4MjwWP OJOzLfUQcQo/22O5Epid11M+8aTK+Xn1/boYtqeEJfvuNTonXXzwW4Y7WgPDCHINhrF7 6mhmm4GD8vEN8CpFupEWvQYFRljhB7h29O7t5Bzg5QCN6vTMjsoh9UZK20S1ypmn3CqZ BIvf1uc6gc3nQqy+9+vR/3QRIvqpJxOf4jyVegP2nGCmutIZqu/R4bZxh+A0TZDdePLr mhWw== X-Gm-Message-State: ALQs6tAeWB5Wy23nPm9HQf6j95iWXAPvCxPd+canATclLniF4DS4VgLu kW0ILd80p5O0zTunyu90IgkfEfu1sQE= X-Received: by 10.28.21.195 with SMTP id 186mr18050834wmv.39.1525413692442; Thu, 03 May 2018 23:01:32 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:31 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Shunyong Yang , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 16/17] efi/capsule-loader: Don't output reset log when reset flags are not set Date: Fri, 4 May 2018 08:00:02 +0200 Message-Id: <20180504060003.19618-17-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Shunyong Yang When reset flags in capsule header are not set, it means firmware attempts to immediately process or launch the capsule. Moreover, reset is not needed in this case. The current code will output log to indicate reset. This patch adds a branch to avoid reset log output when the flags are not set. Cc: Joey Zheng Signed-off-by: Shunyong Yang [ardb: use braces in multi-line 'if', clarify comment and commit log] Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/capsule-loader.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.17.0 -- 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/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index e456f4602df1..96688986da56 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -134,10 +134,16 @@ static ssize_t efi_capsule_submit_update(struct capsule_info *cap_info) /* Indicate capsule binary uploading is done */ cap_info->index = NO_FURTHER_WRITE_ACTION; - pr_info("Successfully upload capsule file with reboot type '%s'\n", - !cap_info->reset_type ? "RESET_COLD" : - cap_info->reset_type == 1 ? "RESET_WARM" : - "RESET_SHUTDOWN"); + + if (cap_info->header.flags & EFI_CAPSULE_PERSIST_ACROSS_RESET) { + pr_info("Successfully uploaded capsule file with reboot type '%s'\n", + !cap_info->reset_type ? "RESET_COLD" : + cap_info->reset_type == 1 ? "RESET_WARM" : + "RESET_SHUTDOWN"); + } else { + pr_info("Successfully processed capsule file\n"); + } + return 0; }