diff options
Diffstat (limited to 'arch/x86/power')
| -rw-r--r-- | arch/x86/power/cpu.c | 30 | ||||
| -rw-r--r-- | arch/x86/power/hibernate_32.c | 2 | ||||
| -rw-r--r-- | arch/x86/power/hibernate_64.c | 64 | ||||
| -rw-r--r-- | arch/x86/power/hibernate_asm_32.S | 4 | ||||
| -rw-r--r-- | arch/x86/power/hibernate_asm_64.S | 3 | 
5 files changed, 47 insertions, 56 deletions
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c index 120cee1c3f8..1cf5b300305 100644 --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c @@ -11,6 +11,7 @@  #include <linux/suspend.h>  #include <linux/export.h>  #include <linux/smp.h> +#include <linux/perf_event.h>  #include <asm/pgtable.h>  #include <asm/proto.h> @@ -24,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 @@ -61,13 +58,20 @@ static void __save_processor_state(struct saved_context *ctxt)  	 * descriptor tables  	 */  #ifdef CONFIG_X86_32 -	store_gdt(&ctxt->gdt);  	store_idt(&ctxt->idt);  #else  /* CONFIG_X86_64 */ -	store_gdt((struct desc_ptr *)&ctxt->gdt_limit);  	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(). */ @@ -134,7 +138,10 @@ static void fix_processor_context(void)  {  	int cpu = smp_processor_id();  	struct tss_struct *t = &per_cpu(init_tss, cpu); - +#ifdef CONFIG_X86_64 +	struct desc_struct *desc = get_cpu_gdt_table(cpu); +	tss_desc tss; +#endif  	set_tss_desc(cpu, t);	/*  				 * This just modifies memory; should not be  				 * necessary. But... This is necessary, because @@ -143,7 +150,9 @@ static void fix_processor_context(void)  				 */  #ifdef CONFIG_X86_64 -	get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9; +	memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc)); +	tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */ +	write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);  	syscall_init();				/* This sets MSR_*STAR and related */  #endif @@ -182,11 +191,9 @@ static void __restore_processor_state(struct saved_context *ctxt)  	 * ltr is done i fix_processor_context().  	 */  #ifdef CONFIG_X86_32 -	load_gdt(&ctxt->gdt);  	load_idt(&ctxt->idt);  #else  /* CONFIG_X86_64 */ -	load_gdt((const struct desc_ptr *)&ctxt->gdt_limit);  	load_idt((const struct desc_ptr *)&ctxt->idt_limit);  #endif @@ -228,6 +235,7 @@ static void __restore_processor_state(struct saved_context *ctxt)  	do_fpu_end();  	x86_platform.restore_sched_clock_state();  	mtrr_bp_restore(); +	perf_restore_debug_store();  }  /* Needed by apm.c */ diff --git a/arch/x86/power/hibernate_32.c b/arch/x86/power/hibernate_32.c index 74202c1910c..7d28c885d23 100644 --- a/arch/x86/power/hibernate_32.c +++ b/arch/x86/power/hibernate_32.c @@ -129,8 +129,6 @@ static int resume_physical_mapping_init(pgd_t *pgd_base)  		}  	} -	resume_map_numa_kva(pgd_base); -  	return 0;  } diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c index 460f314d13e..a0fde91c16c 100644 --- a/arch/x86/power/hibernate_64.c +++ b/arch/x86/power/hibernate_64.c @@ -11,6 +11,8 @@  #include <linux/gfp.h>  #include <linux/smp.h>  #include <linux/suspend.h> + +#include <asm/init.h>  #include <asm/proto.h>  #include <asm/page.h>  #include <asm/pgtable.h> @@ -39,41 +41,21 @@ pgd_t *temp_level4_pgt;  void *relocated_restore_code; -static int res_phys_pud_init(pud_t *pud, unsigned long address, unsigned long end) +static void *alloc_pgt_page(void *context)  { -	long i, j; - -	i = pud_index(address); -	pud = pud + i; -	for (; i < PTRS_PER_PUD; pud++, i++) { -		unsigned long paddr; -		pmd_t *pmd; - -		paddr = address + i*PUD_SIZE; -		if (paddr >= end) -			break; - -		pmd = (pmd_t *)get_safe_page(GFP_ATOMIC); -		if (!pmd) -			return -ENOMEM; -		set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE)); -		for (j = 0; j < PTRS_PER_PMD; pmd++, j++, paddr += PMD_SIZE) { -			unsigned long pe; - -			if (paddr >= end) -				break; -			pe = __PAGE_KERNEL_LARGE_EXEC | paddr; -			pe &= __supported_pte_mask; -			set_pmd(pmd, __pmd(pe)); -		} -	} -	return 0; +	return (void *)get_safe_page(GFP_ATOMIC);  }  static int set_up_temporary_mappings(void)  { -	unsigned long start, end, next; -	int error; +	struct x86_mapping_info info = { +		.alloc_pgt_page	= alloc_pgt_page, +		.pmd_flag	= __PAGE_KERNEL_LARGE_EXEC, +		.kernel_mapping = true, +	}; +	unsigned long mstart, mend; +	int result; +	int i;  	temp_level4_pgt = (pgd_t *)get_safe_page(GFP_ATOMIC);  	if (!temp_level4_pgt) @@ -84,21 +66,17 @@ static int set_up_temporary_mappings(void)  		init_level4_pgt[pgd_index(__START_KERNEL_map)]);  	/* Set up the direct mapping from scratch */ -	start = (unsigned long)pfn_to_kaddr(0); -	end = (unsigned long)pfn_to_kaddr(max_pfn); +	for (i = 0; i < nr_pfn_mapped; i++) { +		mstart = pfn_mapped[i].start << PAGE_SHIFT; +		mend   = pfn_mapped[i].end << PAGE_SHIFT; -	for (; start < end; start = next) { -		pud_t *pud = (pud_t *)get_safe_page(GFP_ATOMIC); -		if (!pud) -			return -ENOMEM; -		next = start + PGDIR_SIZE; -		if (next > end) -			next = end; -		if ((error = res_phys_pud_init(pud, __pa(start), __pa(next)))) -			return error; -		set_pgd(temp_level4_pgt + pgd_index(start), -			mk_kernel_pgd(__pa(pud))); +		result = kernel_ident_mapping_init(&info, temp_level4_pgt, +						   mstart, mend); + +		if (result) +			return result;  	} +  	return 0;  } diff --git a/arch/x86/power/hibernate_asm_32.S b/arch/x86/power/hibernate_asm_32.S index ad47daeafa4..1d0fa0e2407 100644 --- a/arch/x86/power/hibernate_asm_32.S +++ b/arch/x86/power/hibernate_asm_32.S @@ -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 diff --git a/arch/x86/power/hibernate_asm_64.S b/arch/x86/power/hibernate_asm_64.S index 9356547d8c0..3c4469a7a92 100644 --- a/arch/x86/power/hibernate_asm_64.S +++ b/arch/x86/power/hibernate_asm_64.S @@ -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 */  |