From patchwork Fri Aug 25 15:50:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 111032 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1219222qge; Fri, 25 Aug 2017 08:59:37 -0700 (PDT) X-Received: by 10.101.76.139 with SMTP id m11mr3111987pgt.160.1503676777243; Fri, 25 Aug 2017 08:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503676777; cv=none; d=google.com; s=arc-20160816; b=c0l8JkiUCEnF2vuhmkN7oFnyXwS8Hxmb2yP/yX5M2nAEUiNd28tJ2OcpLZazUsUDce qGj5SQYkozQAbQrfTUzOzFeQMf4QB3k95U0vPOSTY7Auns29xi5Yro7WhYuTX59CcsmG IVf38XR4DBT9dAnccc/3rEtbduGrlJOnjKgPt2A0H6nFwwjuR6MZUxQhgp0HY9IDOPx2 81WM03cYkkJ8PJaGDF6LVD9L15cwKNq5JabxktlFx7U74zklqrvykW9iHaktKlMoBfPv mEjrCZzmkqthIrKyab2bHuM6RO+Og/dqmvWktUK4FfzyE65pxPEWDCx7wDQjCRcLxK0c HH2w== 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=yeh1AHTMnB28aqq2EkdnHsurG1pADBSntYpp9jxtf5Y=; b=monu7R189CmdBEOqId0wRWt7wK6OM0HnLS/l3HEh1MsKC66roxP4aJ4/CzkH9F5RmW 6G8lsLDmsPKVB6p4TLRoSC/DzoZbUKJqBfZkjKwV+GQOVfgDn1JponAuM/ylxCXbKw5K UmJ/lMuL3Fd7TXbbOjBksdr0g/kx+gsiqnVLk1C0bwsn3Oi2i7I1u8Y+Zsxaw+Xpmp/L gXkcBTSK+1Qb4bR9Q3DtvOGC7gCAjTiH0BS079yGlnz23L+qi2LXW82et0nFomD1hfaw z8upYN5NnInoqey/U8KYbhivsBvW/LjHhFTwTWHS5iChYaEcUbBp5AA/vbqmmPEef3/X COQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JvzDtQ2b; 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 q4si5489004pli.267.2017.08.25.08.59.36; Fri, 25 Aug 2017 08:59:37 -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 header.s=google header.b=JvzDtQ2b; 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 S934112AbdHYP7e (ORCPT + 26 others); Fri, 25 Aug 2017 11:59:34 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:34539 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934089AbdHYP73 (ORCPT ); Fri, 25 Aug 2017 11:59:29 -0400 Received: by mail-wr0-f182.google.com with SMTP id z91so692846wrc.1 for ; Fri, 25 Aug 2017 08:59:28 -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=yeh1AHTMnB28aqq2EkdnHsurG1pADBSntYpp9jxtf5Y=; b=JvzDtQ2bCtoW4OPJPfhIrzMvEZTSIjVJNdSTCyVqhcTOHmpTWG24TSSlB7Kz/ufSme X7a2LfQ7gBNhCyf1nGfcNqcSGqB/HIuxoCZRQSn6Mkwj4cT67MoEx+pHnPCwUoqLi2NC 8q6xDY70qvU7X2wfmyenSIyhcoVm5RwIxGRdo= 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=yeh1AHTMnB28aqq2EkdnHsurG1pADBSntYpp9jxtf5Y=; b=RpjQLgcJ3qcL4gtqWGwE/UhkdOKxzIj9x9jCLa2HtfFaihNgaWdKmmjlCwnjxvpbOh aQtMF9DdFSUuf1SrBr9qK/OyF5VXy9zsPbxT4QHl15oNSm6Mgvy7Bfgi7uA4QYByy3UT xVqNLrYtPQ/b/uTBshH1iVT8Rs54APEU5NxdQhB0Va0a9drlwrG6IAXm0D22nOTrVEOT +OuYWOL2ce2426LA1Pm5ejgr0LX6PrCKSqYYUBTWu2KYguiTc9TpaLDRuNT66CukQcwj J1h4VUkawyoanH99xGBaLWtcJz0FvfFLNvUiV1MS5wer0Y8Y6yUo6sjdQCcYIo+Bygg3 OYdg== X-Gm-Message-State: AHYfb5jAmMWDdzLSBAmFQHje0K0iQlC2X/7kqwEY6Oxb5MJzniH/OxQr bcVxPrLOZGKEhSq4 X-Received: by 10.223.186.13 with SMTP id o13mr7139428wrg.129.1503676767613; Fri, 25 Aug 2017 08:59:27 -0700 (PDT) Received: from localhost.localdomain ([105.137.125.182]) by smtp.gmail.com with ESMTPSA id b96sm14507757wrd.94.2017.08.25.08.59.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 08:59:26 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Matthew Garrett , Ard Biesheuvel , linux-kernel@vger.kernel.org, Matt Fleming Subject: [PATCH 1/5] efi/libstub: Enable reset attack mitigation Date: Fri, 25 Aug 2017 16:50:15 +0100 Message-Id: <20170825155019.6740-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825155019.6740-1-ard.biesheuvel@linaro.org> References: <20170825155019.6740-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Garrett If a machine is reset while secrets are present in RAM, it may be possible for code executed after the reboot to extract those secrets from untouched memory. The Trusted Computing Group specified a mechanism for requesting that the firmware clear all RAM on reset before booting another OS. This is done by setting the MemoryOverwriteRequestControl variable at startup. If userspace can ensure that all secrets are removed as part of a controlled shutdown, it can reset this variable to 0 before triggering a hardware reboot. Signed-off-by: Matthew Garrett Cc: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 3 ++ drivers/firmware/efi/Kconfig | 10 ++++++ drivers/firmware/efi/libstub/Makefile | 1 + drivers/firmware/efi/libstub/arm-stub.c | 3 ++ drivers/firmware/efi/libstub/tpm.c | 58 +++++++++++++++++++++++++++++++++ include/linux/efi.h | 7 ++++ 6 files changed, 82 insertions(+) create mode 100644 drivers/firmware/efi/libstub/tpm.c -- 2.11.0 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index c3e869eaef0c..a1686f3dc295 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -997,6 +997,9 @@ struct boot_params *efi_main(struct efi_config *c, if (boot_params->secure_boot == efi_secureboot_mode_unset) boot_params->secure_boot = efi_get_secureboot(sys_table); + /* Ask the firmware to clear memory on unclean shutdown */ + efi_enable_reset_attack_mitigation(sys_table); + setup_graphics(boot_params); setup_efi_pci(boot_params); diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index 394db40ed374..2b4c39fdfa91 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -151,6 +151,16 @@ config APPLE_PROPERTIES If unsure, say Y if you have a Mac. Otherwise N. +config RESET_ATTACK_MITIGATION + bool "Reset memory attack mitigation" + depends on EFI_STUB + help + Request that the firmware clear the contents of RAM after a reboot + using the TCG Platform Reset Attack Mitigation specification. This + protects against an attacker forcibly rebooting the system while it + still contains secrets in RAM, booting another OS and extracting the + secrets. + endmenu config UEFI_CPER diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index cf81e6cf5ae8..dedf9bde44db 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -30,6 +30,7 @@ OBJECT_FILES_NON_STANDARD := y KCOV_INSTRUMENT := n lib-y := efi-stub-helper.o gop.o secureboot.o +lib-$(CONFIG_RESET_ATTACK_MITIGATION) += tpm.o # include the stub's generic dependencies from lib/ when building for ARM/arm64 arm-deps := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c sort.c diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index 8181ac179d14..1cb2d1c070c3 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -192,6 +192,9 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, goto fail_free_cmdline; } + /* Ask the firmware to clear memory on unclean shutdown */ + efi_enable_reset_attack_mitigation(sys_table); + secure_boot = efi_get_secureboot(sys_table); /* diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c new file mode 100644 index 000000000000..6224cdbc9669 --- /dev/null +++ b/drivers/firmware/efi/libstub/tpm.c @@ -0,0 +1,58 @@ +/* + * TPM handling. + * + * Copyright (C) 2016 CoreOS, Inc + * Copyright (C) 2017 Google, Inc. + * Matthew Garrett + * + * This file is part of the Linux kernel, and is made available under the + * terms of the GNU General Public License version 2. + */ +#include +#include + +#include "efistub.h" + +static const efi_char16_t efi_MemoryOverWriteRequest_name[] = { + 'M', 'e', 'm', 'o', 'r', 'y', 'O', 'v', 'e', 'r', 'w', 'r', 'i', 't', + 'e', 'R', 'e', 'q', 'u', 'e', 's', 't', 'C', 'o', 'n', 't', 'r', 'o', + 'l', 0 +}; + +#define MEMORY_ONLY_RESET_CONTROL_GUID \ + EFI_GUID(0xe20939be, 0x32d4, 0x41be, 0xa1, 0x50, 0x89, 0x7f, 0x85, 0xd4, 0x98, 0x29) + +#define get_efi_var(name, vendor, ...) \ + efi_call_runtime(get_variable, \ + (efi_char16_t *)(name), (efi_guid_t *)(vendor), \ + __VA_ARGS__) + +#define set_efi_var(name, vendor, ...) \ + efi_call_runtime(set_variable, \ + (efi_char16_t *)(name), (efi_guid_t *)(vendor), \ + __VA_ARGS__) + +/* + * Enable reboot attack mitigation. This requests that the firmware clear the + * RAM on next reboot before proceeding with boot, ensuring that any secrets + * are cleared. If userland has ensured that all secrets have been removed + * from RAM before reboot it can simply reset this variable. + */ +void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) +{ + u8 val = 1; + efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID; + efi_status_t status; + unsigned long datasize = 0; + + status = get_efi_var(efi_MemoryOverWriteRequest_name, &var_guid, + NULL, &datasize, NULL); + + if (status == EFI_NOT_FOUND) + return; + + set_efi_var(efi_MemoryOverWriteRequest_name, &var_guid, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, sizeof(val), &val); +} diff --git a/include/linux/efi.h b/include/linux/efi.h index 8269bcb8ccf7..12e05118657c 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1497,6 +1497,13 @@ enum efi_secureboot_mode { }; enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table); +#ifdef CONFIG_RESET_ATTACK_MITIGATION +void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg); +#else +static inline void +efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) { } +#endif + /* * Arch code can implement the following three template macros, avoiding * reptition for the void/non-void return cases of {__,}efi_call_virt(): From patchwork Fri Aug 25 15:50:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 111036 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1220542qge; Fri, 25 Aug 2017 09:00:34 -0700 (PDT) X-Received: by 10.99.39.135 with SMTP id n129mr10258527pgn.36.1503676833894; Fri, 25 Aug 2017 09:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503676833; cv=none; d=google.com; s=arc-20160816; b=KKsSv2IzSv2SqTvoOh4b1g9hkjv0ls6jI5BdEmmAQy5oSGvGh/t+1cttuF4qNwAYQA NWrQCYbsCEy5TPBt/fh4VMo3nXkbGc10nJfN6G6nN6t5cdxUHsxn0wYfbnvtrRofrJE8 G1IQioJpJ+J02zFq6HXizLeOuVrTm4jI1VLDF8vU81lgAUVsD46oiqM40pNfoO4SKouT MXZ+jts9Mg5JOBKCYjbai6iQbMsFAhz0ZwE0jAp9FkoM3x0LfdqY3g5yu5h6AQWSAwEc CMjzQ4CXw1fpmkSWV5BqrQcGcwTz2Fbt0DPipjTrvokkKD3qg2i8fRBtJXJe1utmqHQd JU+w== 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=Wyuy/mlIDfntK6vu6GmgfJkBQ34Jcu17erRIovoJoeo=; b=TUFmF7Wdy2ckYz1yffBSEDZ7mAZW728vlKGLhuCnaOnisn92IiJnhBkbrRiRJUwWbW WCpaGatmWc2N32+tG7jFKMO7u+CR2FCMl/2HmUsUmAylromfcxVqWfqSeRC1G69dzP0y dTgiHgeSe5hix0RhScSDWSm9/PCIbvYj2Ts6Pk3y3ES6tN/DJI2wBSvaIChq4hEn6g7A 0LwCQIWXvBsC+BEmdV868HDjG1HUtkqm4ZVSVn0d3ySzJ6xyoCYcc3ZBZkIXlIpY3aBB gZM/87sX7gn/V39+I5jgkmLnhni+XZo34HdSzk43cqx+ARsmMN7LT3foi1MR4xV+tocN h0/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hL1ynxN/; 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 e6si4846786pgp.440.2017.08.25.09.00.32; Fri, 25 Aug 2017 09:00:33 -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 header.s=google header.b=hL1ynxN/; 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 S934162AbdHYQAa (ORCPT + 26 others); Fri, 25 Aug 2017 12:00:30 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:37476 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934093AbdHYP7b (ORCPT ); Fri, 25 Aug 2017 11:59:31 -0400 Received: by mail-wr0-f182.google.com with SMTP id a47so623130wra.4 for ; Fri, 25 Aug 2017 08:59:30 -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=Wyuy/mlIDfntK6vu6GmgfJkBQ34Jcu17erRIovoJoeo=; b=hL1ynxN/jam1cOBU1cV1a7liBWDsvhTa8l4INlr8brTfQeiLblkNz8eD02yxZSrJhw TpiR2S69REI498txVJ3VwtNeDLY7c0l5iEnoF98V/f3MClNpTKSe/5pGkbBzCOs7YD3s 4oNtABEIoMIQtxxQZEEIc6sMTgfvElgRr8n+o= 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=Wyuy/mlIDfntK6vu6GmgfJkBQ34Jcu17erRIovoJoeo=; b=hRNjz2OFF0GoJLzwDfpemkocPOLy4QxxnF2633MJ6A+mKRl93pR9owPrsKzEohCTkv L3CNqNwRoDSXSSIa8vSD5nJqgCXzz2/hKzSQGR4+IQYpVDgSYMkoX/XUzoyCKCmtc2J8 pKcsH9XPXW71obPbD7Kv1r9Vp8zZqhIQzknABM6mSA7dSbuV5conZeE5HdA5RbQQJT4Z JTIYPZ0aG0WSXdOPDUvO+oOzlglc84iquxI85Wa8F9Yr0me7IHd3vXJlS9Vo6bhk/TOV oITkFXuo4ZxRmTpOtWTUkwexFJGZquqKk885HKN8pmcIMkEWp7hdJZI4Fwg36+6kwVZJ gRgQ== X-Gm-Message-State: AHYfb5iNJSTiDNARmalr/aPSDekJgFx3zvwFBp3ZldSjxB7aP3i0AA+A kxpab0ocQBR583aM X-Received: by 10.223.175.21 with SMTP id z21mr7543783wrc.145.1503676769986; Fri, 25 Aug 2017 08:59:29 -0700 (PDT) Received: from localhost.localdomain ([105.137.125.182]) by smtp.gmail.com with ESMTPSA id b96sm14507757wrd.94.2017.08.25.08.59.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 08:59:29 -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 2/5] efi/random: Increase size of firmware supplied randomness Date: Fri, 25 Aug 2017 16:50:16 +0100 Message-Id: <20170825155019.6740-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825155019.6740-1-ard.biesheuvel@linaro.org> References: <20170825155019.6740-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The crng code requires at least 64 bytes (2 * CHACHA20_BLOCK_SIZE) to complete the fast boot-time init, so provide that many bytes when invoking UEFI protocols to seed the entropy pool. Also, add a notice so we can tell from the boot log when the seeding actually took place. Cc: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 3 ++- drivers/firmware/efi/libstub/random.c | 10 ++++------ include/linux/efi.h | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) -- 2.11.0 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 6519be44387c..9e822906adcb 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -522,6 +522,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, if (seed != NULL) { add_device_randomness(seed->bits, seed->size); early_memunmap(seed, sizeof(*seed) + size); + pr_notice("seeding entropy pool\n"); } else { pr_err("Could not map UEFI random seed!\n"); } @@ -867,7 +868,7 @@ static int update_efi_random_seed(struct notifier_block *nb, seed = memremap(efi.rng_seed, sizeof(*seed), MEMREMAP_WB); if (seed != NULL) { - size = min(seed->size, 32U); + size = min(seed->size, EFI_RANDOM_SEED_SIZE); memunmap(seed); } else { pr_err("Could not map UEFI random seed!\n"); diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c index 7e72954d5860..e0e603a89aa9 100644 --- a/drivers/firmware/efi/libstub/random.c +++ b/drivers/firmware/efi/libstub/random.c @@ -145,8 +145,6 @@ efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, return status; } -#define RANDOM_SEED_SIZE 32 - efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) { efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; @@ -162,25 +160,25 @@ efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) return status; status = efi_call_early(allocate_pool, EFI_RUNTIME_SERVICES_DATA, - sizeof(*seed) + RANDOM_SEED_SIZE, + sizeof(*seed) + EFI_RANDOM_SEED_SIZE, (void **)&seed); if (status != EFI_SUCCESS) return status; - status = rng->get_rng(rng, &rng_algo_raw, RANDOM_SEED_SIZE, + status = rng->get_rng(rng, &rng_algo_raw, EFI_RANDOM_SEED_SIZE, seed->bits); if (status == EFI_UNSUPPORTED) /* * Use whatever algorithm we have available if the raw algorithm * is not implemented. */ - status = rng->get_rng(rng, NULL, RANDOM_SEED_SIZE, + status = rng->get_rng(rng, NULL, EFI_RANDOM_SEED_SIZE, seed->bits); if (status != EFI_SUCCESS) goto err_freepool; - seed->size = RANDOM_SEED_SIZE; + seed->size = EFI_RANDOM_SEED_SIZE; status = efi_call_early(install_configuration_table, &rng_table_guid, seed); if (status != EFI_SUCCESS) diff --git a/include/linux/efi.h b/include/linux/efi.h index 12e05118657c..8dc3d94a3e3c 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1564,6 +1564,8 @@ efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table, void *priv, efi_exit_boot_map_processing priv_func); +#define EFI_RANDOM_SEED_SIZE 64U + struct linux_efi_random_seed { u32 size; u8 bits[]; From patchwork Fri Aug 25 15:50:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 111033 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1219343qge; Fri, 25 Aug 2017 08:59:43 -0700 (PDT) X-Received: by 10.101.85.193 with SMTP id k1mr9978561pgs.328.1503676783611; Fri, 25 Aug 2017 08:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503676783; cv=none; d=google.com; s=arc-20160816; b=FPyn5LvH88uj3+EEJ9eTKPSmCOfLOdulkHswZoV4arKZYTAW72K5bdSsE+KU2Uha/0 ec+I3C6Uxa7fzxhq389lxYEUW9xJt88ATJm6CBf+FiSfBhK7SxCGI9sRCVQurb2yndfc 5QNzYP4rFaRw67pZrKF1Q4MKr/W1o8mQG5wI9jR2qMdSfX1J3c6mFv3FxsR6BFw8PRyP yWJOTLt/fdOdTBBClU5QZK/aJug3F27wbmldrCAMklTGE+E6xBXe92esOEX3o+7DB9F3 grybjYhtV6N77LBynlGk4j0hmMLvSv/wq0N/UhWsbVuc8NMDW9ex2KPBjzmZXJiPgSkD lhPA== 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=b+dQj+2DZHZIrYWTsOCNpO51m8t2K7qWXOWuTx1bPJk=; b=jsBC+f+vPfr1+q4yKT62xRe/YzkHDcM5l7lF2S1yPDRxUlF3IKdcc4reKueTlx2NN4 NoTO2q4R+J3mEPcKE1mqWIkVH5lQaNSt+hTiL3mULCr0JBERTkDEruDCfpipK5c9ewdD rT/JojDjqjvGrGPhMc1iCd7P7rW297SYr7bVDB8qUIgI6oH24GOoqcGcmzegSfq/KlrK O3HKPhqcZTMVaHY8UFNvXVmKM/WY1zm2tyW6WE4gz9LY8WFQ9MIkcod6nyIYzioE4BsQ j5vGxEmyCEQo8I0qUx/jGnE1epjFHO4MeXJw+DoOdMLdL8dlgIk6J8bL4K5rrm/CW1n1 Ybvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YdqzRyCy; 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 q4si5489004pli.267.2017.08.25.08.59.43; Fri, 25 Aug 2017 08:59:43 -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 header.s=google header.b=YdqzRyCy; 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 S934129AbdHYP7k (ORCPT + 26 others); Fri, 25 Aug 2017 11:59:40 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:33545 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934105AbdHYP7d (ORCPT ); Fri, 25 Aug 2017 11:59:33 -0400 Received: by mail-wm0-f41.google.com with SMTP id b14so1895636wme.0 for ; Fri, 25 Aug 2017 08:59: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=b+dQj+2DZHZIrYWTsOCNpO51m8t2K7qWXOWuTx1bPJk=; b=YdqzRyCyTuVgWloXdZUAx7/qbCQLVDFRrjTqgPcxqsGFUlvZ0xcEQpdZLPnpaWK5CQ 0SNTe5t2OYEUSpG39Cdv+5k1hS9BDH0lUMuX5El8sLp84qI6JnSPlb2N/J517tHy/7kU gQGiodzrX+ziad2e2p2XLN0toVXsCVx/en6gE= 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=b+dQj+2DZHZIrYWTsOCNpO51m8t2K7qWXOWuTx1bPJk=; b=IKyBnIs20J3y0DDuZpjRM8nu6lUVFcbmu+e2dIkAo24P61Nfg44U48nCuBcVa4tzVE UG+mVCaoMih9C9rD8TGtMSttsRkfB0ikPY6kG7NO5eMPigD13XH94A+arSlGi27gT1IR qZLiRQtGDqXZUN8xUXVXF2s8AP+TCZ+Q2Kwq8br0bn/DzzZYEGVpsu6zszfwfreTyJ3j Lt4Se/UgjxLr1LSTynWpId/SK4kdgi1HreKv9S2ebOCNxTHP/vR7b+3QeCWnjRGMApla xCEPoyBdtlsunnOBrOUI/05s/AbUxtR81pCdEW+n4Kchxk6frz1sHxH/BdnUjdTeIZ1/ BE7g== X-Gm-Message-State: AHYfb5jqHtvi3OxAQjjG7DaK2zb8aoHhONhzCK2i9Ky+HfJp4pFqJNGB 3VGYdsf/uv2egAQW X-Received: by 10.28.36.194 with SMTP id k185mr1454395wmk.124.1503676772569; Fri, 25 Aug 2017 08:59:32 -0700 (PDT) Received: from localhost.localdomain ([105.137.125.182]) by smtp.gmail.com with ESMTPSA id b96sm14507757wrd.94.2017.08.25.08.59.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 08:59:31 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Colin Ian King , Ard Biesheuvel , linux-kernel@vger.kernel.org, Matt Fleming Subject: [PATCH 3/5] efi/reboot: Make function pointer orig_pm_power_off static Date: Fri, 25 Aug 2017 16:50:17 +0100 Message-Id: <20170825155019.6740-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825155019.6740-1-ard.biesheuvel@linaro.org> References: <20170825155019.6740-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The function pointer orig_pm_power_off is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warning: symbol 'orig_pm_power_off' was not declared. Should it be static? Signed-off-by: Colin Ian King Cc: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/reboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/drivers/firmware/efi/reboot.c b/drivers/firmware/efi/reboot.c index 7117e2d0c7f9..22874544d301 100644 --- a/drivers/firmware/efi/reboot.c +++ b/drivers/firmware/efi/reboot.c @@ -5,7 +5,7 @@ #include #include -void (*orig_pm_power_off)(void); +static void (*orig_pm_power_off)(void); int efi_reboot_quirk_mode = -1; From patchwork Fri Aug 25 15:50:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 111035 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1219977qge; Fri, 25 Aug 2017 09:00:12 -0700 (PDT) X-Received: by 10.84.224.1 with SMTP id r1mr11299859plj.442.1503676812005; Fri, 25 Aug 2017 09:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503676811; cv=none; d=google.com; s=arc-20160816; b=W5cDEMK/qk/qULpssZASbhvXc4P5uQNkHUqqrv56hkvi7xvFiOTqu2/YJmbJjtvEUE ts4Jy2k0CNJ+tbVmkTbY5xRz8BHXCLAKPG6CEKEJJdul9pikgpZ108BFzt/Y1PmpTHyo 2AGp0w+3zxVgAUACVNph5D25wXeSVIeCref4eaj3I5MJ9xzx3XSm2ozk21Af42oeiDiM UmWax+29yzrbn1oev0Q1Xha7z9rYfu0B+emPRhNtlVDhdA1jK5cQQ+Q32mIbE+rMhPpv MI6PdWMvY0ucJu2nJmhYMVgiQt3OqUdxjVoTHVErCLwUe8xbclKpl/CzMC38pSmxSSxn CqKA== 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=vhhZZtzHQMxi1W07q23V2Ku+JUyIp9/zQHaoeVPYWVE=; b=wARPegnfWw9GD6pWeIeL98hEp0bwn383KFu68CKcYaTKPvCGnczyv639ZPSbwNC2Lq +AguPgZbqgPTrOaY5OSQA01wGonwChlevsKgLDI5NK+jcrMqCKftT0aFm8i6JxgdyKPa NlF4xWHhyrKeFJ2A6Y7CuIh0svUjeWnW2oq6U4wp27MJ1XGFZNjRNnJcopeeZujVg+3e ToU9uAPBzJkM6AeD6IYW8z04Zu6sgLLQbmWdWUrsY8XtQ3/zusDKsT5iH5dpvAH8dfV8 iYq4NfEtd/+Alc3X8XQr88ueqVE1nx2Kqs40AIsf+DDBHS3FgVww/NQAF96k8dHKOHB7 IwiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WXG1Ydui; 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 33si5361626ply.828.2017.08.25.09.00.11; Fri, 25 Aug 2017 09:00:11 -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 header.s=google header.b=WXG1Ydui; 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 S934152AbdHYQAJ (ORCPT + 26 others); Fri, 25 Aug 2017 12:00:09 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:36675 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934089AbdHYP7g (ORCPT ); Fri, 25 Aug 2017 11:59:36 -0400 Received: by mail-wr0-f169.google.com with SMTP id p14so648106wrg.3 for ; Fri, 25 Aug 2017 08:59:36 -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=vhhZZtzHQMxi1W07q23V2Ku+JUyIp9/zQHaoeVPYWVE=; b=WXG1YduipZbX1hPmtF24+ZGSLHVusBtrMgqhd22bIJElr+2ukjLxCUD58JlvZtxa9I b0lQxknykAnuahk9WEjCYgdMkqHMqKQbMXc+kdbQYVMh+Xv2UNg9qWbBSQ/yQ+STdUQ3 DWjamFNHCvyWKy4UbQwy9vkzMskZQW78ABGN8= 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=vhhZZtzHQMxi1W07q23V2Ku+JUyIp9/zQHaoeVPYWVE=; b=OFjRPLhETzTEJK6kPBceL/ExywhoxmuUYWphy1juP+Zu+D3rAPiZaErGI3V7I13jOx yZ0JS1UwEUeAItmxWsKc8+v9t+H+ERrng9u4ZnVfgzviWklqAnDvmDhLNhNjpQLHr+zP rLTrIhtZr6VX2JBDDZx7dpoFkfXKBkZs45LwMJvzUCDsC1Y+n7q+MUdBq9zap9cEE1Bp 7Ibj7CE5x0c3eXAdXCK/CZ4zL3Rzhv4YowV8HBJbycgTJ8pk6i0Ja3drWvThp0RYChy1 eSoApt7K66H977gDNZqn8i8AiBvxnMjxkqEahmGWLeAK6q3MhwJKu2YNqbEdaNht2CEX hu5Q== X-Gm-Message-State: AHYfb5jFZVdB48/NMqP3R7KntFvSZwG3PZy32ibG5WMWTp3bMhazsSl8 jP1x6Eqwoxy9obeo X-Received: by 10.223.186.132 with SMTP id p4mr6178604wrg.181.1503676775378; Fri, 25 Aug 2017 08:59:35 -0700 (PDT) Received: from localhost.localdomain ([105.137.125.182]) by smtp.gmail.com with ESMTPSA id b96sm14507757wrd.94.2017.08.25.08.59.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 08:59:34 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Jan Beulich , Ard Biesheuvel , linux-kernel@vger.kernel.org, Jan Beulich , Matt Fleming Subject: [PATCH 4/5] efi: move efi_mem_type() to common code Date: Fri, 25 Aug 2017 16:50:18 +0100 Message-Id: <20170825155019.6740-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825155019.6740-1-ard.biesheuvel@linaro.org> References: <20170825155019.6740-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Beulich This follows efi_mem_attributes(), as it's similarly generic. Drop __weak from that one though (and don't introduce it for efi_mem_type() in the first place) to make clear that other overrides to these functions are really not intended. Signed-off-by: Jan Beulich Cc: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/x86/platform/efi/efi.c | 19 ------------------- drivers/firmware/efi/efi.c | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 25 deletions(-) -- 2.11.0 diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index f084d8718ac4..928b6dceeca0 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -1032,25 +1032,6 @@ void __init efi_enter_virtual_mode(void) efi_dump_pagetable(); } -/* - * Convenience functions to obtain memory types and attributes - */ -u32 efi_mem_type(unsigned long phys_addr) -{ - efi_memory_desc_t *md; - - if (!efi_enabled(EFI_MEMMAP)) - return 0; - - for_each_efi_memory_desc(md) { - if ((md->phys_addr <= phys_addr) && - (phys_addr < (md->phys_addr + - (md->num_pages << EFI_PAGE_SHIFT)))) - return md->type; - } - return 0; -} - static int __init arch_parse_efi_cmdline(char *str) { if (!str) { diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 9e822906adcb..f97f272e16ee 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -792,19 +792,19 @@ char * __init efi_md_typeattr_format(char *buf, size_t size, } /* + * IA64 has a funky EFI memory map that doesn't work the same way as + * other architectures. + */ +#ifndef CONFIG_IA64 +/* * efi_mem_attributes - lookup memmap attributes for physical address * @phys_addr: the physical address to lookup * * Search in the EFI memory map for the region covering * @phys_addr. Returns the EFI memory attributes if the region * was found in the memory map, 0 otherwise. - * - * Despite being marked __weak, most architectures should *not* - * override this function. It is __weak solely for the benefit - * of ia64 which has a funky EFI memory map that doesn't work - * the same way as other architectures. */ -u64 __weak efi_mem_attributes(unsigned long phys_addr) +u64 efi_mem_attributes(unsigned long phys_addr) { efi_memory_desc_t *md; @@ -820,6 +820,31 @@ u64 __weak efi_mem_attributes(unsigned long phys_addr) return 0; } +/* + * efi_mem_type - lookup memmap type for physical address + * @phys_addr: the physical address to lookup + * + * Search in the EFI memory map for the region covering @phys_addr. + * Returns the EFI memory type if the region was found in the memory + * map, EFI_RESERVED_TYPE (zero) otherwise. + */ +u32 efi_mem_type(unsigned long phys_addr) +{ + const efi_memory_desc_t *md; + + if (!efi_enabled(EFI_MEMMAP)) + return 0; + + for_each_efi_memory_desc(md) { + if ((md->phys_addr <= phys_addr) && + (phys_addr < (md->phys_addr + + (md->num_pages << EFI_PAGE_SHIFT)))) + return md->type; + } + return EFI_RESERVED_TYPE; +} +#endif + int efi_status_to_err(efi_status_t status) { int err; From patchwork Fri Aug 25 15:50:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 111034 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1219490qge; Fri, 25 Aug 2017 08:59:51 -0700 (PDT) X-Received: by 10.84.133.111 with SMTP id 102mr11062551plf.277.1503676791859; Fri, 25 Aug 2017 08:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503676791; cv=none; d=google.com; s=arc-20160816; b=wqu4WvIUgQc32fPxakl20ui+/nste/LY/zbtX0zUOrUneZ5qvAK0NypTX7fWhPGQbz rAXJw7sCG5OPd46IYkTt0Hy58RsqSs7lrpI0emVtjUpzZTvn+9acACfU0UcAtYs1F1lf CjXRLcfYl69Uge4d8W9yN84AfJ/8+VUfmwAH/dl88lo8puyO35RblYfZsNJW3IjnYE9S SDRutdfDtAxBMICZQj+jXZJlO1o0t2ULecAMi/XuHnd3CNbVExS3bpLGO+7dlGPMSVq0 OvjEJy5CM3U93YSnTMJUFk+akJThz1/xpBVK1DqhXaty0ZNf2oV8BHhv4ktwo4IVbwN2 LHNg== 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=UXlGPp/xPY9UYIw6wrwcGqC8u4mZqngYVHii4Fb09Kc=; b=wf2hUaJAJdb5gbYJ6Kwyeg+735KaAEYPgl4t0/lEA6e9yZ3i1f+iIHz9YZxVGO3wO+ V/Z+RPCTp1BvQCFZkE1txbtPgv8Kk5GDMPH6stPczti9UdRiOXfuxcUCj0b2QhrJ+Miv tGeUrX0AiNxW+mvnIe6+9XEXlGhfjWCsPaHa8H94mAlCPuuZO7uShnUXqNXddPMR0Qb2 VAZdpVcjMdbWKVNl7K2eKaSut/D/cjz1t7nKknmzXiib3JtpUUJj/9FCNM5lii9bKLPH tv6LHuLpSUdENEwV0pzpRuuWH+WRgC+Q2ZeOOHowO4kR0nYxI03LzN6crBn7xswu6IZf gYTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e46Tdt0r; 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 m19si4929261pgk.551.2017.08.25.08.59.51; Fri, 25 Aug 2017 08:59:51 -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 header.s=google header.b=e46Tdt0r; 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 S934142AbdHYP7t (ORCPT + 26 others); Fri, 25 Aug 2017 11:59:49 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38323 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934116AbdHYP7j (ORCPT ); Fri, 25 Aug 2017 11:59:39 -0400 Received: by mail-wm0-f51.google.com with SMTP id z132so1694926wmg.1 for ; Fri, 25 Aug 2017 08:59:38 -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=UXlGPp/xPY9UYIw6wrwcGqC8u4mZqngYVHii4Fb09Kc=; b=e46Tdt0raGyRfCyIJkCIfpXi1Fu6leRBtPu6k3BTojS2jxEluQh7l+UU2ZaerYFMGV zuIlP4pcBcnVG7Y6UwIcir2XIA4FH2kTxBEVWAEpQteJDnsbWWW/eOhGNbZFdloWm9Mt SiH9qaJB1Mn+5GRAtycML/ryYAWhWpneQbWGA= 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=UXlGPp/xPY9UYIw6wrwcGqC8u4mZqngYVHii4Fb09Kc=; b=Mo7GLlmV4ugRCYsdedCN7cs854mcCG8BOhKuceBqPxRCYu02+0m/JqC9SBnina8RJb lZx4/ps9+1G8awPYxTVkwUZT8L+KBkTnC5U5cKZilUUx9k6U4nYTxctnMb2G6R8TLoMR Mom668AojwcB73P39HzWh9+6v16YX/ybyrc93fTI909xWXkt4M/Bx45MX9/l5+9y6OiQ 327mnVPllp0IYvaBMkdiCcDhJL2aLriYgwDo0SBdBaRNz/AYfCxDxYwRaG6eYmh7cr56 yt2lctiNk4w2VGpVNAjwQiZC8Y/SrVijOldJ+6B9iQRrzmg09ziA0PFnt1YaMgftYker omng== X-Gm-Message-State: AHYfb5iHWyT4BtRA8L7IeENs7ob+5nwvHrytvkC22IH5N/nJ0rjupM7U I/0nCosihJktUbrJ X-Received: by 10.28.155.194 with SMTP id d185mr1473174wme.157.1503676778193; Fri, 25 Aug 2017 08:59:38 -0700 (PDT) Received: from localhost.localdomain ([105.137.125.182]) by smtp.gmail.com with ESMTPSA id b96sm14507757wrd.94.2017.08.25.08.59.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 08:59:37 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Jan Beulich , Ard Biesheuvel , linux-kernel@vger.kernel.org, Jan Beulich , Matt Fleming Subject: [PATCH 5/5] efi: bgrt: use efi_mem_type() Date: Fri, 25 Aug 2017 16:50:19 +0100 Message-Id: <20170825155019.6740-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825155019.6740-1-ard.biesheuvel@linaro.org> References: <20170825155019.6740-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Beulich Avoid effectively open-coding the function. Signed-off-by: Jan Beulich Cc: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi-bgrt.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) -- 2.11.0 diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c index b58233e4ed71..50793fda7819 100644 --- a/drivers/firmware/efi/efi-bgrt.c +++ b/drivers/firmware/efi/efi-bgrt.c @@ -27,26 +27,6 @@ struct bmp_header { u32 size; } __packed; -static bool efi_bgrt_addr_valid(u64 addr) -{ - efi_memory_desc_t *md; - - for_each_efi_memory_desc(md) { - u64 size; - u64 end; - - if (md->type != EFI_BOOT_SERVICES_DATA) - continue; - - size = md->num_pages << EFI_PAGE_SHIFT; - end = md->phys_addr + size; - if (addr >= md->phys_addr && addr < end) - return true; - } - - return false; -} - void __init efi_bgrt_init(struct acpi_table_header *table) { void *image; @@ -85,7 +65,7 @@ void __init efi_bgrt_init(struct acpi_table_header *table) goto out; } - if (!efi_bgrt_addr_valid(bgrt->image_address)) { + if (efi_mem_type(bgrt->image_address) != EFI_BOOT_SERVICES_DATA) { pr_notice("Ignoring BGRT: invalid image address\n"); goto out; }