All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Ben Hutchings <ben.hutchings@codethink.co.uk>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	Borislav Petkov <bp@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Andy Lutomirski <luto@kernel.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
	Dave Jones <davej@codemonkey.org.uk>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 4.4 101/105] Revert "x86/efi: Build our own page table structures"
Date: Fri, 15 Dec 2017 10:45:39 +0100	[thread overview]
Message-ID: <20171215092311.242857463@linuxfoundation.org> (raw)
In-Reply-To: <20171215092305.994559179@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

This reverts commit 36e0f05afd4e1d09fd47936761a502aedbc50649 which is
commit 67a9108ed4313b85a9c53406d80dc1ae3f8c3e36 upstream.

Turns there was too many other issues with this patch to make it viable
for the stable tree.

Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Jones <davej@codemonkey.org.uk>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: linux-efi@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Ghannam, Yazen" <Yazen.Ghannam@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/include/asm/efi.h     |    1 
 arch/x86/platform/efi/efi.c    |   39 ++++++++++------
 arch/x86/platform/efi/efi_32.c |    5 --
 arch/x86/platform/efi/efi_64.c |   97 ++++++-----------------------------------
 4 files changed, 40 insertions(+), 102 deletions(-)

--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -136,7 +136,6 @@ extern void __init efi_memory_uc(u64 add
 extern void __init efi_map_region(efi_memory_desc_t *md);
 extern void __init efi_map_region_fixed(efi_memory_desc_t *md);
 extern void efi_sync_low_kernel_mappings(void);
-extern int __init efi_alloc_page_tables(void);
 extern int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages);
 extern void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages);
 extern void __init old_map_region(efi_memory_desc_t *md);
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -869,7 +869,7 @@ static void __init kexec_enter_virtual_m
  * This function will switch the EFI runtime services to virtual mode.
  * Essentially, we look through the EFI memmap and map every region that
  * has the runtime attribute bit set in its memory descriptor into the
- * efi_pgd page table.
+ * ->trampoline_pgd page table using a top-down VA allocation scheme.
  *
  * The old method which used to update that memory descriptor with the
  * virtual address obtained from ioremap() is still supported when the
@@ -879,8 +879,8 @@ static void __init kexec_enter_virtual_m
  *
  * The new method does a pagetable switch in a preemption-safe manner
  * so that we're in a different address space when calling a runtime
- * function. For function arguments passing we do copy the PUDs of the
- * kernel page table into efi_pgd prior to each call.
+ * function. For function arguments passing we do copy the PGDs of the
+ * kernel page table into ->trampoline_pgd prior to each call.
  *
  * Specially for kexec boot, efi runtime maps in previous kernel should
  * be passed in via setup_data. In that case runtime ranges will be mapped
@@ -895,12 +895,6 @@ static void __init __efi_enter_virtual_m
 
 	efi.systab = NULL;
 
-	if (efi_alloc_page_tables()) {
-		pr_err("Failed to allocate EFI page tables\n");
-		clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
-		return;
-	}
-
 	efi_merge_regions();
 	new_memmap = efi_map_regions(&count, &pg_shift);
 	if (!new_memmap) {
@@ -960,11 +954,28 @@ static void __init __efi_enter_virtual_m
 	efi_runtime_mkexec();
 
 	/*
-	 * We mapped the descriptor array into the EFI pagetable above
-	 * but we're not unmapping it here because if we're running in
-	 * EFI mixed mode we need all of memory to be accessible when
-	 * we pass parameters to the EFI runtime services in the
-	 * thunking code.
+	 * We mapped the descriptor array into the EFI pagetable above but we're
+	 * not unmapping it here. Here's why:
+	 *
+	 * We're copying select PGDs from the kernel page table to the EFI page
+	 * table and when we do so and make changes to those PGDs like unmapping
+	 * stuff from them, those changes appear in the kernel page table and we
+	 * go boom.
+	 *
+	 * From setup_real_mode():
+	 *
+	 * ...
+	 * trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
+	 *
+	 * In this particular case, our allocation is in PGD 0 of the EFI page
+	 * table but we've copied that PGD from PGD[272] of the EFI page table:
+	 *
+	 *	pgd_index(__PAGE_OFFSET = 0xffff880000000000) = 272
+	 *
+	 * where the direct memory mapping in kernel space is.
+	 *
+	 * new_memmap's VA comes from that direct mapping and thus clearing it,
+	 * it would get cleared in the kernel page table too.
 	 *
 	 * efi_cleanup_page_tables(__pa(new_memmap), 1 << pg_shift);
 	 */
--- a/arch/x86/platform/efi/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
@@ -38,11 +38,6 @@
  * say 0 - 3G.
  */
 
-int __init efi_alloc_page_tables(void)
-{
-	return 0;
-}
-
 void efi_sync_low_kernel_mappings(void) {}
 void __init efi_dump_pagetable(void) {}
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -40,7 +40,6 @@
 #include <asm/fixmap.h>
 #include <asm/realmode.h>
 #include <asm/time.h>
-#include <asm/pgalloc.h>
 
 /*
  * We allocate runtime services regions bottom-up, starting from -4G, i.e.
@@ -122,92 +121,22 @@ void __init efi_call_phys_epilog(pgd_t *
 	early_code_mapping_set_exec(0);
 }
 
-static pgd_t *efi_pgd;
-
-/*
- * We need our own copy of the higher levels of the page tables
- * because we want to avoid inserting EFI region mappings (EFI_VA_END
- * to EFI_VA_START) into the standard kernel page tables. Everything
- * else can be shared, see efi_sync_low_kernel_mappings().
- */
-int __init efi_alloc_page_tables(void)
-{
-	pgd_t *pgd;
-	pud_t *pud;
-	gfp_t gfp_mask;
-
-	if (efi_enabled(EFI_OLD_MEMMAP))
-		return 0;
-
-	gfp_mask = GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO;
-	efi_pgd = (pgd_t *)__get_free_page(gfp_mask);
-	if (!efi_pgd)
-		return -ENOMEM;
-
-	pgd = efi_pgd + pgd_index(EFI_VA_END);
-
-	pud = pud_alloc_one(NULL, 0);
-	if (!pud) {
-		free_page((unsigned long)efi_pgd);
-		return -ENOMEM;
-	}
-
-	pgd_populate(NULL, pgd, pud);
-
-	return 0;
-}
-
 /*
  * Add low kernel mappings for passing arguments to EFI functions.
  */
 void efi_sync_low_kernel_mappings(void)
 {
-	unsigned num_entries;
-	pgd_t *pgd_k, *pgd_efi;
-	pud_t *pud_k, *pud_efi;
+	unsigned num_pgds;
+	pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
 
 	if (efi_enabled(EFI_OLD_MEMMAP))
 		return;
 
-	/*
-	 * We can share all PGD entries apart from the one entry that
-	 * covers the EFI runtime mapping space.
-	 *
-	 * Make sure the EFI runtime region mappings are guaranteed to
-	 * only span a single PGD entry and that the entry also maps
-	 * other important kernel regions.
-	 */
-	BUILD_BUG_ON(pgd_index(EFI_VA_END) != pgd_index(MODULES_END));
-	BUILD_BUG_ON((EFI_VA_START & PGDIR_MASK) !=
-			(EFI_VA_END & PGDIR_MASK));
-
-	pgd_efi = efi_pgd + pgd_index(PAGE_OFFSET);
-	pgd_k = pgd_offset_k(PAGE_OFFSET);
-
-	num_entries = pgd_index(EFI_VA_END) - pgd_index(PAGE_OFFSET);
-	memcpy(pgd_efi, pgd_k, sizeof(pgd_t) * num_entries);
-
-	/*
-	 * We share all the PUD entries apart from those that map the
-	 * EFI regions. Copy around them.
-	 */
-	BUILD_BUG_ON((EFI_VA_START & ~PUD_MASK) != 0);
-	BUILD_BUG_ON((EFI_VA_END & ~PUD_MASK) != 0);
-
-	pgd_efi = efi_pgd + pgd_index(EFI_VA_END);
-	pud_efi = pud_offset(pgd_efi, 0);
-
-	pgd_k = pgd_offset_k(EFI_VA_END);
-	pud_k = pud_offset(pgd_k, 0);
-
-	num_entries = pud_index(EFI_VA_END);
-	memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
+	num_pgds = pgd_index(MODULES_END - 1) - pgd_index(PAGE_OFFSET);
 
-	pud_efi = pud_offset(pgd_efi, EFI_VA_START);
-	pud_k = pud_offset(pgd_k, EFI_VA_START);
-
-	num_entries = PTRS_PER_PUD - pud_index(EFI_VA_START);
-	memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
+	memcpy(pgd + pgd_index(PAGE_OFFSET),
+		init_mm.pgd + pgd_index(PAGE_OFFSET),
+		sizeof(pgd_t) * num_pgds);
 }
 
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
@@ -220,8 +149,8 @@ int __init efi_setup_page_tables(unsigne
 	if (efi_enabled(EFI_OLD_MEMMAP))
 		return 0;
 
-	efi_scratch.efi_pgt = (pgd_t *)__pa(efi_pgd);
-	pgd = efi_pgd;
+	efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd;
+	pgd = __va(efi_scratch.efi_pgt);
 
 	/*
 	 * It can happen that the physical address of new_memmap lands in memory
@@ -267,14 +196,16 @@ int __init efi_setup_page_tables(unsigne
 
 void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
-	kernel_unmap_pages_in_pgd(efi_pgd, pa_memmap, num_pages);
+	pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
+
+	kernel_unmap_pages_in_pgd(pgd, pa_memmap, num_pages);
 }
 
 static void __init __map_region(efi_memory_desc_t *md, u64 va)
 {
+	pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
 	unsigned long flags = 0;
 	unsigned long pfn;
-	pgd_t *pgd = efi_pgd;
 
 	if (!(md->attribute & EFI_MEMORY_WB))
 		flags |= _PAGE_PCD;
@@ -383,7 +314,9 @@ void __init efi_runtime_mkexec(void)
 void __init efi_dump_pagetable(void)
 {
 #ifdef CONFIG_EFI_PGT_DUMP
-	ptdump_walk_pgd_level(NULL, efi_pgd);
+	pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
+
+	ptdump_walk_pgd_level(NULL, pgd);
 #endif
 }
 

WARNING: multiple messages have this Message-ID (diff)
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Ben Hutchings <ben.hutchings@codethink.co.uk>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	Borislav Petkov <bp@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Andy Lutomirski <luto@kernel.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
	Dave Jones <davej@codemonkey.org.uk>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Thomas Gleixner <tglx@linutronix.de>,
	Toshi Kani <toshi.kani@hp.com>,
	linux-efi@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	"Ghannam, Yazen" <Yazen.Ghannam@amd.com>
Subject: [PATCH 4.4 101/105] Revert "x86/efi: Build our own page table structures"
Date: Fri, 15 Dec 2017 10:45:39 +0100	[thread overview]
Message-ID: <20171215092311.242857463@linuxfoundation.org> (raw)
In-Reply-To: <20171215092305.994559179@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

This reverts commit 36e0f05afd4e1d09fd47936761a502aedbc50649 which is
commit 67a9108ed4313b85a9c53406d80dc1ae3f8c3e36 upstream.

Turns there was too many other issues with this patch to make it viable
for the stable tree.

Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Jones <davej@codemonkey.org.uk>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: linux-efi@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "Ghannam, Yazen" <Yazen.Ghannam@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/include/asm/efi.h     |    1 
 arch/x86/platform/efi/efi.c    |   39 ++++++++++------
 arch/x86/platform/efi/efi_32.c |    5 --
 arch/x86/platform/efi/efi_64.c |   97 ++++++-----------------------------------
 4 files changed, 40 insertions(+), 102 deletions(-)

--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -136,7 +136,6 @@ extern void __init efi_memory_uc(u64 add
 extern void __init efi_map_region(efi_memory_desc_t *md);
 extern void __init efi_map_region_fixed(efi_memory_desc_t *md);
 extern void efi_sync_low_kernel_mappings(void);
-extern int __init efi_alloc_page_tables(void);
 extern int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages);
 extern void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages);
 extern void __init old_map_region(efi_memory_desc_t *md);
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -869,7 +869,7 @@ static void __init kexec_enter_virtual_m
  * This function will switch the EFI runtime services to virtual mode.
  * Essentially, we look through the EFI memmap and map every region that
  * has the runtime attribute bit set in its memory descriptor into the
- * efi_pgd page table.
+ * ->trampoline_pgd page table using a top-down VA allocation scheme.
  *
  * The old method which used to update that memory descriptor with the
  * virtual address obtained from ioremap() is still supported when the
@@ -879,8 +879,8 @@ static void __init kexec_enter_virtual_m
  *
  * The new method does a pagetable switch in a preemption-safe manner
  * so that we're in a different address space when calling a runtime
- * function. For function arguments passing we do copy the PUDs of the
- * kernel page table into efi_pgd prior to each call.
+ * function. For function arguments passing we do copy the PGDs of the
+ * kernel page table into ->trampoline_pgd prior to each call.
  *
  * Specially for kexec boot, efi runtime maps in previous kernel should
  * be passed in via setup_data. In that case runtime ranges will be mapped
@@ -895,12 +895,6 @@ static void __init __efi_enter_virtual_m
 
 	efi.systab = NULL;
 
-	if (efi_alloc_page_tables()) {
-		pr_err("Failed to allocate EFI page tables\n");
-		clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
-		return;
-	}
-
 	efi_merge_regions();
 	new_memmap = efi_map_regions(&count, &pg_shift);
 	if (!new_memmap) {
@@ -960,11 +954,28 @@ static void __init __efi_enter_virtual_m
 	efi_runtime_mkexec();
 
 	/*
-	 * We mapped the descriptor array into the EFI pagetable above
-	 * but we're not unmapping it here because if we're running in
-	 * EFI mixed mode we need all of memory to be accessible when
-	 * we pass parameters to the EFI runtime services in the
-	 * thunking code.
+	 * We mapped the descriptor array into the EFI pagetable above but we're
+	 * not unmapping it here. Here's why:
+	 *
+	 * We're copying select PGDs from the kernel page table to the EFI page
+	 * table and when we do so and make changes to those PGDs like unmapping
+	 * stuff from them, those changes appear in the kernel page table and we
+	 * go boom.
+	 *
+	 * From setup_real_mode():
+	 *
+	 * ...
+	 * trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
+	 *
+	 * In this particular case, our allocation is in PGD 0 of the EFI page
+	 * table but we've copied that PGD from PGD[272] of the EFI page table:
+	 *
+	 *	pgd_index(__PAGE_OFFSET = 0xffff880000000000) = 272
+	 *
+	 * where the direct memory mapping in kernel space is.
+	 *
+	 * new_memmap's VA comes from that direct mapping and thus clearing it,
+	 * it would get cleared in the kernel page table too.
 	 *
 	 * efi_cleanup_page_tables(__pa(new_memmap), 1 << pg_shift);
 	 */
--- a/arch/x86/platform/efi/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
@@ -38,11 +38,6 @@
  * say 0 - 3G.
  */
 
-int __init efi_alloc_page_tables(void)
-{
-	return 0;
-}
-
 void efi_sync_low_kernel_mappings(void) {}
 void __init efi_dump_pagetable(void) {}
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -40,7 +40,6 @@
 #include <asm/fixmap.h>
 #include <asm/realmode.h>
 #include <asm/time.h>
-#include <asm/pgalloc.h>
 
 /*
  * We allocate runtime services regions bottom-up, starting from -4G, i.e.
@@ -122,92 +121,22 @@ void __init efi_call_phys_epilog(pgd_t *
 	early_code_mapping_set_exec(0);
 }
 
-static pgd_t *efi_pgd;
-
-/*
- * We need our own copy of the higher levels of the page tables
- * because we want to avoid inserting EFI region mappings (EFI_VA_END
- * to EFI_VA_START) into the standard kernel page tables. Everything
- * else can be shared, see efi_sync_low_kernel_mappings().
- */
-int __init efi_alloc_page_tables(void)
-{
-	pgd_t *pgd;
-	pud_t *pud;
-	gfp_t gfp_mask;
-
-	if (efi_enabled(EFI_OLD_MEMMAP))
-		return 0;
-
-	gfp_mask = GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO;
-	efi_pgd = (pgd_t *)__get_free_page(gfp_mask);
-	if (!efi_pgd)
-		return -ENOMEM;
-
-	pgd = efi_pgd + pgd_index(EFI_VA_END);
-
-	pud = pud_alloc_one(NULL, 0);
-	if (!pud) {
-		free_page((unsigned long)efi_pgd);
-		return -ENOMEM;
-	}
-
-	pgd_populate(NULL, pgd, pud);
-
-	return 0;
-}
-
 /*
  * Add low kernel mappings for passing arguments to EFI functions.
  */
 void efi_sync_low_kernel_mappings(void)
 {
-	unsigned num_entries;
-	pgd_t *pgd_k, *pgd_efi;
-	pud_t *pud_k, *pud_efi;
+	unsigned num_pgds;
+	pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
 
 	if (efi_enabled(EFI_OLD_MEMMAP))
 		return;
 
-	/*
-	 * We can share all PGD entries apart from the one entry that
-	 * covers the EFI runtime mapping space.
-	 *
-	 * Make sure the EFI runtime region mappings are guaranteed to
-	 * only span a single PGD entry and that the entry also maps
-	 * other important kernel regions.
-	 */
-	BUILD_BUG_ON(pgd_index(EFI_VA_END) != pgd_index(MODULES_END));
-	BUILD_BUG_ON((EFI_VA_START & PGDIR_MASK) !=
-			(EFI_VA_END & PGDIR_MASK));
-
-	pgd_efi = efi_pgd + pgd_index(PAGE_OFFSET);
-	pgd_k = pgd_offset_k(PAGE_OFFSET);
-
-	num_entries = pgd_index(EFI_VA_END) - pgd_index(PAGE_OFFSET);
-	memcpy(pgd_efi, pgd_k, sizeof(pgd_t) * num_entries);
-
-	/*
-	 * We share all the PUD entries apart from those that map the
-	 * EFI regions. Copy around them.
-	 */
-	BUILD_BUG_ON((EFI_VA_START & ~PUD_MASK) != 0);
-	BUILD_BUG_ON((EFI_VA_END & ~PUD_MASK) != 0);
-
-	pgd_efi = efi_pgd + pgd_index(EFI_VA_END);
-	pud_efi = pud_offset(pgd_efi, 0);
-
-	pgd_k = pgd_offset_k(EFI_VA_END);
-	pud_k = pud_offset(pgd_k, 0);
-
-	num_entries = pud_index(EFI_VA_END);
-	memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
+	num_pgds = pgd_index(MODULES_END - 1) - pgd_index(PAGE_OFFSET);
 
-	pud_efi = pud_offset(pgd_efi, EFI_VA_START);
-	pud_k = pud_offset(pgd_k, EFI_VA_START);
-
-	num_entries = PTRS_PER_PUD - pud_index(EFI_VA_START);
-	memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries);
+	memcpy(pgd + pgd_index(PAGE_OFFSET),
+		init_mm.pgd + pgd_index(PAGE_OFFSET),
+		sizeof(pgd_t) * num_pgds);
 }
 
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
@@ -220,8 +149,8 @@ int __init efi_setup_page_tables(unsigne
 	if (efi_enabled(EFI_OLD_MEMMAP))
 		return 0;
 
-	efi_scratch.efi_pgt = (pgd_t *)__pa(efi_pgd);
-	pgd = efi_pgd;
+	efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd;
+	pgd = __va(efi_scratch.efi_pgt);
 
 	/*
 	 * It can happen that the physical address of new_memmap lands in memory
@@ -267,14 +196,16 @@ int __init efi_setup_page_tables(unsigne
 
 void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
-	kernel_unmap_pages_in_pgd(efi_pgd, pa_memmap, num_pages);
+	pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
+
+	kernel_unmap_pages_in_pgd(pgd, pa_memmap, num_pages);
 }
 
 static void __init __map_region(efi_memory_desc_t *md, u64 va)
 {
+	pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
 	unsigned long flags = 0;
 	unsigned long pfn;
-	pgd_t *pgd = efi_pgd;
 
 	if (!(md->attribute & EFI_MEMORY_WB))
 		flags |= _PAGE_PCD;
@@ -383,7 +314,9 @@ void __init efi_runtime_mkexec(void)
 void __init efi_dump_pagetable(void)
 {
 #ifdef CONFIG_EFI_PGT_DUMP
-	ptdump_walk_pgd_level(NULL, efi_pgd);
+	pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
+
+	ptdump_walk_pgd_level(NULL, pgd);
 #endif
 }
 

  parent reply	other threads:[~2017-12-15  9:45 UTC|newest]

Thread overview: 129+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-15  9:43 [PATCH 4.4 000/105] 4.4.106-stable review Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 002/105] can: kvaser_usb: free buf in error paths Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 003/105] can: kvaser_usb: Fix comparison bug in kvaser_usb_read_bulk_callback() Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 004/105] can: kvaser_usb: ratelimit errors if incomplete messages are received Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 005/105] can: kvaser_usb: cancel urb on -EPIPE and -EPROTO Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 006/105] can: ems_usb: " Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 007/105] can: esd_usb2: " Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 008/105] can: usb_8dev: " Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 009/105] virtio: release virtio index when fail to device_register Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 010/105] hv: kvp: Avoid reading past allocated blocks from KVP file Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 011/105] isa: Prevent NULL dereference in isa_bus driver callbacks Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 012/105] scsi: libsas: align sata_devices rps_resp on a cacheline Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 013/105] efi: Move some sysfs files to be read-only by root Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 014/105] ASN.1: fix out-of-bounds read when parsing indefinite length item Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 015/105] ASN.1: check for error from ASN1_OP_END__ACT actions Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 016/105] X.509: reject invalid BIT STRING for subjectPublicKey Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 017/105] x86/PCI: Make broadcom_postcore_init() check acpi_disabled Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 018/105] ALSA: pcm: prevent UAF in snd_pcm_info Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 019/105] ALSA: seq: Remove spurious WARN_ON() at timer check Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 020/105] ALSA: usb-audio: Fix out-of-bound error Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 021/105] ALSA: usb-audio: Add check return value for usb_string() Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 022/105] iommu/vt-d: Fix scatterlist offset handling Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 023/105] s390: fix compat system call table Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 024/105] kdb: Fix handling of kallsyms_symbol_next() return value Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 025/105] drm: extra printk() wrapper macros Greg Kroah-Hartman
2017-12-15  9:44   ` Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 026/105] drm/exynos: gem: Drop NONCONTIG flag for buffers allocated without IOMMU Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 027/105] media: dvb: i2c transfers over usb cannot be done from stack Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 028/105] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 030/105] arm64: fpsimd: Prevent registers leaking from dead tasks Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 031/105] ARM: BUG if jumping to usermode address in kernel mode Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 032/105] ARM: avoid faulting on qemu Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 033/105] scsi: storvsc: Workaround for virtual DVD SCSI version Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 034/105] thp: reduce indentation level in change_huge_pmd() Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 035/105] thp: fix MADV_DONTNEED vs. numa balancing race Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 036/105] mm: drop unused pmdp_huge_get_and_clear_notify() Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 037/105] Revert "drm/armada: Fix compile fail" Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 038/105] Revert "spi: SPI_FSL_DSPI should depend on HAS_DMA" Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 039/105] Revert "s390/kbuild: enable modversions for symbols exported from asm" Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 040/105] vti6: Dont report path MTU below IPV6_MIN_MTU Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 041/105] ARM: OMAP2+: gpmc-onenand: propagate error on initialization failure Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 042/105] x86/hpet: Prevent might sleep splat on resume Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 043/105] selftest/powerpc: Fix false failures for skipped tests Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 044/105] module: set __jump_table alignment to 8 Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 045/105] ARM: OMAP2+: Fix device node reference counts Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 046/105] ARM: OMAP2+: Release device node after it is no longer needed Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 047/105] gpio: altera: Use handle_level_irq when configured as a level_high Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 048/105] HID: chicony: Add support for another ASUS Zen AiO keyboard Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 049/105] usb: gadget: configs: plug memory leak Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 050/105] USB: gadgetfs: Fix a potential memory leak in dev_config() Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 052/105] libata: drop WARN from protocol error in ata_sff_qc_issue() Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 053/105] workqueue: trigger WARN if queue_delayed_work() is called with NULL @wq Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 054/105] scsi: lpfc: Fix crash during Hardware error recovery on SLI3 adapters Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 055/105] irqchip/crossbar: Fix incorrect type of register size Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 057/105] arm: KVM: Survive unknown traps from guests Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 058/105] arm64: " Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 059/105] spi_ks8995: fix "BUG: key accdaa28 not in .data!" Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 060/105] bnx2x: prevent crash when accessing PTP with interface down Greg Kroah-Hartman
2017-12-15  9:44 ` [PATCH 4.4 061/105] bnx2x: fix possible overrun of VFPF multicast addresses array Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 062/105] bnx2x: do not rollback VF MAC/VLAN filters we did not configure Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 063/105] ipv6: reorder icmpv6_init() and ip6_mr_init() Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 064/105] crypto: s5p-sss - Fix completing crypto request in IRQ handler Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 065/105] i2c: riic: fix restart condition Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 066/105] zram: set physical queue limits to avoid array out of bounds accesses Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 067/105] netfilter: dont track fragmented packets Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 068/105] axonram: Fix gendisk handling Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 069/105] drm/amd/amdgpu: fix console deadlock if late init failed Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 070/105] powerpc/powernv/ioda2: Gracefully fail if too many TCE levels requested Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 073/105] kbuild: pkg: use --transform option to prefix paths in tar Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 074/105] mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl() Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 075/105] route: also update fnhe_genid when updating a route cache Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 076/105] route: update fnhe_expires for redirect when the fnhe exists Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 077/105] lib/genalloc.c: make the avail variable an atomic_long_t Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 078/105] dynamic-debug-howto: fix optional/omitted ending line number to be LARGE instead of 0 Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 079/105] NFS: Fix a typo in nfs_rename() Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 080/105] sunrpc: Fix rpc_task_begin trace point Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 081/105] block: wake up all tasks blocked in get_request() Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 082/105] sparc64/mm: set fields in deferred pages Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 083/105] sctp: do not free asoc when it is already dead in sctp_sendmsg Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 084/105] sctp: use the right sk after waking up from wait_buf sleep Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 085/105] atm: horizon: Fix irq release error Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 086/105] jump_label: Invoke jump_label_test() via early_initcall() Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 087/105] xfrm: Copy policy family in clone_policy Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 088/105] IB/mlx4: Increase maximal message size under UD QP Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 089/105] IB/mlx5: Assign send CQ and recv CQ of UMR QP Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 090/105] afs: Connect up the CB.ProbeUuid Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 091/105] ipvlan: fix ipv6 outbound device Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 092/105] audit: ensure that audit=1 actually enables audit for PID 1 Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 093/105] ipmi: Stop timers before cleaning up the module Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 094/105] s390: always save and restore all registers on context switch Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 095/105] more bio_map_user_iov() leak fixes Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 096/105] tipc: fix memory leak in tipc_accept_from_sock() Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 098/105] sit: update frag_off info Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 099/105] packet: fix crash in fanout_demux_rollover() Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 100/105] net/packet: fix a race in packet_bind() and packet_notifier() Greg Kroah-Hartman
2017-12-15  9:45 ` Greg Kroah-Hartman [this message]
2017-12-15  9:45   ` [PATCH 4.4 101/105] Revert "x86/efi: Build our own page table structures" Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 102/105] Revert "x86/efi: Hoist page table switching code into efi_call_virt()" Greg Kroah-Hartman
2017-12-15  9:45   ` Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers" Greg Kroah-Hartman
2017-12-15  9:45   ` Greg Kroah-Hartman
2018-08-23  0:48   ` Roland Dreier
2018-08-23  6:12     ` Greg Kroah-Hartman
2018-08-23 16:37       ` Roland Dreier
2018-08-24 14:54         ` Matt Fleming
2018-08-24 16:45     ` Ben Hutchings
2018-08-24 17:08       ` Roland Dreier
2018-08-24 19:17         ` Greg Kroah-Hartman
2018-08-24 20:04           ` Roland Dreier
2018-08-24 20:10             ` Guenter Roeck
2018-08-24 20:16               ` Roland Dreier
2018-08-24 20:32                 ` Guenter Roeck
2018-08-31  6:24                   ` Guillaume Tucker
2018-08-31 16:02                     ` Greg Kroah-Hartman
2018-08-24 21:19             ` Guenter Roeck
2018-08-25 13:52             ` Guenter Roeck
2018-08-25 15:07               ` Greg Kroah-Hartman
2018-08-26  2:30                 ` Guenter Roeck
2018-08-29 19:58                   ` Roland Dreier
2018-08-30 12:10                     ` Greg Kroah-Hartman
2018-08-24 20:06           ` Guenter Roeck
2017-12-15  9:45 ` [PATCH 4.4 104/105] arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one Greg Kroah-Hartman
2017-12-15  9:45 ` [PATCH 4.4 105/105] usb: gadget: ffs: Forbid usb_ep_alloc_request from sleeping Greg Kroah-Hartman
2017-12-15 10:01 ` [PATCH 4.4 000/105] 4.4.106-stable review Nathan Chancellor
2017-12-15 10:01   ` Nathan Chancellor
2017-12-15 13:07   ` Greg Kroah-Hartman
2017-12-15 17:39 ` Guenter Roeck
2017-12-15 21:14 ` Shuah Khan
2017-12-16  5:36 ` Naresh Kamboju

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=20171215092311.242857463@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=ben.hutchings@codethink.co.uk \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=davej@codemonkey.org.uk \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=peterz@infradead.org \
    --cc=sai.praneeth.prakhya@intel.com \
    --cc=sds@tycho.nsa.gov \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.