diff options
| -rw-r--r-- | arch/x86/include/asm/pgtable_types.h | 29 | ||||
| -rw-r--r-- | arch/x86/mm/init.c | 6 | ||||
| -rw-r--r-- | arch/x86/mm/init_32.c | 8 | ||||
| -rw-r--r-- | arch/x86/mm/init_64.c | 5 |
4 files changed, 34 insertions, 14 deletions
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index acfe755562a6..1e5a40673953 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h | |||
| @@ -196,19 +196,21 @@ enum page_cache_mode { | |||
| 196 | #define __PAGE_KERNEL_NOENC (__PAGE_KERNEL) | 196 | #define __PAGE_KERNEL_NOENC (__PAGE_KERNEL) |
| 197 | #define __PAGE_KERNEL_NOENC_WP (__PAGE_KERNEL_WP) | 197 | #define __PAGE_KERNEL_NOENC_WP (__PAGE_KERNEL_WP) |
| 198 | 198 | ||
| 199 | #define PAGE_KERNEL __pgprot(__PAGE_KERNEL | _PAGE_ENC) | 199 | #define default_pgprot(x) __pgprot((x) & __default_kernel_pte_mask) |
| 200 | #define PAGE_KERNEL_NOENC __pgprot(__PAGE_KERNEL) | 200 | |
| 201 | #define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO | _PAGE_ENC) | 201 | #define PAGE_KERNEL default_pgprot(__PAGE_KERNEL | _PAGE_ENC) |
| 202 | #define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC | _PAGE_ENC) | 202 | #define PAGE_KERNEL_NOENC default_pgprot(__PAGE_KERNEL) |
| 203 | #define PAGE_KERNEL_EXEC_NOENC __pgprot(__PAGE_KERNEL_EXEC) | 203 | #define PAGE_KERNEL_RO default_pgprot(__PAGE_KERNEL_RO | _PAGE_ENC) |
| 204 | #define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX | _PAGE_ENC) | 204 | #define PAGE_KERNEL_EXEC default_pgprot(__PAGE_KERNEL_EXEC | _PAGE_ENC) |
| 205 | #define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE | _PAGE_ENC) | 205 | #define PAGE_KERNEL_EXEC_NOENC default_pgprot(__PAGE_KERNEL_EXEC) |
| 206 | #define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE | _PAGE_ENC) | 206 | #define PAGE_KERNEL_RX default_pgprot(__PAGE_KERNEL_RX | _PAGE_ENC) |
| 207 | #define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC | _PAGE_ENC) | 207 | #define PAGE_KERNEL_NOCACHE default_pgprot(__PAGE_KERNEL_NOCACHE | _PAGE_ENC) |
| 208 | #define PAGE_KERNEL_VVAR __pgprot(__PAGE_KERNEL_VVAR | _PAGE_ENC) | 208 | #define PAGE_KERNEL_LARGE default_pgprot(__PAGE_KERNEL_LARGE | _PAGE_ENC) |
| 209 | 209 | #define PAGE_KERNEL_LARGE_EXEC default_pgprot(__PAGE_KERNEL_LARGE_EXEC | _PAGE_ENC) | |
| 210 | #define PAGE_KERNEL_IO __pgprot(__PAGE_KERNEL_IO) | 210 | #define PAGE_KERNEL_VVAR default_pgprot(__PAGE_KERNEL_VVAR | _PAGE_ENC) |
| 211 | #define PAGE_KERNEL_IO_NOCACHE __pgprot(__PAGE_KERNEL_IO_NOCACHE) | 211 | |
| 212 | #define PAGE_KERNEL_IO default_pgprot(__PAGE_KERNEL_IO) | ||
| 213 | #define PAGE_KERNEL_IO_NOCACHE default_pgprot(__PAGE_KERNEL_IO_NOCACHE) | ||
| 212 | 214 | ||
| 213 | #endif /* __ASSEMBLY__ */ | 215 | #endif /* __ASSEMBLY__ */ |
| 214 | 216 | ||
| @@ -483,6 +485,7 @@ static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot) | |||
| 483 | typedef struct page *pgtable_t; | 485 | typedef struct page *pgtable_t; |
| 484 | 486 | ||
| 485 | extern pteval_t __supported_pte_mask; | 487 | extern pteval_t __supported_pte_mask; |
| 488 | extern pteval_t __default_kernel_pte_mask; | ||
| 486 | extern void set_nx(void); | 489 | extern void set_nx(void); |
| 487 | extern int nx_enabled; | 490 | extern int nx_enabled; |
| 488 | 491 | ||
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 82f5252c723a..583a88c8a6ee 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
| @@ -190,6 +190,12 @@ static void __init probe_page_size_mask(void) | |||
| 190 | enable_global_pages(); | 190 | enable_global_pages(); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | /* By the default is everything supported: */ | ||
| 194 | __default_kernel_pte_mask = __supported_pte_mask; | ||
| 195 | /* Except when with PTI where the kernel is mostly non-Global: */ | ||
| 196 | if (cpu_feature_enabled(X86_FEATURE_PTI)) | ||
| 197 | __default_kernel_pte_mask &= ~_PAGE_GLOBAL; | ||
| 198 | |||
| 193 | /* Enable 1 GB linear kernel mappings if available: */ | 199 | /* Enable 1 GB linear kernel mappings if available: */ |
| 194 | if (direct_gbpages && boot_cpu_has(X86_FEATURE_GBPAGES)) { | 200 | if (direct_gbpages && boot_cpu_has(X86_FEATURE_GBPAGES)) { |
| 195 | printk(KERN_INFO "Using GB pages for direct mapping\n"); | 201 | printk(KERN_INFO "Using GB pages for direct mapping\n"); |
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 396e1f0151ac..07cdc2ed4965 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c | |||
| @@ -558,8 +558,14 @@ static void __init pagetable_init(void) | |||
| 558 | permanent_kmaps_init(pgd_base); | 558 | permanent_kmaps_init(pgd_base); |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL); | 561 | #define DEFAULT_PTE_MASK ~(_PAGE_NX | _PAGE_GLOBAL) |
| 562 | /* Bits supported by the hardware: */ | ||
| 563 | pteval_t __supported_pte_mask __read_mostly = DEFAULT_PTE_MASK; | ||
| 564 | /* Bits allowed in normal kernel mappings: */ | ||
| 565 | pteval_t __default_kernel_pte_mask __read_mostly = DEFAULT_PTE_MASK; | ||
| 562 | EXPORT_SYMBOL_GPL(__supported_pte_mask); | 566 | EXPORT_SYMBOL_GPL(__supported_pte_mask); |
| 567 | /* Used in PAGE_KERNEL_* macros which are reasonably used out-of-tree: */ | ||
| 568 | EXPORT_SYMBOL(__default_kernel_pte_mask); | ||
| 563 | 569 | ||
| 564 | /* user-defined highmem size */ | 570 | /* user-defined highmem size */ |
| 565 | static unsigned int highmem_pages = -1; | 571 | static unsigned int highmem_pages = -1; |
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 45241de66785..e6c52dbbf649 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c | |||
| @@ -65,8 +65,13 @@ | |||
| 65 | * around without checking the pgd every time. | 65 | * around without checking the pgd every time. |
| 66 | */ | 66 | */ |
| 67 | 67 | ||
| 68 | /* Bits supported by the hardware: */ | ||
| 68 | pteval_t __supported_pte_mask __read_mostly = ~0; | 69 | pteval_t __supported_pte_mask __read_mostly = ~0; |
| 70 | /* Bits allowed in normal kernel mappings: */ | ||
| 71 | pteval_t __default_kernel_pte_mask __read_mostly = ~0; | ||
| 69 | EXPORT_SYMBOL_GPL(__supported_pte_mask); | 72 | EXPORT_SYMBOL_GPL(__supported_pte_mask); |
| 73 | /* Used in PAGE_KERNEL_* macros which are reasonably used out-of-tree: */ | ||
| 74 | EXPORT_SYMBOL(__default_kernel_pte_mask); | ||
| 70 | 75 | ||
| 71 | int force_personality32; | 76 | int force_personality32; |
| 72 | 77 | ||
