Skip to content

Commit f94560c

Browse files
joergroedelKAGA-KOKO
authored andcommitted
x86/mm/pti: Clone CPU_ENTRY_AREA on PMD level on x86_32
Cloning on the P4D level would clone the complete kernel address space into the user-space page-tables for PAE kernels. Cloning on PMD level is fine for PAE and legacy paging. Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Pavel Machek <pavel@ucw.cz> Cc: "H . Peter Anvin" <hpa@zytor.com> Cc: linux-mm@kvack.org Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Juergen Gross <jgross@suse.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Brian Gerst <brgerst@gmail.com> Cc: David Laight <David.Laight@aculab.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Eduardo Valentin <eduval@amazon.com> Cc: Greg KH <gregkh@linuxfoundation.org> Cc: Will Deacon <will.deacon@arm.com> Cc: aliguori@amazon.com Cc: daniel.gruss@iaik.tugraz.at Cc: hughd@google.com Cc: keescook@google.com Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Waiman Long <llong@redhat.com> Cc: "David H . Gutteridge" <dhgutteridge@sympatico.ca> Cc: joro@8bytes.org Link: https://lkml.kernel.org/r/1531906876-13451-27-git-send-email-joro@8bytes.org
1 parent 2c1b9fb commit f94560c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

arch/x86/mm/pti.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
348348
}
349349
}
350350

351+
#ifdef CONFIG_X86_64
351352
/*
352353
* Clone a single p4d (i.e. a top-level entry on 4-level systems and a
353354
* next-level entry on 5-level systems.
@@ -371,6 +372,25 @@ static void __init pti_clone_user_shared(void)
371372
pti_clone_p4d(CPU_ENTRY_AREA_BASE);
372373
}
373374

375+
#else /* CONFIG_X86_64 */
376+
377+
/*
378+
* On 32 bit PAE systems with 1GB of Kernel address space there is only
379+
* one pgd/p4d for the whole kernel. Cloning that would map the whole
380+
* address space into the user page-tables, making PTI useless. So clone
381+
* the page-table on the PMD level to prevent that.
382+
*/
383+
static void __init pti_clone_user_shared(void)
384+
{
385+
unsigned long start, end;
386+
387+
start = CPU_ENTRY_AREA_BASE;
388+
end = start + (PAGE_SIZE * CPU_ENTRY_AREA_PAGES);
389+
390+
pti_clone_pmds(start, end, 0);
391+
}
392+
#endif /* CONFIG_X86_64 */
393+
374394
/*
375395
* Clone the ESPFIX P4D into the user space visible page table
376396
*/

0 commit comments

Comments
 (0)