aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2013-05-02 13:33:46 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2013-05-02 14:27:35 -0400
commit78d77df71510a96e042de7ba6dbd7998103642cb (patch)
tree9b948900c1493a5f1711b59235db842bc40adfb1
parentcc456c4e7cac3837a86aaa7ca3cb9f488d44d196 (diff)
x86-64, init: Do not set NX bits on non-NX capable hardware
During early init, we would incorrectly set the NX bit even if the NX feature was not supported. Instead, only set this bit if NX is actually available and enabled. We already do very early detection of the NX bit to enable it in EFER, this simply extends this detection to the early page table mask. Reported-by: Fernando Luis Vázquez Cao <fernando@oss.ntt.co.jp> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Link: http://lkml.kernel.org/r/1367476850.5660.2.camel@nexus Cc: <stable@vger.kernel.org> v3.9
-rw-r--r--arch/x86/kernel/head64.c3
-rw-r--r--arch/x86/kernel/head_64.S1
2 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 101ac1a9263e..dab95a85f7f8 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -34,6 +34,7 @@
34extern pgd_t early_level4_pgt[PTRS_PER_PGD]; 34extern pgd_t early_level4_pgt[PTRS_PER_PGD];
35extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD]; 35extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];
36static unsigned int __initdata next_early_pgt = 2; 36static unsigned int __initdata next_early_pgt = 2;
37pmdval_t __initdata early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);
37 38
38/* Wipe all early page tables except for the kernel symbol map */ 39/* Wipe all early page tables except for the kernel symbol map */
39static void __init reset_early_page_tables(void) 40static void __init reset_early_page_tables(void)
@@ -99,7 +100,7 @@ again:
99 pmd_p[i] = 0; 100 pmd_p[i] = 0;
100 *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE; 101 *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
101 } 102 }
102 pmd = (physaddr & PMD_MASK) + (__PAGE_KERNEL_LARGE & ~_PAGE_GLOBAL); 103 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
103 pmd_p[pmd_index(address)] = pmd; 104 pmd_p[pmd_index(address)] = pmd;
104 105
105 return 0; 106 return 0;
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 6859e9626442..08f7e8039099 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -200,6 +200,7 @@ ENTRY(secondary_startup_64)
200 btl $20,%edi /* No Execute supported? */ 200 btl $20,%edi /* No Execute supported? */
201 jnc 1f 201 jnc 1f
202 btsl $_EFER_NX, %eax 202 btsl $_EFER_NX, %eax
203 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
2031: wrmsr /* Make changes effective */ 2041: wrmsr /* Make changes effective */
204 205
205 /* Setup cr0 */ 206 /* Setup cr0 */