From patchwork Thu Jan 8 18:48:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 42890 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F1CBB26CD8 for ; Thu, 8 Jan 2015 18:56:44 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id w61sf2184705wes.0 for ; Thu, 08 Jan 2015 10:56:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Wr/hq1StVYDP7H3cijcO8rrK4+VA7Geq8/W5x4n5z14=; b=OkpaFCIRZ/8k+djfFq6C9zn6R2wOmyYg0+KpSk4BjsPkyNqiA0XEVIvkQ4UMnUBv5+ BwH4mHN685sIoC56LqxOEC69cVtB+iv6kT5lDqHWsDc+MR7JhvyCwp4meUmGSTUIRR1C 71zh3vAKI3RcgXRnjJtZkBmhn3EvFDYPauAAtNuIbRcltnMg+XQ2k3Tv7YlcjZJMyH4l CmCV1QGZkKrTus5Rs9eZbHnzWEr5oK6KWI4rs9tXIOEpNKPLwmBbjC1bbwOPcvVTRw6d 6w8j10hrrgEG9TYERor2+aTiQfFZ2dwnDHwBaMcm8Dx6a9QwWYuw0gpiz5RjWpsv+2Pu X71A== X-Gm-Message-State: ALoCoQnMsVDuZsT5NseWLzHLqMdxb4AO1Uhp2khTeVhiskzeotIi+p3+p9jkShXQRDFXxKTSEUQq X-Received: by 10.180.7.226 with SMTP id m2mr1468048wia.5.1420743403841; Thu, 08 Jan 2015 10:56:43 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.7 with SMTP id f7ls351268laa.100.gmail; Thu, 08 Jan 2015 10:56:43 -0800 (PST) X-Received: by 10.112.27.133 with SMTP id t5mr16529000lbg.45.1420743403587; Thu, 08 Jan 2015 10:56:43 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id q2si10083153lbb.130.2015.01.08.10.56.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Jan 2015 10:56:43 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id s18so10842921lam.2 for ; Thu, 08 Jan 2015 10:56:43 -0800 (PST) X-Received: by 10.112.64.35 with SMTP id l3mr16447767lbs.82.1420743403248; Thu, 08 Jan 2015 10:56:43 -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.9.200 with SMTP id c8csp92024lbb; Thu, 8 Jan 2015 10:56:42 -0800 (PST) X-Received: by 10.70.92.3 with SMTP id ci3mr17563808pdb.28.1420743401331; Thu, 08 Jan 2015 10:56:41 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lu17si9906558pab.157.2015.01.08.10.56.37; Thu, 08 Jan 2015 10:56:41 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757242AbbAHS4e (ORCPT + 27 others); Thu, 8 Jan 2015 13:56:34 -0500 Received: from mail-wg0-f45.google.com ([74.125.82.45]:58749 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531AbbAHS4d (ORCPT ); Thu, 8 Jan 2015 13:56:33 -0500 Received: by mail-wg0-f45.google.com with SMTP id b13so4257828wgh.4 for ; Thu, 08 Jan 2015 10:56:32 -0800 (PST) X-Received: by 10.180.210.167 with SMTP id mv7mr23508270wic.78.1420742944643; Thu, 08 Jan 2015 10:49:04 -0800 (PST) Received: from ards-macbook-pro.local ([197.131.128.104]) by mx.google.com with ESMTPSA id gf6sm7204081wjc.11.2015.01.08.10.49.01 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Jan 2015 10:49:03 -0800 (PST) From: Ard Biesheuvel To: leif.lindholm@linaro.org, roy.franz@linaro.org, matt.fleming@intel.com, will.deacon@arm.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, bp@alien8.de, msalter@redhat.com, geoff.levand@linaro.org, dyoung@redhat.com, mark.rutland@arm.com, linux-kernel@vger.kernel.org Cc: Ard Biesheuvel Subject: [PATCH v5 3/8] efi: split off remapping code from efi_config_init() Date: Thu, 8 Jan 2015 18:48:29 +0000 Message-Id: <1420742914-2404-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1420742914-2404-1-git-send-email-ard.biesheuvel@linaro.org> References: <1420742914-2404-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.43 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. Acked-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 56 ++++++++++++++++++++++++++-------------------- include/linux/efi.h | 2 ++ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 9035c1b74d58..b7ba9d8ec4b0 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -293,29 +293,15 @@ 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, int sz, + efi_config_table_type_t *arch_tables) { - void *config_tables, *tablep; - int i, sz; - - 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; - } + void *tablep; + int i; 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 +314,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 +328,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, sz, + 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..5ffe5115951f 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, int sz, + 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);