ia64/xen-unstable

changeset 14227:29d4bca7a503

linux: Some save/restore simplifications and cleanups.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Fri Mar 02 23:01:36 2007 +0000 (2007-03-02)
parents d5ca4c37b3c5
children 25c0b660f7c6
files linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c linux-2.6-xen-sparse/include/xen/cpu_hotplug.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c	Fri Mar 02 22:57:27 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_reboot.c	Fri Mar 02 23:01:36 2007 +0000
     1.3 @@ -59,23 +59,6 @@ EXPORT_SYMBOL(machine_restart);
     1.4  EXPORT_SYMBOL(machine_halt);
     1.5  EXPORT_SYMBOL(machine_power_off);
     1.6  
     1.7 -/* Ensure we run on the idle task page tables so that we will
     1.8 -   switch page tables before running user space. This is needed
     1.9 -   on architectures with separate kernel and user page tables
    1.10 -   because the user page table pointer is not saved/restored. */
    1.11 -static void switch_idle_mm(void)
    1.12 -{
    1.13 -	struct mm_struct *mm = current->active_mm;
    1.14 -
    1.15 -	if (mm == &init_mm)
    1.16 -		return;
    1.17 -
    1.18 -	atomic_inc(&init_mm.mm_count);
    1.19 -	switch_mm(mm, &init_mm, current);
    1.20 -	current->active_mm = &init_mm;
    1.21 -	mmdrop(mm);
    1.22 -}
    1.23 -
    1.24  static void pre_suspend(void)
    1.25  {
    1.26  	HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
    1.27 @@ -99,7 +82,9 @@ static void post_suspend(int suspend_can
    1.28  		xen_start_info->console.domU.mfn =
    1.29  			pfn_to_mfn(xen_start_info->console.domU.mfn);
    1.30  	} else {
    1.31 +#ifdef CONFIG_SMP
    1.32  		cpu_initialized_map = cpumask_of_cpu(0);
    1.33 +#endif
    1.34  	}
    1.35  	
    1.36  	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
    1.37 @@ -172,10 +157,25 @@ static int take_machine_down(void *p_fas
    1.38  
    1.39  	post_suspend(suspend_cancelled);
    1.40  	gnttab_resume();
    1.41 -	if (!suspend_cancelled)
    1.42 +	if (!suspend_cancelled) {
    1.43  		irq_resume();
    1.44 +#ifdef __x86_64__
    1.45 +		/*
    1.46 +		 * Older versions of Xen do not save/restore the user %cr3.
    1.47 +		 * We do it here just in case, but there's no need if we are
    1.48 +		 * in fast-suspend mode as that implies a new enough Xen.
    1.49 +		 */
    1.50 +		if (!fast_suspend) {
    1.51 +			struct mmuext_op op;
    1.52 +			op.cmd = MMUEXT_NEW_USER_BASEPTR;
    1.53 +			op.arg1.mfn = pfn_to_mfn(__pa(__user_pgd(
    1.54 +				current->active_mm->pgd)) >> PAGE_SHIFT);
    1.55 +			if (HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF))
    1.56 +				BUG();
    1.57 +		}
    1.58 +#endif
    1.59 +	}
    1.60  	time_resume();
    1.61 -	switch_idle_mm();
    1.62  	local_irq_enable();
    1.63  
    1.64  	if (fast_suspend && !suspend_cancelled) {
     2.1 --- a/linux-2.6-xen-sparse/include/xen/cpu_hotplug.h	Fri Mar 02 22:57:27 2007 +0000
     2.2 +++ b/linux-2.6-xen-sparse/include/xen/cpu_hotplug.h	Fri Mar 02 23:01:36 2007 +0000
     2.3 @@ -4,7 +4,7 @@
     2.4  #include <linux/kernel.h>
     2.5  #include <linux/cpumask.h>
     2.6  
     2.7 -#if defined(CONFIG_X86)
     2.8 +#if defined(CONFIG_X86) && defined(CONFIG_SMP)
     2.9  extern cpumask_t cpu_initialized_map;
    2.10  #define cpu_set_initialized(cpu) cpu_set(cpu, cpu_initialized_map)
    2.11  #else