xen: arm: pcpu context switch
authorIan Campbell <ian.campbell@citrix.com>
Fri, 22 Feb 2013 08:58:07 +0000 (08:58 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 22 Feb 2013 12:14:54 +0000 (12:14 +0000)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/arm/arm64/entry.S
xen/arch/arm/domain.c
xen/include/asm-arm/domain.h

index e35b6eafd6eff6f2edc30ff5152de4628e54840e..9d38088c8525081f6d3270078c63d8dac8f6fb0d 100644 (file)
@@ -246,6 +246,36 @@ ENTRY(hyp_traps_vector)
         ventry  guest_fiq_invalid_compat        // FIQ 32-bit EL0/EL1
         ventry  guest_error_invalid_compat      // Error 32-bit EL0/EL1
 
+/*
+ * struct vcpu *__context_switch(struct vcpu *prev, struct vcpu *next)
+ *
+ * x0 - prev
+ * x1 - next
+ *
+ * Returns prev in x0
+ */
+ENTRY(__context_switch)
+        add     x8, x0, #VCPU_arch_saved_context
+        mov     x9, sp
+        stp     x19, x20, [x8], #16             // store callee-saved registers
+        stp     x21, x22, [x8], #16
+        stp     x23, x24, [x8], #16
+        stp     x25, x26, [x8], #16
+        stp     x27, x28, [x8], #16
+        stp     x29, x9, [x8], #16
+        str     lr, [x8]
+
+        add     x8, x1, #VCPU_arch_saved_context
+        ldp     x19, x20, [x8], #16             // restore callee-saved registers
+        ldp     x21, x22, [x8], #16
+        ldp     x23, x24, [x8], #16
+        ldp     x25, x26, [x8], #16
+        ldp     x27, x28, [x8], #16
+        ldp     x29, x9, [x8], #16
+        ldr     lr, [x8]
+        mov     sp, x9
+        ret
+
 /*
  * Local variables:
  * mode: ASM
index 3d21f0ebf1824e8b694b8bac658bc3ac7dd281fa..883a681d3613808085dbb2735ab18d3067db828d 100644 (file)
@@ -387,8 +387,8 @@ int vcpu_initialise(struct vcpu *v)
                                            - sizeof(struct cpu_info));
 
     memset(&v->arch.saved_context, 0, sizeof(v->arch.saved_context));
-    v->arch.saved_context.sp = (uint32_t)v->arch.cpu_info;
-    v->arch.saved_context.pc = (uint32_t)continue_new_vcpu;
+    v->arch.saved_context.sp = (register_t)v->arch.cpu_info;
+    v->arch.saved_context.pc = (register_t)continue_new_vcpu;
 
     /* Idle VCPUs don't need the rest of this setup */
     if ( is_idle_vcpu(v) )
index 4e9d38d2f7c3089586ff57fe06be01dcbb4eab49..f691c26461db4518ea5e756150ed00db98c790d7 100644 (file)
@@ -99,16 +99,29 @@ struct vtimer {
 struct arch_vcpu
 {
     struct {
-        uint32_t    r4;
-        uint32_t    r5;
-        uint32_t    r6;
-        uint32_t    r7;
-        uint32_t    r8;
-        uint32_t    r9;
-        uint32_t    sl;
-        uint32_t    fp;
-        uint32_t    sp;
-        uint32_t    pc;
+#ifdef CONFIG_ARM_32
+        register_t r4;
+        register_t r5;
+        register_t r6;
+        register_t r7;
+        register_t r8;
+        register_t r9;
+        register_t sl;
+#else
+        register_t x19;
+        register_t x20;
+        register_t x21;
+        register_t x22;
+        register_t x23;
+        register_t x24;
+        register_t x25;
+        register_t x26;
+        register_t x27;
+        register_t x28;
+#endif
+        register_t fp;
+        register_t sp;
+        register_t pc;
     } saved_context;
 
     void *stack;