linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 04/13] efi: split off remapping code from efi_config_init()
Date: Tue, 18 Nov 2014 13:57:03 +0100	[thread overview]
Message-ID: <1416315432-8534-5-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1416315432-8534-1-git-send-email-ard.biesheuvel@linaro.org>

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 <ard.biesheuvel@linaro.org>
---
 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);
-- 
1.8.3.2

  parent reply	other threads:[~2014-11-18 12:57 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18 12:56 [PATCH v3 00/13] arm64: stable UEFI mappings for kexec Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 01/13] arm64/mm: add explicit struct_mm argument to __create_mapping() Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 02/13] arm64/mm: add create_pgd_mapping() to create private page tables Ard Biesheuvel
2014-11-25 14:32   ` Will Deacon
2014-11-18 12:57 ` [PATCH v3 03/13] arm64: improve CONFIG_STRICT_DEVMEM handling Ard Biesheuvel
2014-11-25 17:39   ` Matt Fleming
2014-11-25 17:48     ` Borislav Petkov
2014-11-26  9:30   ` Dave Young
2014-11-26 16:23     ` Ard Biesheuvel
2014-11-27  6:22       ` Dave Young
2014-11-18 12:57 ` Ard Biesheuvel [this message]
2014-11-25 17:24   ` [PATCH v3 04/13] efi: split off remapping code from efi_config_init() Matt Fleming
2014-11-25 17:48     ` Will Deacon
2014-11-18 12:57 ` [PATCH v3 05/13] efi: add common infrastructure for stub-installed virtual mapping Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 06/13] efi: register iomem resources for UEFI reserved regions Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 07/13] arm64/efi: move SetVirtualAddressMap() to UEFI stub Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 08/13] arm64/efi: remove free_boot_services() and friends Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 09/13] arm64/efi: remove idmap manipulations from UEFI code Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 10/13] arm64/efi: use UEFI memory map unconditionally if available Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 11/13] arm64/efi: use plain memblock API for adding and removing reserved RAM Ard Biesheuvel
2014-11-20 17:28   ` Mark Salter
2014-11-20 17:38     ` Ard Biesheuvel
2014-11-20 17:54       ` Mark Salter
2014-11-21 12:07         ` Ard Biesheuvel
2014-11-21 15:21           ` Mark Salter
2014-11-26 16:59             ` Ard Biesheuvel
2014-11-18 12:57 ` [PATCH v3 12/13] efi: efistub: allow allocation alignment larger than EFI_PAGE_SIZE Ard Biesheuvel
2014-11-27 17:30   ` Matt Fleming
2014-11-18 12:57 ` [PATCH v3 13/13] arm64/efi: set EFI_ALLOC_ALIGN to 64 KB Ard Biesheuvel
2014-11-20  1:27 ` [PATCH v3 00/13] arm64: stable UEFI mappings for kexec Geoff Levand
2014-11-20 22:05 ` Geoff Levand
2014-11-22  8:49   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416315432-8534-5-git-send-email-ard.biesheuvel@linaro.org \
    --to=ard.biesheuvel@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).