Skip to content

Commit d92fc69

Browse files
amlutoIngo Molnar
authored andcommitted
x86/mm: Remove kernel_unmap_pages_in_pgd() and efi_cleanup_page_tables()
kernel_unmap_pages_in_pgd() is dangerous: if a PGD entry in init_mm.pgd were to be cleared, callers would need to ensure that the pgd entry hadn't been propagated to any other pgd. Its only caller was efi_cleanup_page_tables(), and that, in turn, was unused, so just delete both functions. This leaves a couple of other helpers unused, so delete them, too. Signed-off-by: Andy Lutomirski <luto@kernel.org> Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk> Acked-by: Borislav Petkov <bp@suse.de> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/77ff20fdde3b75cd393be5559ad8218870520248.1468527351.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 360cb4d commit d92fc69

File tree

6 files changed

+0
-41
lines changed

6 files changed

+0
-41
lines changed

arch/x86/include/asm/efi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ extern void __init efi_map_region_fixed(efi_memory_desc_t *md);
125125
extern void efi_sync_low_kernel_mappings(void);
126126
extern int __init efi_alloc_page_tables(void);
127127
extern int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages);
128-
extern void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages);
129128
extern void __init old_map_region(efi_memory_desc_t *md);
130129
extern void __init runtime_code_page_mkexec(void);
131130
extern void __init efi_runtime_update_mappings(void);

arch/x86/include/asm/pgtable_types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,6 @@ extern pmd_t *lookup_pmd_address(unsigned long address);
481481
extern phys_addr_t slow_virt_to_phys(void *__address);
482482
extern int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address,
483483
unsigned numpages, unsigned long page_flags);
484-
void kernel_unmap_pages_in_pgd(pgd_t *root, unsigned long address,
485-
unsigned numpages);
486484
#endif /* !__ASSEMBLY__ */
487485

488486
#endif /* _ASM_X86_PGTABLE_DEFS_H */

arch/x86/mm/pageattr.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -746,18 +746,6 @@ static bool try_to_free_pmd_page(pmd_t *pmd)
746746
return true;
747747
}
748748

749-
static bool try_to_free_pud_page(pud_t *pud)
750-
{
751-
int i;
752-
753-
for (i = 0; i < PTRS_PER_PUD; i++)
754-
if (!pud_none(pud[i]))
755-
return false;
756-
757-
free_page((unsigned long)pud);
758-
return true;
759-
}
760-
761749
static bool unmap_pte_range(pmd_t *pmd, unsigned long start, unsigned long end)
762750
{
763751
pte_t *pte = pte_offset_kernel(pmd, start);
@@ -871,16 +859,6 @@ static void unmap_pud_range(pgd_t *pgd, unsigned long start, unsigned long end)
871859
*/
872860
}
873861

874-
static void unmap_pgd_range(pgd_t *root, unsigned long addr, unsigned long end)
875-
{
876-
pgd_t *pgd_entry = root + pgd_index(addr);
877-
878-
unmap_pud_range(pgd_entry, addr, end);
879-
880-
if (try_to_free_pud_page((pud_t *)pgd_page_vaddr(*pgd_entry)))
881-
pgd_clear(pgd_entry);
882-
}
883-
884862
static int alloc_pte_page(pmd_t *pmd)
885863
{
886864
pte_t *pte = (pte_t *)get_zeroed_page(GFP_KERNEL | __GFP_NOTRACK);
@@ -1994,12 +1972,6 @@ int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address,
19941972
return retval;
19951973
}
19961974

1997-
void kernel_unmap_pages_in_pgd(pgd_t *root, unsigned long address,
1998-
unsigned numpages)
1999-
{
2000-
unmap_pgd_range(root, address, address + (numpages << PAGE_SHIFT));
2001-
}
2002-
20031975
/*
20041976
* The testcases use internal knowledge of the implementation that shouldn't
20051977
* be exposed to the rest of the kernel. Include these directly here.

arch/x86/platform/efi/efi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,6 @@ static void __init __efi_enter_virtual_mode(void)
978978
* EFI mixed mode we need all of memory to be accessible when
979979
* we pass parameters to the EFI runtime services in the
980980
* thunking code.
981-
*
982-
* efi_cleanup_page_tables(__pa(new_memmap), 1 << pg_shift);
983981
*/
984982
free_pages((unsigned long)new_memmap, pg_shift);
985983

arch/x86/platform/efi/efi_32.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
4949
{
5050
return 0;
5151
}
52-
void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages)
53-
{
54-
}
5552

5653
void __init efi_map_region(efi_memory_desc_t *md)
5754
{

arch/x86/platform/efi/efi_64.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,6 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
285285
return 0;
286286
}
287287

288-
void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages)
289-
{
290-
kernel_unmap_pages_in_pgd(efi_pgd, pa_memmap, num_pages);
291-
}
292-
293288
static void __init __map_region(efi_memory_desc_t *md, u64 va)
294289
{
295290
unsigned long flags = _PAGE_RW;

0 commit comments

Comments
 (0)