[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XenPPC][Patch] Kernel patch for xm save/restore



diff -r f4d382795e57 arch/powerpc/platforms/xen/hcall.c
--- a/arch/powerpc/platforms/xen/hcall.c        Wed Oct 25 17:22:54 2006 -0400
+++ b/arch/powerpc/platforms/xen/hcall.c        Fri Oct 13 13:56:04 2006 -0500
@@ -256,6 +256,7 @@ static int xenppc_privcmd_domctl(privcmd
        case XEN_DOMCTL_pausedomain:
        case XEN_DOMCTL_unpausedomain:
        case XEN_DOMCTL_getdomaininfo:
+       case XEN_DOMCTL_getshadowlist:
                break;
        case XEN_DOMCTL_getmemlist:
                ret = xencomm_create(
diff -r f4d382795e57 arch/powerpc/platforms/xen/reboot.c
--- a/arch/powerpc/platforms/xen/reboot.c       Wed Oct 25 17:22:54 2006 -0400
+++ b/arch/powerpc/platforms/xen/reboot.c       Wed Nov 01 17:11:58 2006 -0500
@@ -1,9 +1,19 @@
 #include <linux/module.h>
+#include <linux/kernel.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/io/console.h>
 #include <xen/xencons.h>
 #include <asm/hypervisor.h>
 #include <asm/machdep.h>
+#include <asm/mmu_context.h>
+#include <xen/cpu_hotplug.h>
+#include <xen/xenbus.h>
+#include <xen/gnttab.h>
+#include <xen/evtchn.h>
+
+#define  SHUTDOWN_INVALID      -1
+
+static int shutting_down ;

 static void domain_machine_restart(char * __unused)
 {
@@ -31,3 +41,86 @@ void xen_reboot_init(struct machdep_call
                ppc_md.halt      = domain_machine_power_off;
        }
 }
+
+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);
+}
+
+int ppc_do_suspend(void *ignore)
+{
+       int  err;
+       enum system_states temp_state;
+
+       BUG_ON(smp_processor_id() != 0);
+       BUG_ON(in_interrupt());
+
+#ifndef CONFIG_PPC_XEN
+       if (xen_feature(XENFEAT_auto_translated_physmap)) {
+               printk(KERN_WARNING "Cannot suspend in "
+                      "auto_translated_physmap mode.\n");
+               return -EOPNOTSUPP;
+       }
+#endif
+       err = smp_suspend();
+       if (err)
+               return err;
+
+       xenbus_suspend();
+
+       preempt_disable();
+
+       __cli();
+       
+       temp_state = system_state;
+       system_state = SYSTEM_SUSPEND_DISK;
+
+       preempt_enable();
+
+       gnttab_suspend();
+
+       HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
+
+       xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
+       xen_start_info->console_mfn = mfn_to_pfn(xen_start_info->console_mfn);
+
+       /*
+        * We'll stop somewhere inside this hypercall. When it returns,
+        * we'll start resuming after the restore.
+        */
+       HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
+
+       shutting_down = SHUTDOWN_INVALID;
+       
+       printk("Here we're resuming \n");  //DEBUG
+
+ HYPERVISOR_shared_info = (shared_info_t *)__va(xen_start_info->shared_info);
+       memset(empty_zero_page, 0, PAGE_SIZE);
+
+       gnttab_resume();
+
+       irq_resume();
+
+       switch_idle_mm();
+
+       system_state = temp_state;
+
+       __sti();
+
+       xencons_resume();
+
+       xenbus_resume();
+
+       smp_resume();
+
+       return err;
+}
+
diff -r f4d382795e57 drivers/xen/core/reboot.c
--- a/drivers/xen/core/reboot.c Wed Oct 25 17:22:54 2006 -0400
+++ b/drivers/xen/core/reboot.c Wed Nov 01 17:14:40 2006 -0500
@@ -151,7 +151,7 @@ static int __do_suspend(void *ignore)
        HYPERVISOR_suspend(virt_to_mfn(xen_start_info));

        shutting_down = SHUTDOWN_INVALID;
-
+       
        set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);

        HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
@@ -192,13 +192,15 @@ static int __do_suspend(void *ignore)

        return err;
 }
-#else  /* CONFIG_PPC_XEN */
+
+#else
+int ppc_do_suspend(void *ignore);
 static int __do_suspend(void *ignore)
 {
        printk("SUSPEND!!??\n");
-       return 0;
-}
-#endif  /* CONFIG_PPC_XEN */
+       return ppc_do_suspend(ignore);
+}
+#endif

 static int shutdown_process(void *__unused)
 {
diff -r f4d382795e57 include/asm-powerpc/system.h
--- a/include/asm-powerpc/system.h      Wed Oct 25 17:22:54 2006 -0400
+++ b/include/asm-powerpc/system.h      Thu Oct 05 15:13:38 2006 -0500
@@ -433,5 +433,12 @@ extern void account_system_vtime(struct
 extern void account_system_vtime(struct task_struct *);
 #endif

+#ifndef        __cli
+
+#define __cli() local_irq_disable()
+#define        __sti() local_irq_enable()
+#endif /* __cli */
+
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_SYSTEM_H */
diff -r f4d382795e57 include/asm-powerpc/xen/asm/hypercall.h
--- a/include/asm-powerpc/xen/asm/hypercall.h   Wed Oct 25 17:22:54 2006 -0400
+++ b/include/asm-powerpc/xen/asm/hypercall.h   Thu Oct 05 15:16:40 2006 -0500
@@ -60,6 +60,16 @@ static inline int HYPERVISOR_shutdown(un
        return HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
 }

+
+static inline int HYPERVISOR_suspend(unsigned long srec)
+{
+       struct sched_shutdown sched_shutdown = {
+               .reason = SHUTDOWN_suspend
+       };
+
+       return HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
+}
+
 static inline int HYPERVISOR_set_timer_op(unsigned long arg)
 {
        return plpar_hcall_norets(XEN_MARK(__HYPERVISOR_set_timer_op), arg);
diff -r f4d382795e57 include/xen/interface/arch-powerpc.h
--- a/include/xen/interface/arch-powerpc.h      Wed Oct 25 17:22:54 2006 -0400
+++ b/include/xen/interface/arch-powerpc.h      Wed Nov 01 16:16:35 2006 -0500
@@ -29,7 +29,6 @@

#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
 #define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
-#define XEN_GUEST_HANDLE_64(name)     __guest_handle_ ## name
 #define set_xen_guest_handle(hnd, val) \
     do { \
         if (sizeof ((hnd).__pad)) \
@@ -42,9 +41,6 @@
 #endif

 #ifndef __ASSEMBLY__
-
-typedef uint64_t uint64_aligned_t;
-
 /* Guest handles for primitive C types. */
 __DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
 __DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
@@ -98,11 +94,66 @@ typedef struct cpu_user_regs cpu_user_re

 typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */ /* XXX timebase */

+#define        NUM_SLB_ENTRIES 64
+struct slb_entry {
+       uint64_t slb_vsid;
+       uint64_t slb_esid;
+};
+typedef struct slb_entry slb_entry_t;
+
+#ifndef HAS_VMX
+#define        HAS_VMX 1
+#endif
+
+#ifndef HAS_FLOAT
+#define        HAS_FLOAT 1
+#endif
+
+#ifdef HAS_VMX
+typedef struct {
+       uint32_t u[4];
+} __attribute__((aligned(16))) _vector128;
+#endif /* HAS_VMX */
+
+
 /* ONLY used to communicate with dom0! See also struct exec_domain. */
 struct vcpu_guest_context {
     cpu_user_regs_t user_regs;         /* User-level CPU registers     */
+ slb_entry_t slb_entries[NUM_SLB_ENTRIES]; /* Segment Lookaside Buffer */
+
+    /* Special-Purpose Registers */
+    uint64_t sprg[4];
+    uint64_t timebase;
+    uint64_t dar;
+    uint64_t dsisr;
+
+    struct cpu_vcpu_tag {
+       uint64_t hid4;
+    } cpu; /* CPU-specific bits */
+
+    uint32_t dec;
+
+    /* XXX etc */
+#ifdef HAS_FLOAT
+#define  NUM_FPRS 32
+    double fprs[NUM_FPRS];
+#endif
+#ifdef HAS_VMX
+    _vector128 vrs[32];
+    _vector128 vscr;
+    uint32_t vrsave;
+#endif
+
+#if 0
+    struct xencomm *xencomm;
+
+    /* I/O-port access bitmap. */
+    u8 *iobmp;        /* Guest kernel virtual address of the bitmap. */
+    int iobmp_limit;  /* Number of ports represented in the bitmap.  */
+    int iopl;         /* Current IOPL for this VCPU. */
+#endif
+
     uint64_t sdr1;                     /* Pagetable base               */
-    /* XXX etc */
 };
 typedef struct vcpu_guest_context vcpu_guest_context_t;
 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
diff -r f4d382795e57 include/xen/interface/domctl.h
--- a/include/xen/interface/domctl.h    Wed Oct 25 17:22:54 2006 -0400
+++ b/include/xen/interface/domctl.h    Fri Oct 13 14:28:14 2006 -0500
@@ -354,6 +354,17 @@ struct xen_domctl_real_mode_area {
 };
 typedef struct xen_domctl_real_mode_area xen_domctl_real_mode_area_t;
 DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_mode_area_t);
+
+#define XEN_DOMCTL_getshadowlist       29
+struct xen_domctl_getshadowlist {
+       /* OUT variables. */
+       /* Start of htab array */
+       uint64_t htab_map;
+       /* Numver of ptes within htab */
+       uint htab_num_ptes;
+};
+typedef struct xen_domctl_getshadowlist        xen_domctl_getshadowlist_t;
+DEFINE_XEN_GUEST_HANDLE(xen_domctl_getshadowlist_t);

 struct xen_domctl {
     uint32_t cmd;
@@ -381,6 +392,7 @@ struct xen_domctl {
         struct xen_domctl_arch_setup        arch_setup;
         struct xen_domctl_settimeoffset     settimeoffset;
         struct xen_domctl_real_mode_area    real_mode_area;
+        struct xen_domctl_getshadowlist            getshadowlist;
         uint8_t                             pad[128];
     } u;
 };


_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.