x86/mm/pageattr: Use __KERNEL_PAGE_EXEC for kernel pgtable _KERNPG_TABLE isn't the correct pgprot value to use for the PTE, it's only suitable for the upper levels of the page table structures (TRUE?). One benefit is that _PAGE_GLOBAL is now set in the ptes created in kernel_map_pages_in_pgd() just like if large pages get split later. Cc: Borislav Petkov <bp@suse.de> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 58653ae..427dfb0 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c
@@ -881,6 +881,22 @@ pte = pte_offset_kernel(pmd, start); +#if 0 + pgprot_val(pgprot) = __PAGE_KERNEL; + + /* + * Set the GLOBAL flags only if the PRESENT flag is + * set otherwise pte_present will return true even on + * a non present pte. The canon_pgprot will clear + * _PAGE_GLOBAL for the ancient hardware that doesn't + * support it. + */ + if (pgprot_val(pgprot) & _PAGE_PRESENT) + pgprot_val(pgprot) |= _PAGE_GLOBAL; + else + pgprot_val(pgprot) &= ~_PAGE_GLOBAL; +#endif + while (num_pages-- && start < end) { /* deal with the NX bit */