Skip to content

Commit

Permalink
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/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.
  • Loading branch information
Linus Torvalds committed May 2, 2013
2 parents fbe8ed6 + 78d77df commit a8bdf74
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions arch/x86/include/asm/suspend_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct saved_context {
unsigned long cr0, cr2, cr3, cr4;
u64 misc_enable;
bool misc_enable_saved;
struct desc_ptr gdt_desc;
struct desc_ptr idt;
u16 ldt;
u16 tss;
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/include/asm/suspend_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct saved_context {
u64 misc_enable;
bool misc_enable_saved;
unsigned long efer;
u16 gdt_pad; /* Unused */
struct desc_ptr gdt_desc;
u16 idt_pad;
u16 idt_limit;
unsigned long idt_base;
Expand Down
3 changes: 3 additions & 0 deletions arch/x86/kernel/asm-offsets_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ void foo(void)
OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
BLANK();

OFFSET(saved_context_gdt_desc, saved_context, gdt_desc);
BLANK();

/* Offset from the sysenter stack to tss.sp0 */
DEFINE(TSS_sysenter_sp0, offsetof(struct tss_struct, x86_tss.sp0) -
sizeof(struct tss_struct));
Expand Down
1 change: 1 addition & 0 deletions arch/x86/kernel/asm-offsets_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ int main(void)
ENTRY(cr3);
ENTRY(cr4);
ENTRY(cr8);
ENTRY(gdt_desc);
BLANK();
#undef ENTRY

Expand Down
3 changes: 2 additions & 1 deletion arch/x86/kernel/head64.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
extern pgd_t early_level4_pgt[PTRS_PER_PGD];
extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];
static unsigned int __initdata next_early_pgt = 2;
pmdval_t __initdata early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);

/* Wipe all early page tables except for the kernel symbol map */
static void __init reset_early_page_tables(void)
Expand Down Expand Up @@ -99,7 +100,7 @@ int __init early_make_pgtable(unsigned long address)
pmd_p[i] = 0;
*pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
}
pmd = (physaddr & PMD_MASK) + (__PAGE_KERNEL_LARGE & ~_PAGE_GLOBAL);
pmd = (physaddr & PMD_MASK) + early_pmd_flags;
pmd_p[pmd_index(address)] = pmd;

return 0;
Expand Down
1 change: 1 addition & 0 deletions arch/x86/kernel/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ ENTRY(secondary_startup_64)
btl $20,%edi /* No Execute supported? */
jnc 1f
btsl $_EFER_NX, %eax
btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
1: wrmsr /* Make changes effective */

/* Setup cr0 */
Expand Down
15 changes: 10 additions & 5 deletions arch/x86/power/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
#include <asm/cpu.h>

#ifdef CONFIG_X86_32
static struct saved_context saved_context;

unsigned long saved_context_ebx;
unsigned long saved_context_esp, saved_context_ebp;
unsigned long saved_context_esi, saved_context_edi;
unsigned long saved_context_eflags;
#else
/* CONFIG_X86_64 */
struct saved_context saved_context;
#endif
struct saved_context saved_context;

/**
* __save_processor_state - save CPU registers before creating a
Expand Down Expand Up @@ -67,6 +63,15 @@ static void __save_processor_state(struct saved_context *ctxt)
/* CONFIG_X86_64 */
store_idt((struct desc_ptr *)&ctxt->idt_limit);
#endif
/*
* We save it here, but restore it only in the hibernate case.
* For ACPI S3 resume, this is loaded via 'early_gdt_desc' in 64-bit
* mode in "secondary_startup_64". In 32-bit mode it is done via
* 'pmode_gdt' in wakeup_start.
*/
ctxt->gdt_desc.size = GDT_SIZE - 1;
ctxt->gdt_desc.address = (unsigned long)get_cpu_gdt_table(smp_processor_id());

store_tr(ctxt->tr);

/* XMM0..XMM15 should be handled by kernel_fpu_begin(). */
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/power/hibernate_asm_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ done:
pushl saved_context_eflags
popfl

/* Saved in save_processor_state. */
movl $saved_context, %eax
lgdt saved_context_gdt_desc(%eax)

xorl %eax, %eax

ret
3 changes: 3 additions & 0 deletions arch/x86/power/hibernate_asm_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ ENTRY(restore_registers)
pushq pt_regs_flags(%rax)
popfq

/* Saved in save_processor_state. */
lgdt saved_context_gdt_desc(%rax)

xorq %rax, %rax

/* tell the hibernation core that we've just restored the memory */
Expand Down

0 comments on commit a8bdf74

Please sign in to comment.