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
Stefano Stabellini
2013-May-01 19:32 UTC
[PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
xen/arch/x86/domain.c | 28 ----------------------------
xen/common/domain.c | 28 ++++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index d1b6c64..87dcb73 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -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.
diff --git a/xen/common/domain.c b/xen/common/domain.c
index d21909f..0752dd2 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -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) )
--
1.7.2.5
Stefano Stabellini
2013-May-01 19:32 UTC
[PATCH 2/2] xen/arm: handle the runstate_memory_area
Support VCPUOP_register_runstate_memory_area on ARM.
Update_runstate_area on context switch.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
xen/arch/arm/domain.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 2d018cf..40bf963 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -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;
--
1.7.2.5
Ian Campbell
2013-May-02 08:05 UTC
Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code
On Wed, 2013-05-01 at 20:32 +0100, Stefano Stabellini wrote:> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>Needs x86 and/or core acks, but lacks suitable CCs. Added.> --- > xen/arch/x86/domain.c | 28 ---------------------------- > xen/common/domain.c | 28 ++++++++++++++++++++++++++++ > 2 files changed, 28 insertions(+), 28 deletions(-) > > diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c > index d1b6c64..87dcb73 100644 > --- a/xen/arch/x86/domain.c > +++ b/xen/arch/x86/domain.c > @@ -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. > diff --git a/xen/common/domain.c b/xen/common/domain.c > index d21909f..0752dd2 100644 > --- a/xen/common/domain.c > +++ b/xen/common/domain.c > @@ -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) )
Ian Campbell
2013-May-02 08:07 UTC
Re: [PATCH 2/2] xen/arm: handle the runstate_memory_area
On Wed, 2013-05-01 at 20:32 +0100, Stefano Stabellini wrote:> Support VCPUOP_register_runstate_memory_area on ARM. > Update_runstate_area on context switch. > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>Acked-by: Ian Campbell <ian.campbell@citrix.com>
Keir Fraser
2013-May-02 08:27 UTC
Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code
On 02/05/2013 09:05, "Ian Campbell" <Ian.Campbell@citrix.com> wrote:> On Wed, 2013-05-01 at 20:32 +0100, Stefano Stabellini wrote: >> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > Needs x86 and/or core acks, but lacks suitable CCs. Added.Acked-by: Keir Fraser <keir@xen.org>>> --- >> xen/arch/x86/domain.c | 28 ---------------------------- >> xen/common/domain.c | 28 ++++++++++++++++++++++++++++ >> 2 files changed, 28 insertions(+), 28 deletions(-) >> >> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c >> index d1b6c64..87dcb73 100644 >> --- a/xen/arch/x86/domain.c >> +++ b/xen/arch/x86/domain.c >> @@ -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. >> diff --git a/xen/common/domain.c b/xen/common/domain.c >> index d21909f..0752dd2 100644 >> --- a/xen/common/domain.c >> +++ b/xen/common/domain.c >> @@ -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) ) > >
Ian Campbell
2013-May-08 09:59 UTC
Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code
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.> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > --- > xen/arch/x86/domain.c | 28 ---------------------------- > xen/common/domain.c | 28 ++++++++++++++++++++++++++++ > 2 files changed, 28 insertions(+), 28 deletions(-) > > diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c > index d1b6c64..87dcb73 100644 > --- a/xen/arch/x86/domain.c > +++ b/xen/arch/x86/domain.c > @@ -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. > diff --git a/xen/common/domain.c b/xen/common/domain.c > index d21909f..0752dd2 100644 > --- a/xen/common/domain.c > +++ b/xen/common/domain.c > @@ -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) )
Stefano Stabellini
2013-May-08 11:43 UTC
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. On Wed, 8 May 2013, Ian Campbell wrote:> 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. > > > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > --- > > xen/arch/x86/domain.c | 28 ---------------------------- > > xen/common/domain.c | 28 ++++++++++++++++++++++++++++ > > 2 files changed, 28 insertions(+), 28 deletions(-) > > > > diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c > > index d1b6c64..87dcb73 100644 > > --- a/xen/arch/x86/domain.c > > +++ b/xen/arch/x86/domain.c > > @@ -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. > > diff --git a/xen/common/domain.c b/xen/common/domain.c > > index d21909f..0752dd2 100644 > > --- a/xen/common/domain.c > > +++ b/xen/common/domain.c > > @@ -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) ) > > >
Ian Campbell
2013-May-08 12:30 UTC
Re: [PATCH 1/2] xen: move VCPUOP_register_runstate_memory_area to common code
On Wed, 2013-05-08 at 12:43 +0100, Stefano Stabellini wrote:> 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.
Reasonably Related Threads
- [PATCH 0/4] Add V4V to Xen (v6)
- [PATCH v2 2/4] xen/arm: do not use is_running to decide whether we can write directly to the LR registers
- Bug#861660: Xen package security updates for jessie 4.4, XSA-213, XSA-214
- [PATCH v2 0/5] ARM hypercall ABI: 64 bit ready
- [PATCH v3 0/6] ARM hypercall ABI: 64 bit ready