From patchwork Tue Nov 18 12:57:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 41017 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A0C8D241C9 for ; Tue, 18 Nov 2014 12:59:58 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id k14sf3519626wgh.4 for ; Tue, 18 Nov 2014 04:59:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=VkfP79f47jluqkCOXRQJzruuhEMXDYCE9JCBc8PwDv0=; b=bIRKFqu4dQCbpJ45Zl0gxx7vbVx5DQAQrvZqLvgK5xg6rCDH/AOT6o921jVjhIZg/E oh+7I+ttSUPGaZS/KV+GUOfwLyQk7e9GkdIcz/tDT3XEgPONqQrOwIGYXbI/B3fIzAwo yji0/LI5rkxdGypimTjhFpEGx0xD7jfmyhPneyTlvAmzSB1IViH3Nzgy0cx/XkfJGHkh 2m/9GWU0uxsN4jr3fyfBK7h89bWRSECYdl5NDupAFv1c7rhm5NWNscRFsUdg9VyyMEf7 vjUJaEjn3D3tnkUgtEsbxx7RAil/9Ghmx1XTDuJ0YeVsktCe0BpiCyj1u0O++zZcK8ty sJmA== X-Gm-Message-State: ALoCoQm/dRQni4acW1pCuyFmkY3ORsEDXLY7fbIOqr7cCytHooLDz6ZzvlP0sCy2SRDREeLgLpoU X-Received: by 10.112.146.104 with SMTP id tb8mr9206lbb.22.1416315597796; Tue, 18 Nov 2014 04:59:57 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.228 with SMTP id o4ls1170669lag.66.gmail; Tue, 18 Nov 2014 04:59:57 -0800 (PST) X-Received: by 10.112.199.131 with SMTP id jk3mr23919681lbc.45.1416315597651; Tue, 18 Nov 2014 04:59:57 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id sn3si38813973lbb.77.2014.11.18.04.59.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Nov 2014 04:59:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pv20so1296495lab.37 for ; Tue, 18 Nov 2014 04:59:57 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr35396215laj.67.1416315597563; Tue, 18 Nov 2014 04:59:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp1322881lbc; Tue, 18 Nov 2014 04:59:56 -0800 (PST) X-Received: by 10.66.252.193 with SMTP id zu1mr2153811pac.153.1416315595905; Tue, 18 Nov 2014 04:59:55 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id id2si37824787pbb.224.2014.11.18.04.59.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Nov 2014 04:59:55 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqiMb-0002v3-GU; Tue, 18 Nov 2014 12:58:33 +0000 Received: from mail-wi0-f180.google.com ([209.85.212.180]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XqiLm-0002QJ-2U for linux-arm-kernel@lists.infradead.org; Tue, 18 Nov 2014 12:57:43 +0000 Received: by mail-wi0-f180.google.com with SMTP id n3so5132292wiv.1 for ; Tue, 18 Nov 2014 04:57:20 -0800 (PST) X-Received: by 10.180.85.6 with SMTP id d6mr3761897wiz.82.1416315440312; Tue, 18 Nov 2014 04:57:20 -0800 (PST) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id cz3sm55726799wjb.23.2014.11.18.04.57.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Nov 2014 04:57:19 -0800 (PST) From: Ard Biesheuvel To: leif.lindholm@linaro.org, roy.franz@linaro.org, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, msalter@redhat.com, dyoung@redhat.com, linux-efi@vger.kernel.org, matt.fleming@intel.com, will.deacon@arm.com, catalin.marinas@arm.com, grant.likely@linaro.org, geoff.levand@linaro.org Subject: [PATCH v3 04/13] efi: split off remapping code from efi_config_init() Date: Tue, 18 Nov 2014 13:57:03 +0100 Message-Id: <1416315432-8534-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1416315432-8534-1-git-send-email-ard.biesheuvel@linaro.org> References: <1416315432-8534-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141118_045742_317186_ABACE50D X-CRM114-Status: GOOD ( 16.24 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.180 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.180 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Split of the remapping code from efi_config_init() so that the caller can perform its own remapping. This is necessary to correctly handle virtually remapped UEFI memory regions under kexec, as efi.systab will have been updated to a virtual address. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 49 +++++++++++++++++++++++++++++----------------- include/linux/efi.h | 2 ++ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 9035c1b74d58..0de77db4fb88 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -293,9 +293,10 @@ static __init int match_config_table(efi_guid_t *guid, return 0; } -int __init efi_config_init(efi_config_table_type_t *arch_tables) +int __init efi_config_parse_tables(void *config_tables, int count, + efi_config_table_type_t *arch_tables) { - void *config_tables, *tablep; + void *tablep; int i, sz; if (efi_enabled(EFI_64BIT)) @@ -303,19 +304,9 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables) else sz = sizeof(efi_config_table_32_t); - /* - * Let's see what config tables the firmware passed to us. - */ - config_tables = early_memremap(efi.systab->tables, - efi.systab->nr_tables * sz); - if (config_tables == NULL) { - pr_err("Could not map Configuration table!\n"); - return -ENOMEM; - } - tablep = config_tables; pr_info(""); - for (i = 0; i < efi.systab->nr_tables; i++) { + for (i = 0; i < count; i++) { efi_guid_t guid; unsigned long table; @@ -328,8 +319,6 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables) if (table64 >> 32) { pr_cont("\n"); pr_err("Table located above 4GB, disabling EFI.\n"); - early_memunmap(config_tables, - efi.systab->nr_tables * sz); return -EINVAL; } #endif @@ -344,13 +333,37 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables) tablep += sz; } pr_cont("\n"); - early_memunmap(config_tables, efi.systab->nr_tables * sz); - set_bit(EFI_CONFIG_TABLES, &efi.flags); - return 0; } +int __init efi_config_init(efi_config_table_type_t *arch_tables) +{ + void *config_tables; + int sz, ret; + + if (efi_enabled(EFI_64BIT)) + sz = sizeof(efi_config_table_64_t); + else + sz = sizeof(efi_config_table_32_t); + + /* + * Let's see what config tables the firmware passed to us. + */ + config_tables = early_memremap(efi.systab->tables, + efi.systab->nr_tables * sz); + if (config_tables == NULL) { + pr_err("Could not map Configuration table!\n"); + return -ENOMEM; + } + + ret = efi_config_parse_tables(config_tables, efi.systab->nr_tables, + arch_tables); + + early_memunmap(config_tables, efi.systab->nr_tables * sz); + return ret; +} + #ifdef CONFIG_EFI_VARS_MODULE static int __init efi_load_efivars(void) { diff --git a/include/linux/efi.h b/include/linux/efi.h index 0238d612750e..2dc8577032b3 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -875,6 +875,8 @@ static inline efi_status_t efi_query_variable_store(u32 attributes, unsigned lon #endif extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); extern int efi_config_init(efi_config_table_type_t *arch_tables); +extern int efi_config_parse_tables(void *config_tables, int count, + efi_config_table_type_t *arch_tables); extern u64 efi_get_iobase (void); extern u32 efi_mem_type (unsigned long phys_addr); extern u64 efi_mem_attributes (unsigned long phys_addr);