mirror of https://gitee.com/openkylin/linux.git
efi/x86: Split off some old memmap handling into separate routines
In a subsequent patch, we will fold the prolog/epilog routines that are part of the support code to call SetVirtualAddressMap() with a 1:1 mapping into the callers. However, the 64-bit version mostly consists of ugly mapping code that is only used when efi=old_map is in effect, which is extremely rare. So let's move this code out of the way so it does not clutter the common code. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Arvind Sankar <nivedita@alum.mit.edu> Cc: Matthew Garrett <mjg59@google.com> Cc: linux-efi@vger.kernel.org Link: https://lkml.kernel.org/r/20200103113953.9571-7-ardb@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
89ed486532
commit
98dd0e3a0c
|
@ -72,7 +72,9 @@ static void __init early_code_mapping_set_exec(int executable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pgd_t * __init efi_call_phys_prolog(void)
|
void __init efi_old_memmap_phys_epilog(pgd_t *save_pgd);
|
||||||
|
|
||||||
|
pgd_t * __init efi_old_memmap_phys_prolog(void)
|
||||||
{
|
{
|
||||||
unsigned long vaddr, addr_pgd, addr_p4d, addr_pud;
|
unsigned long vaddr, addr_pgd, addr_p4d, addr_pud;
|
||||||
pgd_t *save_pgd, *pgd_k, *pgd_efi;
|
pgd_t *save_pgd, *pgd_k, *pgd_efi;
|
||||||
|
@ -82,11 +84,6 @@ pgd_t * __init efi_call_phys_prolog(void)
|
||||||
int pgd;
|
int pgd;
|
||||||
int n_pgds, i, j;
|
int n_pgds, i, j;
|
||||||
|
|
||||||
if (!efi_enabled(EFI_OLD_MEMMAP)) {
|
|
||||||
efi_switch_mm(&efi_mm);
|
|
||||||
return efi_mm.pgd;
|
|
||||||
}
|
|
||||||
|
|
||||||
early_code_mapping_set_exec(1);
|
early_code_mapping_set_exec(1);
|
||||||
|
|
||||||
n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
|
n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
|
||||||
|
@ -143,11 +140,11 @@ pgd_t * __init efi_call_phys_prolog(void)
|
||||||
__flush_tlb_all();
|
__flush_tlb_all();
|
||||||
return save_pgd;
|
return save_pgd;
|
||||||
out:
|
out:
|
||||||
efi_call_phys_epilog(save_pgd);
|
efi_old_memmap_phys_epilog(save_pgd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __init efi_call_phys_epilog(pgd_t *save_pgd)
|
void __init efi_old_memmap_phys_epilog(pgd_t *save_pgd)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* After the lock is released, the original page table is restored.
|
* After the lock is released, the original page table is restored.
|
||||||
|
@ -158,11 +155,6 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
|
||||||
p4d_t *p4d;
|
p4d_t *p4d;
|
||||||
pud_t *pud;
|
pud_t *pud;
|
||||||
|
|
||||||
if (!efi_enabled(EFI_OLD_MEMMAP)) {
|
|
||||||
efi_switch_mm(efi_scratch.prev_mm);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nr_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT) , PGDIR_SIZE);
|
nr_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT) , PGDIR_SIZE);
|
||||||
|
|
||||||
for (pgd_idx = 0; pgd_idx < nr_pgds; pgd_idx++) {
|
for (pgd_idx = 0; pgd_idx < nr_pgds; pgd_idx++) {
|
||||||
|
@ -193,6 +185,23 @@ void __init efi_call_phys_epilog(pgd_t *save_pgd)
|
||||||
early_code_mapping_set_exec(0);
|
early_code_mapping_set_exec(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pgd_t * __init efi_call_phys_prolog(void)
|
||||||
|
{
|
||||||
|
if (efi_enabled(EFI_OLD_MEMMAP))
|
||||||
|
return efi_old_memmap_phys_prolog();
|
||||||
|
|
||||||
|
efi_switch_mm(&efi_mm);
|
||||||
|
return efi_mm.pgd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __init efi_call_phys_epilog(pgd_t *save_pgd)
|
||||||
|
{
|
||||||
|
if (efi_enabled(EFI_OLD_MEMMAP))
|
||||||
|
efi_old_memmap_phys_epilog(save_pgd);
|
||||||
|
else
|
||||||
|
efi_switch_mm(efi_scratch.prev_mm);
|
||||||
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL_GPL(efi_mm);
|
EXPORT_SYMBOL_GPL(efi_mm);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue