Commit 3ede3417 authored by Sai Praneeth's avatar Sai Praneeth Committed by Ingo Molnar

x86/efi: Replace efi_pgd with efi_mm.pgd

Since the previous patch added support for efi_mm, let's handle efi_pgd
through efi_mm and remove global variable efi_pgd.
Tested-by: default avatarBhupesh Sharma <bhsharma@redhat.com>
Signed-off-by: default avatarSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: default avatarMatt Fleming <matt@codeblueprint.co.uk>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Lee, Chun-Yi <jlee@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Cc: Ricardo Neri <ricardo.neri@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-efi@vger.kernel.org
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 36b64976
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/efi.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -73,13 +74,12 @@ static const struct file_operations ptdump_curusr_fops = { ...@@ -73,13 +74,12 @@ static const struct file_operations ptdump_curusr_fops = {
#endif #endif
#if defined(CONFIG_EFI) && defined(CONFIG_X86_64) #if defined(CONFIG_EFI) && defined(CONFIG_X86_64)
extern pgd_t *efi_pgd;
static struct dentry *pe_efi; static struct dentry *pe_efi;
static int ptdump_show_efi(struct seq_file *m, void *v) static int ptdump_show_efi(struct seq_file *m, void *v)
{ {
if (efi_pgd) if (efi_mm.pgd)
ptdump_walk_pgd_level_debugfs(m, efi_pgd, false); ptdump_walk_pgd_level_debugfs(m, efi_mm.pgd, false);
return 0; return 0;
} }
......
...@@ -191,8 +191,7 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd) ...@@ -191,8 +191,7 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
early_code_mapping_set_exec(0); early_code_mapping_set_exec(0);
} }
pgd_t *efi_pgd; EXPORT_SYMBOL_GPL(efi_mm);
EXPORT_SYMBOL_GPL(efi_pgd);
/* /*
* We need our own copy of the higher levels of the page tables * We need our own copy of the higher levels of the page tables
...@@ -205,7 +204,7 @@ EXPORT_SYMBOL_GPL(efi_pgd); ...@@ -205,7 +204,7 @@ EXPORT_SYMBOL_GPL(efi_pgd);
*/ */
int __init efi_alloc_page_tables(void) int __init efi_alloc_page_tables(void)
{ {
pgd_t *pgd; pgd_t *pgd, *efi_pgd;
p4d_t *p4d; p4d_t *p4d;
pud_t *pud; pud_t *pud;
gfp_t gfp_mask; gfp_t gfp_mask;
...@@ -233,6 +232,7 @@ int __init efi_alloc_page_tables(void) ...@@ -233,6 +232,7 @@ int __init efi_alloc_page_tables(void)
return -ENOMEM; return -ENOMEM;
} }
efi_mm.pgd = efi_pgd;
mm_init_cpumask(&efi_mm); mm_init_cpumask(&efi_mm);
init_new_context(NULL, &efi_mm); init_new_context(NULL, &efi_mm);
...@@ -248,6 +248,7 @@ void efi_sync_low_kernel_mappings(void) ...@@ -248,6 +248,7 @@ void efi_sync_low_kernel_mappings(void)
pgd_t *pgd_k, *pgd_efi; pgd_t *pgd_k, *pgd_efi;
p4d_t *p4d_k, *p4d_efi; p4d_t *p4d_k, *p4d_efi;
pud_t *pud_k, *pud_efi; pud_t *pud_k, *pud_efi;
pgd_t *efi_pgd = efi_mm.pgd;
if (efi_enabled(EFI_OLD_MEMMAP)) if (efi_enabled(EFI_OLD_MEMMAP))
return; return;
...@@ -341,7 +342,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) ...@@ -341,7 +342,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
unsigned long pfn, text, pf; unsigned long pfn, text, pf;
struct page *page; struct page *page;
unsigned npages; unsigned npages;
pgd_t *pgd; pgd_t *pgd = efi_mm.pgd;
if (efi_enabled(EFI_OLD_MEMMAP)) if (efi_enabled(EFI_OLD_MEMMAP))
return 0; return 0;
...@@ -351,8 +352,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) ...@@ -351,8 +352,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
* this value is loaded into cr3 the PGD will be decrypted during * this value is loaded into cr3 the PGD will be decrypted during
* the pagetable walk. * the pagetable walk.
*/ */
efi_scratch.efi_pgt = (pgd_t *)__sme_pa(efi_pgd); efi_scratch.efi_pgt = (pgd_t *)__sme_pa(pgd);
pgd = efi_pgd;
/* /*
* It can happen that the physical address of new_memmap lands in memory * It can happen that the physical address of new_memmap lands in memory
...@@ -422,7 +422,7 @@ static void __init __map_region(efi_memory_desc_t *md, u64 va) ...@@ -422,7 +422,7 @@ static void __init __map_region(efi_memory_desc_t *md, u64 va)
{ {
unsigned long flags = _PAGE_RW; unsigned long flags = _PAGE_RW;
unsigned long pfn; unsigned long pfn;
pgd_t *pgd = efi_pgd; pgd_t *pgd = efi_mm.pgd;
if (!(md->attribute & EFI_MEMORY_WB)) if (!(md->attribute & EFI_MEMORY_WB))
flags |= _PAGE_PCD; flags |= _PAGE_PCD;
...@@ -526,7 +526,7 @@ void __init parse_efi_setup(u64 phys_addr, u32 data_len) ...@@ -526,7 +526,7 @@ void __init parse_efi_setup(u64 phys_addr, u32 data_len)
static int __init efi_update_mappings(efi_memory_desc_t *md, unsigned long pf) static int __init efi_update_mappings(efi_memory_desc_t *md, unsigned long pf)
{ {
unsigned long pfn; unsigned long pfn;
pgd_t *pgd = efi_pgd; pgd_t *pgd = efi_mm.pgd;
int err1, err2; int err1, err2;
/* Update the 1:1 mapping */ /* Update the 1:1 mapping */
...@@ -623,7 +623,7 @@ void __init efi_dump_pagetable(void) ...@@ -623,7 +623,7 @@ void __init efi_dump_pagetable(void)
if (efi_enabled(EFI_OLD_MEMMAP)) if (efi_enabled(EFI_OLD_MEMMAP))
ptdump_walk_pgd_level(NULL, swapper_pg_dir); ptdump_walk_pgd_level(NULL, swapper_pg_dir);
else else
ptdump_walk_pgd_level(NULL, efi_pgd); ptdump_walk_pgd_level(NULL, efi_mm.pgd);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment