x86/mm: Do not auto-massage page protections
authorDave Hansen <[email protected]>
Fri, 6 Apr 2018 20:55:09 +0000 (13:55 -0700)
committerIngo Molnar <[email protected]>
Thu, 12 Apr 2018 07:04:22 +0000 (09:04 +0200)
commitfb43d6cb91ef57d9e58d5f69b423784ff4a4c374
tree4785de6f0a6b6b3bf0ef8df64c400af3c34cdfbc
parent6baf4bec02dbc41645c3a5130ee15a8e1d62b80f
x86/mm: Do not auto-massage page protections

A PTE is constructed from a physical address and a pgprotval_t.
__PAGE_KERNEL, for instance, is a pgprot_t and must be converted
into a pgprotval_t before it can be used to create a PTE.  This is
done implicitly within functions like pfn_pte() by massage_pgprot().

However, this makes it very challenging to set bits (and keep them
set) if your bit is being filtered out by massage_pgprot().

This moves the bit filtering out of pfn_pte() and friends.  For
users of PAGE_KERNEL*, filtering will be done automatically inside
those macros but for users of __PAGE_KERNEL*, they need to do their
own filtering now.

Note that we also just move pfn_pte/pmd/pud() over to check_pgprot()
instead of massage_pgprot().  This way, we still *look* for
unsupported bits and properly warn about them if we find them.  This
might happen if an unfiltered __PAGE_KERNEL* value was passed in,
for instance.

- printk format warning fix from: Arnd Bergmann <[email protected]>
- boot crash fix from:            Tom Lendacky <[email protected]>
- crash bisected by:              Mike Galbraith <[email protected]>

Signed-off-by: Dave Hansen <[email protected]>
Reported-and-fixed-by: Arnd Bergmann <[email protected]>
Fixed-by: Tom Lendacky <[email protected]>
Bisected-by: Mike Galbraith <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Nadav Amit <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/boot/compressed/kaslr.c
arch/x86/include/asm/pgtable.h
arch/x86/kernel/head64.c
arch/x86/kernel/ldt.c
arch/x86/mm/ident_map.c
arch/x86/mm/iomap_32.c
arch/x86/mm/ioremap.c
arch/x86/mm/kasan_init_64.c
arch/x86/mm/pgtable.c
arch/x86/power/hibernate_64.c