]> xenbits.xensource.com Git - xen.git/commitdiff
Fix long-standing save/restore bug on x86-64.
authorsmh22@firebug.cl.cam.ac.uk <smh22@firebug.cl.cam.ac.uk>
Thu, 6 Apr 2006 15:15:28 +0000 (16:15 +0100)
committersmh22@firebug.cl.cam.ac.uk <smh22@firebug.cl.cam.ac.uk>
Thu, 6 Apr 2006 15:15:28 +0000 (16:15 +0100)
Signed-off-by: Steven Hand <steven@xensource.com>
linux-2.6-xen-sparse/drivers/xen/core/reboot.c

index 990dc35cee645a81986926129abe8699c0a5c5c1..ba0b9b911277f434c77f5a0cc1f0350d0caf3faf 100644 (file)
@@ -85,6 +85,23 @@ void smp_resume(void);
 #define smp_resume()   ((void)0)
 #endif
 
+/* Ensure we run on the idle task page tables so that we will
+   switch page tables before running user space. This is needed
+   on architectures with separate kernel and user page tables
+   because the user page table pointer is not saved/restored. */
+static void switch_idle_mm(void)
+{
+       struct mm_struct *mm = current->active_mm;
+
+       if (mm == &init_mm)
+               return;
+
+       atomic_inc(&init_mm.mm_count);
+       switch_mm(mm, &init_mm, current);
+       current->active_mm = &init_mm;
+       mmdrop(mm);
+}
+
 static int __do_suspend(void *ignore)
 {
        int i, j, k, fpp, err;
@@ -164,6 +181,8 @@ static int __do_suspend(void *ignore)
 
        time_resume();
 
+       switch_idle_mm();
+
        __sti();
 
        xencons_resume();