summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2023-10-17 23:23:28 +0200
committerBorislav Petkov (AMD) <bp@alien8.de>2023-10-18 18:28:41 +0200
commit69ba866db281c768d5ecca909361ea4c4e71d57e (patch)
treedb37b656e8f91d7e14e2964abd4cbc34666a6bd0
parentx86/boot/32: De-uglify the 2/3 level paging difference in mk_early_pgtbl_32() (diff)
downloadlinux-69ba866db281c768d5ecca909361ea4c4e71d57e.tar.xz
linux-69ba866db281c768d5ecca909361ea4c4e71d57e.zip
x86/boot/32: Restructure mk_early_pgtbl_32()
Prepare it for adding a temporary initrd mapping by splitting out the actual map loop. No functional change. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20231017211722.175910753@linutronix.de
-rw-r--r--arch/x86/kernel/head32.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index 2b6599807026..bdce6321fabd 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -79,35 +79,40 @@ typedef pgd_t pl2_t;
#define SET_PL2(val) { .pgd = (val), }
#endif
-void __init __no_stack_protector mk_early_pgtbl_32(void)
+static __init __no_stack_protector pte_t init_map(pte_t pte, pte_t **ptep, pl2_t **pl2p,
+ const unsigned long limit)
{
- /* Enough space to fit pagetables for the low memory linear map */
- const unsigned long limit = __pa_nodebug(_end) +
- (PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT);
- pte_t pte, *ptep = (pte_t *)__pa_nodebug(__brk_base);
- pl2_t *pl2p = (pl2_t *)__pa_nodebug(pl2_base);
- unsigned long *ptr;
- int i;
-
- pte.pte = PTE_IDENT_ATTR;
-
while ((pte.pte & PTE_PFN_MASK) < limit) {
- pl2_t pl2 = SET_PL2((unsigned long)ptep | PDE_IDENT_ATTR);
-
- *pl2p = pl2;
+ pl2_t pl2 = SET_PL2((unsigned long)*ptep | PDE_IDENT_ATTR);
+ int i;
+ **pl2p = pl2;
if (!IS_ENABLED(CONFIG_X86_PAE)) {
/* Kernel PDE entry */
- *(pl2p + ((PAGE_OFFSET >> PGDIR_SHIFT))) = pl2;
+ *(*pl2p + ((PAGE_OFFSET >> PGDIR_SHIFT))) = pl2;
}
for (i = 0; i < PTRS_PER_PTE; i++) {
- *ptep = pte;
+ **ptep = pte;
pte.pte += PAGE_SIZE;
- ptep++;
+ (*ptep)++;
}
- pl2p++;
+ (*pl2p)++;
}
+ return pte;
+}
+
+void __init __no_stack_protector mk_early_pgtbl_32(void)
+{
+ /* Enough space to fit pagetables for the low memory linear map */
+ const unsigned long limit = __pa_nodebug(_end) +
+ (PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT);
+ pte_t pte, *ptep = (pte_t *)__pa_nodebug(__brk_base);
+ pl2_t *pl2p = (pl2_t *)__pa_nodebug(pl2_base);
+ unsigned long *ptr;
+
+ pte.pte = PTE_IDENT_ATTR;
+ pte = init_map(pte, &ptep, &pl2p, limit);
ptr = (unsigned long *)__pa_nodebug(&max_pfn_mapped);
/* Can't use pte_pfn() since it's a call with CONFIG_PARAVIRT */
@@ -116,4 +121,3 @@ void __init __no_stack_protector mk_early_pgtbl_32(void)
ptr = (unsigned long *)__pa_nodebug(&_brk_end);
*ptr = (unsigned long)ptep + PAGE_OFFSET;
}
-