Skip to content

Commit f7cfbee

Browse files
amlutoIngo Molnar
authored andcommitted
x86/mm/pti: Share cpu_entry_area with user space page tables
Share the cpu entry area so the user space and kernel space page tables have the same P4D page. Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Laight <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Eduardo Valentin <[email protected]> Cc: Greg KH <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 8d4b067 commit f7cfbee

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

arch/x86/mm/pti.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,29 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
264264
}
265265
}
266266

267+
/*
268+
* Clone a single p4d (i.e. a top-level entry on 4-level systems and a
269+
* next-level entry on 5-level systems.
270+
*/
271+
static void __init pti_clone_p4d(unsigned long addr)
272+
{
273+
p4d_t *kernel_p4d, *user_p4d;
274+
pgd_t *kernel_pgd;
275+
276+
user_p4d = pti_user_pagetable_walk_p4d(addr);
277+
kernel_pgd = pgd_offset_k(addr);
278+
kernel_p4d = p4d_offset(kernel_pgd, addr);
279+
*user_p4d = *kernel_p4d;
280+
}
281+
282+
/*
283+
* Clone the CPU_ENTRY_AREA into the user space visible page table.
284+
*/
285+
static void __init pti_clone_user_shared(void)
286+
{
287+
pti_clone_p4d(CPU_ENTRY_AREA_BASE);
288+
}
289+
267290
/*
268291
* Initialize kernel page table isolation
269292
*/
@@ -273,4 +296,6 @@ void __init pti_init(void)
273296
return;
274297

275298
pr_info("enabled\n");
299+
300+
pti_clone_user_shared();
276301
}

0 commit comments

Comments
 (0)