aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-02 17:43:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-02 17:43:58 -0400
commita8bdf745126593308927dfa264d3d2158338a148 (patch)
treed99e50133bac166ae4017ca4f0143c3e57da3825
parentfbe8ed634d3f7db92227d84363264868bd7ed751 (diff)
parent78d77df71510a96e042de7ba6dbd7998103642cb (diff)
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Peter Anvin: "Two regression fixes: 1. On 64 bits, we would set NX on non-NX-capable hardware (very rare in 64-bit land, but a nonzero subset.) 2. Fix suspend/resume across kernel versions" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86-64, init: Do not set NX bits on non-NX capable hardware x86, gdt, hibernate: Store/load GDT for hibernate path.
-rw-r--r--arch/x86/include/asm/suspend_32.h1
-rw-r--r--arch/x86/include/asm/suspend_64.h2
-rw-r--r--arch/x86/kernel/asm-offsets_32.c3
-rw-r--r--arch/x86/kernel/asm-offsets_64.c1
-rw-r--r--arch/x86/kernel/head64.c3
-rw-r--r--arch/x86/kernel/head_64.S1
-rw-r--r--arch/x86/power/cpu.c15
-rw-r--r--arch/x86/power/hibernate_asm_32.S4
-rw-r--r--arch/x86/power/hibernate_asm_64.S3
9 files changed, 27 insertions, 6 deletions
diff --git a/arch/x86/include/asm/suspend_32.h b/arch/x86/include/asm/suspend_32.h
index f6064b7385b0..552d6c90a6d4 100644
--- a/arch/x86/include/asm/suspend_32.h
+++ b/arch/x86/include/asm/suspend_32.h
@@ -15,6 +15,7 @@ struct saved_context {
15 unsigned long cr0, cr2, cr3, cr4; 15 unsigned long cr0, cr2, cr3, cr4;
16 u64 misc_enable; 16 u64 misc_enable;
17 bool misc_enable_saved; 17 bool misc_enable_saved;
18 struct desc_ptr gdt_desc;
18 struct desc_ptr idt; 19 struct desc_ptr idt;
19 u16 ldt; 20 u16 ldt;
20 u16 tss; 21 u16 tss;
diff --git a/arch/x86/include/asm/suspend_64.h b/arch/x86/include/asm/suspend_64.h
index 97b84e08a211..bc6232834bab 100644
--- a/arch/x86/include/asm/suspend_64.h
+++ b/arch/x86/include/asm/suspend_64.h
@@ -25,6 +25,8 @@ struct saved_context {
25 u64 misc_enable; 25 u64 misc_enable;
26 bool misc_enable_saved; 26 bool misc_enable_saved;
27 unsigned long efer; 27 unsigned long efer;
28 u16 gdt_pad; /* Unused */
29 struct desc_ptr gdt_desc;
28 u16 idt_pad; 30 u16 idt_pad;
29 u16 idt_limit; 31 u16 idt_limit;
30 unsigned long idt_base; 32 unsigned long idt_base;
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index 85d98ab15cdc..0ef4bba2acb7 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -60,6 +60,9 @@ void foo(void)
60 OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext); 60 OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
61 BLANK(); 61 BLANK();
62 62
63 OFFSET(saved_context_gdt_desc, saved_context, gdt_desc);
64 BLANK();
65
63 /* Offset from the sysenter stack to tss.sp0 */ 66 /* Offset from the sysenter stack to tss.sp0 */
64 DEFINE(TSS_sysenter_sp0, offsetof(struct tss_struct, x86_tss.sp0) - 67 DEFINE(TSS_sysenter_sp0, offsetof(struct tss_struct, x86_tss.sp0) -
65 sizeof(struct tss_struct)); 68 sizeof(struct tss_struct));
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index 1b4754f82ba7..e7c798b354fa 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -73,6 +73,7 @@ int main(void)
73 ENTRY(cr3); 73 ENTRY(cr3);
74 ENTRY(cr4); 74 ENTRY(cr4);
75 ENTRY(cr8); 75 ENTRY(cr8);
76 ENTRY(gdt_desc);
76 BLANK(); 77 BLANK();
77#undef ENTRY 78#undef ENTRY
78 79
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 */
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
index 6d6e907cee46..1cf5b300305e 100644
--- a/arch/x86/power/cpu.c
+++ b/arch/x86/power/cpu.c
@@ -25,16 +25,12 @@
25#include <asm/cpu.h> 25#include <asm/cpu.h>
26 26
27#ifdef CONFIG_X86_32 27#ifdef CONFIG_X86_32
28static struct saved_context saved_context;
29
30unsigned long saved_context_ebx; 28unsigned long saved_context_ebx;
31unsigned long saved_context_esp, saved_context_ebp; 29unsigned long saved_context_esp, saved_context_ebp;
32unsigned long saved_context_esi, saved_context_edi; 30unsigned long saved_context_esi, saved_context_edi;
33unsigned long saved_context_eflags; 31unsigned long saved_context_eflags;
34#else
35/* CONFIG_X86_64 */
36struct saved_context saved_context;
37#endif 32#endif
33struct saved_context saved_context;
38 34
39/** 35/**
40 * __save_processor_state - save CPU registers before creating a 36 * __save_processor_state - save CPU registers before creating a
@@ -67,6 +63,15 @@ static void __save_processor_state(struct saved_context *ctxt)
67/* CONFIG_X86_64 */ 63/* CONFIG_X86_64 */
68 store_idt((struct desc_ptr *)&ctxt->idt_limit); 64 store_idt((struct desc_ptr *)&ctxt->idt_limit);
69#endif 65#endif
66 /*
67 * We save it here, but restore it only in the hibernate case.
68 * For ACPI S3 resume, this is loaded via 'early_gdt_desc' in 64-bit
69 * mode in "secondary_startup_64". In 32-bit mode it is done via
70 * 'pmode_gdt' in wakeup_start.
71 */
72 ctxt->gdt_desc.size = GDT_SIZE - 1;
73 ctxt->gdt_desc.address = (unsigned long)get_cpu_gdt_table(smp_processor_id());
74
70 store_tr(ctxt->tr); 75 store_tr(ctxt->tr);
71 76
72 /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */ 77 /* XMM0..XMM15 should be handled by kernel_fpu_begin(). */
diff --git a/arch/x86/power/hibernate_asm_32.S b/arch/x86/power/hibernate_asm_32.S
index ad47daeafa4e..1d0fa0e24070 100644
--- a/arch/x86/power/hibernate_asm_32.S
+++ b/arch/x86/power/hibernate_asm_32.S
@@ -75,6 +75,10 @@ done:
75 pushl saved_context_eflags 75 pushl saved_context_eflags
76 popfl 76 popfl
77 77
78 /* Saved in save_processor_state. */
79 movl $saved_context, %eax
80 lgdt saved_context_gdt_desc(%eax)
81
78 xorl %eax, %eax 82 xorl %eax, %eax
79 83
80 ret 84 ret
diff --git a/arch/x86/power/hibernate_asm_64.S b/arch/x86/power/hibernate_asm_64.S
index 9356547d8c01..3c4469a7a929 100644
--- a/arch/x86/power/hibernate_asm_64.S
+++ b/arch/x86/power/hibernate_asm_64.S
@@ -139,6 +139,9 @@ ENTRY(restore_registers)
139 pushq pt_regs_flags(%rax) 139 pushq pt_regs_flags(%rax)
140 popfq 140 popfq
141 141
142 /* Saved in save_processor_state. */
143 lgdt saved_context_gdt_desc(%rax)
144
142 xorq %rax, %rax 145 xorq %rax, %rax
143 146
144 /* tell the hibernation core that we've just restored the memory */ 147 /* tell the hibernation core that we've just restored the memory */