Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278971

[PATCH v4 3/6] x86/efi: Map RAM into the identity page table for mixed mode

From Matt Fleming <matt@codeblueprint.co.uk>
Newsgroups linux.kernel
Subject [PATCH v4 3/6] x86/efi: Map RAM into the identity page table for mixed mode
Date 2015-11-27 22:10 +0100
Message-ID <qzyrf-82O-7@gated-at.bofh.it> (permalink)
References <qzyrf-82O-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


We are relying on the pre-existing mappings in 'trampoline_pgd' when
accessing function arguments in the EFI mixed mode thunking code.

Instead let's map memory explicitly so that things will continue to
work when we move to a separate page table in the future.

Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/x86/platform/efi/efi_64.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 5aa186db59e3..102976dda8c4 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -144,6 +144,7 @@ void efi_sync_low_kernel_mappings(void)
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
 	unsigned long pfn, text;
+	efi_memory_desc_t *md;
 	struct page *page;
 	unsigned npages;
 	pgd_t *pgd;
@@ -177,6 +178,25 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 	if (!IS_ENABLED(CONFIG_EFI_MIXED))
 		return 0;
 
+	/*
+	 * Map all of RAM so that we can access arguments in the 1:1
+	 * mapping when making EFI runtime calls.
+	 */
+	for_each_efi_memory_desc(&memmap, md) {
+		if (md->type != EFI_CONVENTIONAL_MEMORY &&
+		    md->type != EFI_LOADER_DATA &&
+		    md->type != EFI_LOADER_CODE)
+			continue;
+
+		pfn = md->phys_addr >> PAGE_SHIFT;
+		npages = md->num_pages;
+
+		if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, npages, 0)) {
+			pr_err("Failed to map 1:1 memory\n");
+			return 1;
+		}
+	}
+
 	page = alloc_page(GFP_KERNEL|__GFP_DMA32);
 	if (!page)
 		panic("Unable to allocate EFI runtime stack < 4GB\n");
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL v4 0/6] EFI page table isolation Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-27 22:10 +0100
  [PATCH v4 3/6] x86/efi: Map RAM into the identity page table for mixed mode Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-27 22:10 +0100
    [tip:x86/efi] x86/efi:   Map RAM into the identity page table for mixed mode tip-bot for Matt Fleming <tipbot@zytor.com> - 2015-11-29 10:10 +0100
  [PATCH v4 2/6] x86/mm/pageattr: Ensure cpa->pfn only contains page frame numbers Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-27 22:20 +0100
    [tip:x86/efi] x86/mm/pat: Ensure cpa->  pfn only contains page frame numbers tip-bot for Matt Fleming <tipbot@zytor.com> - 2015-11-29 10:10 +0100
  [PATCH v4 4/6] x86/efi: Hoist page table switching code into efi_call_virt() Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-27 22:20 +0100
    [tip:x86/efi] x86/efi:   Hoist page table switching code into efi_call_virt() tip-bot for Matt Fleming <tipbot@zytor.com> - 2015-11-29 10:10 +0100
  [PATCH v4 6/6] Documentation/x86: Update EFI memory region description Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-27 22:20 +0100
    [tip:x86/efi] Documentation/x86:   Update EFI memory region description tip-bot for Matt Fleming <tipbot@zytor.com> - 2015-11-29 10:10 +0100
  [PATCH v4 1/6] x86: Page align _end to avoid pfn conversion bugs Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-27 22:20 +0100
    [tip:x86/efi] x86/mm: Page align the '_end'   symbol to avoid pfn conversion bugs tip-bot for Matt Fleming <tipbot@zytor.com> - 2015-11-29 10:10 +0100
  [PATCH v4 5/6] x86/efi: Build our own page table structures Matt Fleming <matt@codeblueprint.co.uk> - 2015-11-27 22:20 +0100
    [tip:x86/efi] x86/efi: Build our own page table structures tip-bot for Matt Fleming <tipbot@zytor.com> - 2015-11-29 10:10 +0100
  Re: [GIT PULL v4 0/6] EFI page table isolation Ingo Molnar <mingo@kernel.org> - 2015-11-29 09:20 +0100

csiph-web