Skip to contentSkip to conversation

runstate_memory_area on ARM

PATCH In review Stefano Stabellini 3 participants 9 messages May 1, 2013 – May 8, 2013

lore
Share & tools
lore
#0 lore raw

cover runstate_memory_area on ARM

Hi all,
this patch series introduces support for runstate_memory_area on ARM. The first patch moves VCPUOP_register_runstate_memory_area to common code, while the second one add VCPUOP_register_runstate_memory_area to the whilelist of vcpu_op hypercalls supported on ARM and properly updates the runstate_memory_area during vcpu context switch.

Stefano Stabellini (2):
xen: move VCPUOP_register_runstate_memory_area to common code xen/arm: handle the runstate_memory_area

 xen/arch/arm/domain.c |   22 ++++++++++++++++------
 xen/arch/x86/domain.c |   28 ----------------------------
 xen/common/domain.c   |   28 ++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 34 deletions(-)

Cheers,

Stefano

#1 lore raw

PATCH 1/2 xen: move VCPUOP_register_runstate_memory_area to common code

---
 xen/arch/x86/domain.c |   28 ----------------------------
 xen/common/domain.c   |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 28 deletions(-)
xen/arch/x86/domain.c +0 -28
index d1b6c64..87dcb73 100644
@@ -960,34 +960,6 @@ arch_do_vcpu_op(
 
     switch ( cmd )
     {
-    case VCPUOP_register_runstate_memory_area:
-    {
-        struct vcpu_register_runstate_memory_area area;
-        struct vcpu_runstate_info runstate;
-
-        rc = -EFAULT;
-        if ( copy_from_guest(&area, arg, 1) )
-            break;
-
-        if ( !guest_handle_okay(area.addr.h, 1) )
-            break;
-
-        rc = 0;
-        runstate_guest(v) = area.addr.h;
-
-        if ( v == current )
-        {
-            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
-        }
-        else
-        {
-            vcpu_runstate_get(v, &runstate);
-            __copy_to_guest(runstate_guest(v), &runstate, 1);
-        }
-
-        break;
-    }
-
     /*
      * XXX Disable for 4.0.0: __update_vcpu_system_time() writes to the given
      * virtual address even when running in another domain's address space.
xen/common/domain.c +28 -0
index d21909f..0752dd2 100644
@@ -1126,6 +1126,34 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+    case VCPUOP_register_runstate_memory_area:
+    {
+        struct vcpu_register_runstate_memory_area area;
+        struct vcpu_runstate_info runstate;
+
+        rc = -EFAULT;
+        if ( copy_from_guest(&area, arg, 1) )
+            break;
+
+        if ( !guest_handle_okay(area.addr.h, 1) )
+            break;
+
+        rc = 0;
+        runstate_guest(v) = area.addr.h;
+
+        if ( v == current )
+        {
+            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
+        }
+        else
+        {
+            vcpu_runstate_get(v, &runstate);
+            __copy_to_guest(runstate_guest(v), &runstate, 1);
+        }
+
+        break;
+    }
+
 #ifdef VCPU_TRAP_NMI
     case VCPUOP_send_nmi:
         if ( !guest_handle_is_null(arg) )
Signature · 1 line
1.7.2.5
#2 lore raw

Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code

Quoted 1 line · Stefano Stabellini

Needs x86 and/or core acks, but lacks suitable CCs. Added.

Quoted 83 lines
---
 xen/arch/x86/domain.c |   28 ----------------------------
 xen/common/domain.c   |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 28 deletions(-)
xen/arch/x86/domain.c +0 -28
index d1b6c64..87dcb73 100644
@@ -960,34 +960,6 @@ arch_do_vcpu_op(
 
     switch ( cmd )
     {
-    case VCPUOP_register_runstate_memory_area:
-    {
-        struct vcpu_register_runstate_memory_area area;
-        struct vcpu_runstate_info runstate;
-
-        rc = -EFAULT;
-        if ( copy_from_guest(&area, arg, 1) )
-            break;
-
-        if ( !guest_handle_okay(area.addr.h, 1) )
-            break;
-
-        rc = 0;
-        runstate_guest(v) = area.addr.h;
-
-        if ( v == current )
-        {
-            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
-        }
-        else
-        {
-            vcpu_runstate_get(v, &runstate);
-            __copy_to_guest(runstate_guest(v), &runstate, 1);
-        }
-
-        break;
-    }
-
     /*
      * XXX Disable for 4.0.0: __update_vcpu_system_time() writes to the given
      * virtual address even when running in another domain's address space.
xen/common/domain.c +28 -0
index d21909f..0752dd2 100644
@@ -1126,6 +1126,34 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+    case VCPUOP_register_runstate_memory_area:
+    {
+        struct vcpu_register_runstate_memory_area area;
+        struct vcpu_runstate_info runstate;
+
+        rc = -EFAULT;
+        if ( copy_from_guest(&area, arg, 1) )
+            break;
+
+        if ( !guest_handle_okay(area.addr.h, 1) )
+            break;
+
+        rc = 0;
+        runstate_guest(v) = area.addr.h;
+
+        if ( v == current )
+        {
+            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
+        }
+        else
+        {
+            vcpu_runstate_get(v, &runstate);
+            __copy_to_guest(runstate_guest(v), &runstate, 1);
+        }
+
+        break;
+    }
+
 #ifdef VCPU_TRAP_NMI
     case VCPUOP_send_nmi:
         if ( !guest_handle_is_null(arg) )
Acked-by
#3 lore raw

Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code

Quoted 4 lines · Ian Campbell
Quoted 1 line · Stefano Stabellini

Needs x86 and/or core acks, but lacks suitable CCs. Added.

Quoted 87 lines
Quoted 85 lines
---
 xen/arch/x86/domain.c |   28 ----------------------------
 xen/common/domain.c   |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 28 deletions(-)
xen/arch/x86/domain.c +0 -28
index d1b6c64..87dcb73 100644
@@ -960,34 +960,6 @@ arch_do_vcpu_op(
 
     switch ( cmd )
     {
-    case VCPUOP_register_runstate_memory_area:
-    {
-        struct vcpu_register_runstate_memory_area area;
-        struct vcpu_runstate_info runstate;
-
-        rc = -EFAULT;
-        if ( copy_from_guest(&area, arg, 1) )
-            break;
-
-        if ( !guest_handle_okay(area.addr.h, 1) )
-            break;
-
-        rc = 0;
-        runstate_guest(v) = area.addr.h;
-
-        if ( v == current )
-        {
-            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
-        }
-        else
-        {
-            vcpu_runstate_get(v, &runstate);
-            __copy_to_guest(runstate_guest(v), &runstate, 1);
-        }
-
-        break;
-    }
-
     /*
      * XXX Disable for 4.0.0: __update_vcpu_system_time() writes to the

given
* virtual address even when running in another domain's address space.

xen/common/domain.c +28 -0
index d21909f..0752dd2 100644
@@ -1126,6 +1126,34 @@ long do_vcpu_op(int cmd, int vcpuid,
 XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+    case VCPUOP_register_runstate_memory_area:
+    {
+        struct vcpu_register_runstate_memory_area area;
+        struct vcpu_runstate_info runstate;
+
+        rc = -EFAULT;
+        if ( copy_from_guest(&area, arg, 1) )
+            break;
+
+        if ( !guest_handle_okay(area.addr.h, 1) )
+            break;
+
+        rc = 0;
+        runstate_guest(v) = area.addr.h;
+
+        if ( v == current )
+        {
+            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
+        }
+        else
+        {
+            vcpu_runstate_get(v, &runstate);
+            __copy_to_guest(runstate_guest(v), &runstate, 1);
+        }
+
+        break;
+    }
+
 #ifdef VCPU_TRAP_NMI
     case VCPUOP_send_nmi:

if ( !guest_handle_is_null(arg) )

#4 lore raw

Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code

In reply to Stefano Stabellini

On Wed, 2013-05-01 at 20:32 +0100, Stefano Stabellini wrote:

I got conflicts apply this. I didn't look to see if they related to the problems applying the ARM guest SMP series or if it was some other change to the underlying tree.

Quoted 84 lines
---
 xen/arch/x86/domain.c |   28 ----------------------------
 xen/common/domain.c   |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 28 deletions(-)
xen/arch/x86/domain.c +0 -28
index d1b6c64..87dcb73 100644
@@ -960,34 +960,6 @@ arch_do_vcpu_op(
 
     switch ( cmd )
     {
-    case VCPUOP_register_runstate_memory_area:
-    {
-        struct vcpu_register_runstate_memory_area area;
-        struct vcpu_runstate_info runstate;
-
-        rc = -EFAULT;
-        if ( copy_from_guest(&area, arg, 1) )
-            break;
-
-        if ( !guest_handle_okay(area.addr.h, 1) )
-            break;
-
-        rc = 0;
-        runstate_guest(v) = area.addr.h;
-
-        if ( v == current )
-        {
-            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
-        }
-        else
-        {
-            vcpu_runstate_get(v, &runstate);
-            __copy_to_guest(runstate_guest(v), &runstate, 1);
-        }
-
-        break;
-    }
-
     /*
      * XXX Disable for 4.0.0: __update_vcpu_system_time() writes to the given
      * virtual address even when running in another domain's address space.
xen/common/domain.c +28 -0
index d21909f..0752dd2 100644
@@ -1126,6 +1126,34 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+    case VCPUOP_register_runstate_memory_area:
+    {
+        struct vcpu_register_runstate_memory_area area;
+        struct vcpu_runstate_info runstate;
+
+        rc = -EFAULT;
+        if ( copy_from_guest(&area, arg, 1) )
+            break;
+
+        if ( !guest_handle_okay(area.addr.h, 1) )
+            break;
+
+        rc = 0;
+        runstate_guest(v) = area.addr.h;
+
+        if ( v == current )
+        {
+            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
+        }
+        else
+        {
+            vcpu_runstate_get(v, &runstate);
+            __copy_to_guest(runstate_guest(v), &runstate, 1);
+        }
+
+        break;
+    }
+
 #ifdef VCPU_TRAP_NMI
     case VCPUOP_send_nmi:
         if ( !guest_handle_is_null(arg) )
#5 lore raw

Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code

I guess it needs to be applied on top of the guest SMP patch series because I don't get any conflicts.
Let me know if you are still having issues.

Quoted 93 lines · Ian Campbell

On Wed, 2013-05-01 at 20:32 +0100, Stefano Stabellini wrote:

I got conflicts apply this. I didn't look to see if they related to the problems applying the ARM guest SMP series or if it was some other change to the underlying tree.

Quoted 84 lines
---
 xen/arch/x86/domain.c |   28 ----------------------------
 xen/common/domain.c   |   28 ++++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 28 deletions(-)
xen/arch/x86/domain.c +0 -28
index d1b6c64..87dcb73 100644
@@ -960,34 +960,6 @@ arch_do_vcpu_op(
 
     switch ( cmd )
     {
-    case VCPUOP_register_runstate_memory_area:
-    {
-        struct vcpu_register_runstate_memory_area area;
-        struct vcpu_runstate_info runstate;
-
-        rc = -EFAULT;
-        if ( copy_from_guest(&area, arg, 1) )
-            break;
-
-        if ( !guest_handle_okay(area.addr.h, 1) )
-            break;
-
-        rc = 0;
-        runstate_guest(v) = area.addr.h;
-
-        if ( v == current )
-        {
-            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
-        }
-        else
-        {
-            vcpu_runstate_get(v, &runstate);
-            __copy_to_guest(runstate_guest(v), &runstate, 1);
-        }
-
-        break;
-    }
-
     /*
      * XXX Disable for 4.0.0: __update_vcpu_system_time() writes to the given
      * virtual address even when running in another domain's address space.
xen/common/domain.c +28 -0
index d21909f..0752dd2 100644
@@ -1126,6 +1126,34 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+    case VCPUOP_register_runstate_memory_area:
+    {
+        struct vcpu_register_runstate_memory_area area;
+        struct vcpu_runstate_info runstate;
+
+        rc = -EFAULT;
+        if ( copy_from_guest(&area, arg, 1) )
+            break;
+
+        if ( !guest_handle_okay(area.addr.h, 1) )
+            break;
+
+        rc = 0;
+        runstate_guest(v) = area.addr.h;
+
+        if ( v == current )
+        {
+            __copy_to_guest(runstate_guest(v), &v->runstate, 1);
+        }
+        else
+        {
+            vcpu_runstate_get(v, &runstate);
+            __copy_to_guest(runstate_guest(v), &runstate, 1);
+        }
+
+        break;
+    }
+
 #ifdef VCPU_TRAP_NMI
     case VCPUOP_send_nmi:
         if ( !guest_handle_is_null(arg) )
#6 lore raw

Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code

Quoted 3 lines · Stefano Stabellini

I guess it needs to be applied on top of the guest SMP patch series because I don't get any conflicts.
Let me know if you are still having issues.

It applied fine now that the SMP stuff is in. thanks.

Ian.

#7 lore raw

PATCH 2/2 xen/arm: handle the runstate_memory_area

In reply to Stefano Stabellini

Support VCPUOP_register_runstate_memory_area on ARM. Update_runstate_area on context switch.

---
 xen/arch/arm/domain.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
xen/arch/arm/domain.c +16 -6
index 2d018cf..40bf963 100644
@@ -22,6 +22,7 @@
 
 #include <asm/current.h>
 #include <asm/event.h>
+#include <asm/guest_access.h>
 #include <asm/regs.h>
 #include <asm/p2m.h>
 #include <asm/irq.h>
@@ -212,16 +213,25 @@ static void ctxt_switch_to(struct vcpu *n)
     virt_timer_restore(n);
 }
 
+/* Update per-VCPU guest runstate shared memory area (if registered). */
+static void update_runstate_area(struct vcpu *v)
+{
+    if ( guest_handle_is_null(runstate_guest(v)) )
+        return;
+
+    __copy_to_guest(runstate_guest(v), &v->runstate, 1);
+}
+
 static void schedule_tail(struct vcpu *prev)
 {
     ctxt_switch_from(prev);
 
     local_irq_enable();
 
-    /* TODO
-       update_runstate_area(current);
-    */
     ctxt_switch_to(current);
+
+    if ( prev != current )
+        update_runstate_area(current);
 }
 
 static void continue_new_vcpu(struct vcpu *prev)
@@ -241,9 +251,8 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
     ASSERT(prev != next);
     ASSERT(cpumask_empty(next->vcpu_dirty_cpumask));
 
-    /* TODO
-       update_runstate_area(prev);
-    */
+    if ( prev != next )
+        update_runstate_area(prev);
 
     local_irq_disable();
 
@@ -636,6 +645,7 @@ long do_arm_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
     switch ( cmd )
     {
         case VCPUOP_register_vcpu_info:
+        case VCPUOP_register_runstate_memory_area:
             return do_vcpu_op(cmd, vcpuid, arg);
         default:
             return -EINVAL;
Signature · 1 line
1.7.2.5