Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Xen: Devel

[PATCH 08/38] arm: allocate and setup a guest vcpu.

 

 

Xen devel RSS feed   Index | Next | Previous | View Threaded


ian.campbell at citrix

Jun 1, 2012, 8:39 AM

Post #1 of 6 (78 views)
Permalink
[PATCH 08/38] arm: allocate and setup a guest vcpu.

Signed-off-by: Ian Campbell <ian.campbell [at] citrix>
---
xen/arch/arm/domain.c | 68 +++++++++++++++++++++++++++++++++++++++++
xen/arch/arm/dummy.S | 3 --
xen/include/public/arch-arm.h | 9 -----
3 files changed, 68 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 9339a11..62a2f3a 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -144,6 +144,17 @@ void free_vcpu_struct(struct vcpu *v)
free_xenheap_page(v);
}

+struct vcpu_guest_context *alloc_vcpu_guest_context(void)
+{
+ return xmalloc(struct vcpu_guest_context);
+
+}
+
+void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
+{
+ xfree(vgc);
+}
+
int vcpu_initialise(struct vcpu *v)
{
int rc = 0;
@@ -182,6 +193,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
if ( (rc = p2m_init(d)) != 0 )
goto fail;

+ if ( (rc = domain_vgic_init(d)) != 0 )
+ goto fail;
+
if ( !is_idle_domain(d) )
{
rc = -ENOMEM;
@@ -212,6 +226,60 @@ void arch_domain_destroy(struct domain *d)
/* domain_vgic_destroy */
}

+static int is_guest_psr(uint32_t psr)
+{
+ switch (psr & PSR_MODE_MASK)
+ {
+ case PSR_MODE_USR:
+ case PSR_MODE_FIQ:
+ case PSR_MODE_IRQ:
+ case PSR_MODE_SVC:
+ case PSR_MODE_ABT:
+ case PSR_MODE_UND:
+ case PSR_MODE_SYS:
+ return 1;
+ case PSR_MODE_MON:
+ case PSR_MODE_HYP:
+ default:
+ return 0;
+ }
+}
+
+int arch_set_info_guest(
+ struct vcpu *v, vcpu_guest_context_u c)
+{
+ struct cpu_user_regs *regs = &c.nat->user_regs;
+
+ if ( !is_guest_psr(regs->cpsr) )
+ return -EINVAL;
+
+ if ( regs->spsr_svc && !is_guest_psr(regs->spsr_svc) )
+ return -EINVAL;
+ if ( regs->spsr_abt && !is_guest_psr(regs->spsr_abt) )
+ return -EINVAL;
+ if ( regs->spsr_und && !is_guest_psr(regs->spsr_und) )
+ return -EINVAL;
+ if ( regs->spsr_irq && !is_guest_psr(regs->spsr_irq) )
+ return -EINVAL;
+ if ( regs->spsr_fiq && !is_guest_psr(regs->spsr_fiq) )
+ return -EINVAL;
+
+ v->arch.cpu_info->guest_cpu_user_regs = *regs;
+
+ /* XXX other state:
+ * - SCTLR
+ * - TTBR0/1
+ * - TTBCR
+ */
+
+ //if ( flags & VGCF_online )
+ clear_bit(_VPF_down, &v->pause_flags);
+ //else
+ // set_bit(_VPF_down, &v->pause_flags);
+
+ return 0;
+}
+
void arch_dump_domain_info(struct domain *d)
{
}
diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S
index 016340c..3b48917 100644
--- a/xen/arch/arm/dummy.S
+++ b/xen/arch/arm/dummy.S
@@ -20,11 +20,8 @@ DUMMY(pirq_guest_unbind);
DUMMY(pirq_set_affinity);

/* VCPU */
-DUMMY(alloc_vcpu_guest_context);
DUMMY(arch_get_info_guest);
-DUMMY(arch_set_info_guest);
DUMMY(arch_vcpu_reset);
-DUMMY(free_vcpu_guest_context);
DUMMY(sync_vcpu_execstate);
NOP(update_vcpu_system_time);
DUMMY(vcpu_show_execution_state);
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 1b1bcf3..e439727 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -124,15 +124,6 @@ typedef uint32_t xen_ulong_t;

struct vcpu_guest_context {
struct cpu_user_regs user_regs; /* User-level CPU registers */
- union {
- uint32_t reg[16];
- struct {
- uint32_t __pad[12];
- uint32_t sp; /* r13 */
- uint32_t lr; /* r14 */
- uint32_t pc; /* r15 */
- };
- };
};
typedef struct vcpu_guest_context vcpu_guest_context_t;
DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
--
1.7.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel


stefano.stabellini at eu

Jun 6, 2012, 6:46 AM

Post #2 of 6 (81 views)
Permalink
Re: [PATCH 08/38] arm: allocate and setup a guest vcpu. [In reply to]

On Fri, 1 Jun 2012, Ian Campbell wrote:
> Signed-off-by: Ian Campbell <ian.campbell [at] citrix>
> ---
> xen/arch/arm/domain.c | 68 +++++++++++++++++++++++++++++++++++++++++
> xen/arch/arm/dummy.S | 3 --
> xen/include/public/arch-arm.h | 9 -----
> 3 files changed, 68 insertions(+), 12 deletions(-)
>
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 9339a11..62a2f3a 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -144,6 +144,17 @@ void free_vcpu_struct(struct vcpu *v)
> free_xenheap_page(v);
> }
>
> +struct vcpu_guest_context *alloc_vcpu_guest_context(void)
> +{
> + return xmalloc(struct vcpu_guest_context);
> +
> +}
> +
> +void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
> +{
> + xfree(vgc);
> +}
> +
> int vcpu_initialise(struct vcpu *v)
> {
> int rc = 0;
> @@ -182,6 +193,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
> if ( (rc = p2m_init(d)) != 0 )
> goto fail;
>
> + if ( (rc = domain_vgic_init(d)) != 0 )
> + goto fail;
> +

there is a call to domain_vgic_init already in arch_domain_create


> if ( !is_idle_domain(d) )
> {
> rc = -ENOMEM;
> @@ -212,6 +226,60 @@ void arch_domain_destroy(struct domain *d)
> /* domain_vgic_destroy */
> }
>
> +static int is_guest_psr(uint32_t psr)
> +{
> + switch (psr & PSR_MODE_MASK)
> + {
> + case PSR_MODE_USR:
> + case PSR_MODE_FIQ:
> + case PSR_MODE_IRQ:
> + case PSR_MODE_SVC:
> + case PSR_MODE_ABT:
> + case PSR_MODE_UND:
> + case PSR_MODE_SYS:
> + return 1;
> + case PSR_MODE_MON:
> + case PSR_MODE_HYP:
> + default:
> + return 0;
> + }
> +}
> +
> +int arch_set_info_guest(
> + struct vcpu *v, vcpu_guest_context_u c)
> +{
> + struct cpu_user_regs *regs = &c.nat->user_regs;
> +
> + if ( !is_guest_psr(regs->cpsr) )
> + return -EINVAL;
> +
> + if ( regs->spsr_svc && !is_guest_psr(regs->spsr_svc) )
> + return -EINVAL;
> + if ( regs->spsr_abt && !is_guest_psr(regs->spsr_abt) )
> + return -EINVAL;
> + if ( regs->spsr_und && !is_guest_psr(regs->spsr_und) )
> + return -EINVAL;
> + if ( regs->spsr_irq && !is_guest_psr(regs->spsr_irq) )
> + return -EINVAL;
> + if ( regs->spsr_fiq && !is_guest_psr(regs->spsr_fiq) )
> + return -EINVAL;
> +
> + v->arch.cpu_info->guest_cpu_user_regs = *regs;
> +
> + /* XXX other state:
> + * - SCTLR
> + * - TTBR0/1
> + * - TTBCR
> + */
> +
> + //if ( flags & VGCF_online )
> + clear_bit(_VPF_down, &v->pause_flags);
> + //else
> + // set_bit(_VPF_down, &v->pause_flags);
> +
> + return 0;
> +}

Do we really need to add commented out code like this?
Also arch_set_info_guest could benefit by a couple of lines of comments
to explain what it is supposed to do.


> void arch_dump_domain_info(struct domain *d)
> {
> }
> diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S
> index 016340c..3b48917 100644
> --- a/xen/arch/arm/dummy.S
> +++ b/xen/arch/arm/dummy.S
> @@ -20,11 +20,8 @@ DUMMY(pirq_guest_unbind);
> DUMMY(pirq_set_affinity);
>
> /* VCPU */
> -DUMMY(alloc_vcpu_guest_context);
> DUMMY(arch_get_info_guest);
> -DUMMY(arch_set_info_guest);
> DUMMY(arch_vcpu_reset);
> -DUMMY(free_vcpu_guest_context);
> DUMMY(sync_vcpu_execstate);
> NOP(update_vcpu_system_time);
> DUMMY(vcpu_show_execution_state);
> diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
> index 1b1bcf3..e439727 100644
> --- a/xen/include/public/arch-arm.h
> +++ b/xen/include/public/arch-arm.h
> @@ -124,15 +124,6 @@ typedef uint32_t xen_ulong_t;
>
> struct vcpu_guest_context {
> struct cpu_user_regs user_regs; /* User-level CPU registers */
> - union {
> - uint32_t reg[16];
> - struct {
> - uint32_t __pad[12];
> - uint32_t sp; /* r13 */
> - uint32_t lr; /* r14 */
> - uint32_t pc; /* r15 */
> - };
> - };
> };
> typedef struct vcpu_guest_context vcpu_guest_context_t;
> DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
> --
> 1.7.9.1
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel [at] lists
> http://lists.xen.org/xen-devel
>

_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel


Ian.Campbell at citrix

Jun 6, 2012, 6:55 AM

Post #3 of 6 (81 views)
Permalink
Re: [PATCH 08/38] arm: allocate and setup a guest vcpu. [In reply to]

On Wed, 2012-06-06 at 14:46 +0100, Stefano Stabellini wrote:
> On Fri, 1 Jun 2012, Ian Campbell wrote:
> > Signed-off-by: Ian Campbell <ian.campbell [at] citrix>
> > ---
> > xen/arch/arm/domain.c | 68 +++++++++++++++++++++++++++++++++++++++++
> > xen/arch/arm/dummy.S | 3 --
> > xen/include/public/arch-arm.h | 9 -----
> > 3 files changed, 68 insertions(+), 12 deletions(-)
> >
> > diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> > index 9339a11..62a2f3a 100644
> > --- a/xen/arch/arm/domain.c
> > +++ b/xen/arch/arm/domain.c
> > @@ -144,6 +144,17 @@ void free_vcpu_struct(struct vcpu *v)
> > free_xenheap_page(v);
> > }
> >
> > +struct vcpu_guest_context *alloc_vcpu_guest_context(void)
> > +{
> > + return xmalloc(struct vcpu_guest_context);
> > +
> > +}
> > +
> > +void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
> > +{
> > + xfree(vgc);
> > +}
> > +
> > int vcpu_initialise(struct vcpu *v)
> > {
> > int rc = 0;
> > @@ -182,6 +193,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
> > if ( (rc = p2m_init(d)) != 0 )
> > goto fail;
> >
> > + if ( (rc = domain_vgic_init(d)) != 0 )
> > + goto fail;
> > +
>
> there is a call to domain_vgic_init already in arch_domain_create

So there is!

I notice while checking that a bunch of stuff can/should be pushed under
the !idle_domain conditional, or better the idle domain case should bail
early.

> > +int arch_set_info_guest(
> > + struct vcpu *v, vcpu_guest_context_u c)
> > +{
> > + struct cpu_user_regs *regs = &c.nat->user_regs;
> > +
> > + if ( !is_guest_psr(regs->cpsr) )
> > + return -EINVAL;
> > +
> > + if ( regs->spsr_svc && !is_guest_psr(regs->spsr_svc) )
> > + return -EINVAL;
> > + if ( regs->spsr_abt && !is_guest_psr(regs->spsr_abt) )
> > + return -EINVAL;
> > + if ( regs->spsr_und && !is_guest_psr(regs->spsr_und) )
> > + return -EINVAL;
> > + if ( regs->spsr_irq && !is_guest_psr(regs->spsr_irq) )
> > + return -EINVAL;
> > + if ( regs->spsr_fiq && !is_guest_psr(regs->spsr_fiq) )
> > + return -EINVAL;
> > +
> > + v->arch.cpu_info->guest_cpu_user_regs = *regs;
> > +
> > + /* XXX other state:
> > + * - SCTLR
> > + * - TTBR0/1
> > + * - TTBCR
> > + */
> > +
> > + //if ( flags & VGCF_online )
> > + clear_bit(_VPF_down, &v->pause_flags);
> > + //else
> > + // set_bit(_VPF_down, &v->pause_flags);
> > +
> > + return 0;
> > +}
>
> Do we really need to add commented out code like this?

Yeah, you're right, I copied from x86 which has this but we haven't
implemented it for ARM yet. I suppose an XXX would be better. Or maybe I
should just implement the flags...

> Also arch_set_info_guest could benefit by a couple of lines of comments
> to explain what it is supposed to do.

I'll add something.



_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel


Ian.Campbell at citrix

Jun 7, 2012, 2:40 AM

Post #4 of 6 (80 views)
Permalink
Re: [PATCH 08/38] arm: allocate and setup a guest vcpu. [In reply to]

On Wed, 2012-06-06 at 14:55 +0100, Ian Campbell wrote:
> On Wed, 2012-06-06 at 14:46 +0100, Stefano Stabellini wrote:
> > On Fri, 1 Jun 2012, Ian Campbell wrote:
> > > Signed-off-by: Ian Campbell <ian.campbell [at] citrix>
> > > ---
> > > xen/arch/arm/domain.c | 68 +++++++++++++++++++++++++++++++++++++++++
> > > xen/arch/arm/dummy.S | 3 --
> > > xen/include/public/arch-arm.h | 9 -----
> > > 3 files changed, 68 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> > > index 9339a11..62a2f3a 100644
> > > --- a/xen/arch/arm/domain.c
> > > +++ b/xen/arch/arm/domain.c
> > > @@ -144,6 +144,17 @@ void free_vcpu_struct(struct vcpu *v)
> > > free_xenheap_page(v);
> > > }
> > >
> > > +struct vcpu_guest_context *alloc_vcpu_guest_context(void)
> > > +{
> > > + return xmalloc(struct vcpu_guest_context);
> > > +
> > > +}
> > > +
> > > +void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
> > > +{
> > > + xfree(vgc);
> > > +}
> > > +
> > > int vcpu_initialise(struct vcpu *v)
> > > {
> > > int rc = 0;
> > > @@ -182,6 +193,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
> > > if ( (rc = p2m_init(d)) != 0 )
> > > goto fail;
> > >
> > > + if ( (rc = domain_vgic_init(d)) != 0 )
> > > + goto fail;
> > > +
> >
> > there is a call to domain_vgic_init already in arch_domain_create
>
> So there is!

Rather inexplicably removing either one of those two domain_vgic_init
calls causes:
(XEN) Unexpected Trap: Data Abort
(XEN) ----[ Xen-4.2-unstable x86_64 debug=y Not tainted ]----
(XEN) CPU: 0
(XEN) PC: 00222e7c _spin_lock+0x28/0x6c
(XEN) CPSR: 600001da MODE:HYP
(XEN) R0: 002c4389 R1: 800001da R2: 00000001 R3: 0000ffff
(XEN) R4: 002c4381 R5: 00000080 R6: 002c4380 R7: 002c4000
(XEN) R8: 002c4380 R9: 4000015a R10:00000080 R11:40017d6c R12:00000000
(XEN) SP: 40017d5c LR: 00222e68
(XEN)
(XEN) HTTBR ffec1000
(XEN) HDFAR 2c4381
(XEN) HIFAR 0
(XEN) HPFAR 0
(XEN) HCR 00000835
(XEN) HSR 94000021
(XEN)
(XEN) DFSR 817 DFAR 134bc
(XEN) IFSR 7 IFAR 4024c224
(XEN)
(XEN) Xen stack trace from sp=40017d5c:
[...]
(XEN) Xen call trace:
(XEN) [<00222e7c>] _spin_lock+0x28/0x6c
(XEN) [<00226270>] init_timer+0xbc/0x160
(XEN) [<0021fc14>] sched_init_vcpu+0x94/0x200
(XEN) [<002061a4>] alloc_vcpu+0x124/0x210
(XEN) [<00204890>] do_domctl+0xaa4/0x14e4
(XEN) [<00241aec>] do_trap_hypervisor+0x588/0x8cc
(XEN) [<0023bbf0>] return_from_trap+0x0/0x4

I'm totally at a loss to explain that. domain_vgic_init allocates two
arrays so it is possible we have some sort of overrun error, although I
can't for the life of me see it in there (it could be elsewhere though).

As an experiment I tried doubling the size of both allocations in that
function (and calling it once) but that didn't help so no hints from
that...

More head scratching required I think!

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel


Ian.Campbell at citrix

Jun 7, 2012, 10:02 AM

Post #5 of 6 (71 views)
Permalink
Re: [PATCH 08/38] arm: allocate and setup a guest vcpu. [In reply to]

On Thu, 2012-06-07 at 10:40 +0100, Ian Campbell wrote:
> More head scratching required I think!

This turned out to be the problem with not initialising cpu_sibling_mask
properly, see the thread against "[PATCH 16/38] arm: Add simple
cpu_{sibling,core}_mask".

Having fixed that I updated based on your comments to:

8<-----------------------------------------------------------

From 75cff29f4645dd19d07175109b5891fd44de9d60 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell [at] citrix>
Date: Fri, 13 Apr 2012 16:07:21 +0100
Subject: [PATCH] arm: allocate and setup a guest vcpu.

Signed-off-by: Ian Campbell <ian.campbell [at] citrix>
---
xen/arch/arm/domain.c | 67 +++++++++++++++++++++++++++++++++++++++++
xen/arch/arm/dummy.S | 3 --
xen/include/public/arch-arm.h | 9 -----
3 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 9339a11..b099d91 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -144,6 +144,17 @@ void free_vcpu_struct(struct vcpu *v)
free_xenheap_page(v);
}

+struct vcpu_guest_context *alloc_vcpu_guest_context(void)
+{
+ return xmalloc(struct vcpu_guest_context);
+
+}
+
+void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
+{
+ xfree(vgc);
+}
+
int vcpu_initialise(struct vcpu *v)
{
int rc = 0;
@@ -212,6 +223,62 @@ void arch_domain_destroy(struct domain *d)
/* domain_vgic_destroy */
}

+static int is_guest_psr(uint32_t psr)
+{
+ switch (psr & PSR_MODE_MASK)
+ {
+ case PSR_MODE_USR:
+ case PSR_MODE_FIQ:
+ case PSR_MODE_IRQ:
+ case PSR_MODE_SVC:
+ case PSR_MODE_ABT:
+ case PSR_MODE_UND:
+ case PSR_MODE_SYS:
+ return 1;
+ case PSR_MODE_MON:
+ case PSR_MODE_HYP:
+ default:
+ return 0;
+ }
+}
+
+/*
+ * Initialise VCPU state. The context can be supplied by either the
+ * toolstack (XEN_DOMCTL_setvcpucontext) or the guest
+ * (VCPUOP_initialise) and therefore must be properly validated.
+ */
+int arch_set_info_guest(
+ struct vcpu *v, vcpu_guest_context_u c)
+{
+ struct cpu_user_regs *regs = &c.nat->user_regs;
+
+ if ( !is_guest_psr(regs->cpsr) )
+ return -EINVAL;
+
+ if ( regs->spsr_svc && !is_guest_psr(regs->spsr_svc) )
+ return -EINVAL;
+ if ( regs->spsr_abt && !is_guest_psr(regs->spsr_abt) )
+ return -EINVAL;
+ if ( regs->spsr_und && !is_guest_psr(regs->spsr_und) )
+ return -EINVAL;
+ if ( regs->spsr_irq && !is_guest_psr(regs->spsr_irq) )
+ return -EINVAL;
+ if ( regs->spsr_fiq && !is_guest_psr(regs->spsr_fiq) )
+ return -EINVAL;
+
+ v->arch.cpu_info->guest_cpu_user_regs = *regs;
+
+ /* XXX other state:
+ * - SCTLR
+ * - TTBR0/1
+ * - TTBCR
+ */
+
+ clear_bit(_VPF_down, &v->pause_flags);
+
+ return 0;
+}
+
void arch_dump_domain_info(struct domain *d)
{
}
diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S
index 016340c..3b48917 100644
--- a/xen/arch/arm/dummy.S
+++ b/xen/arch/arm/dummy.S
@@ -20,11 +20,8 @@ DUMMY(pirq_guest_unbind);
DUMMY(pirq_set_affinity);

/* VCPU */
-DUMMY(alloc_vcpu_guest_context);
DUMMY(arch_get_info_guest);
-DUMMY(arch_set_info_guest);
DUMMY(arch_vcpu_reset);
-DUMMY(free_vcpu_guest_context);
DUMMY(sync_vcpu_execstate);
NOP(update_vcpu_system_time);
DUMMY(vcpu_show_execution_state);
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 1b1bcf3..e439727 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -124,15 +124,6 @@ typedef uint32_t xen_ulong_t;

struct vcpu_guest_context {
struct cpu_user_regs user_regs; /* User-level CPU registers */
- union {
- uint32_t reg[16];
- struct {
- uint32_t __pad[12];
- uint32_t sp; /* r13 */
- uint32_t lr; /* r14 */
- uint32_t pc; /* r15 */
- };
- };
};
typedef struct vcpu_guest_context vcpu_guest_context_t;
DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
--
1.7.9.1




_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel


stefano.stabellini at eu

Jun 8, 2012, 3:00 AM

Post #6 of 6 (73 views)
Permalink
Re: [PATCH 08/38] arm: allocate and setup a guest vcpu. [In reply to]

On Thu, 7 Jun 2012, Ian Campbell wrote:
> On Thu, 2012-06-07 at 10:40 +0100, Ian Campbell wrote:
> > More head scratching required I think!
>
> This turned out to be the problem with not initialising cpu_sibling_mask
> properly, see the thread against "[PATCH 16/38] arm: Add simple
> cpu_{sibling,core}_mask".
>
> Having fixed that I updated based on your comments to:
>
> 8<-----------------------------------------------------------
>
> From 75cff29f4645dd19d07175109b5891fd44de9d60 Mon Sep 17 00:00:00 2001
> From: Ian Campbell <ian.campbell [at] citrix>
> Date: Fri, 13 Apr 2012 16:07:21 +0100
> Subject: [PATCH] arm: allocate and setup a guest vcpu.
>
> Signed-off-by: Ian Campbell <ian.campbell [at] citrix>

It looks OK now.


Acked-by: Stefano Stabellini <stefano.stabellini [at] eu>


> xen/arch/arm/domain.c | 67 +++++++++++++++++++++++++++++++++++++++++
> xen/arch/arm/dummy.S | 3 --
> xen/include/public/arch-arm.h | 9 -----
> 3 files changed, 67 insertions(+), 12 deletions(-)
>
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 9339a11..b099d91 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -144,6 +144,17 @@ void free_vcpu_struct(struct vcpu *v)
> free_xenheap_page(v);
> }
>
> +struct vcpu_guest_context *alloc_vcpu_guest_context(void)
> +{
> + return xmalloc(struct vcpu_guest_context);
> +
> +}
> +
> +void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
> +{
> + xfree(vgc);
> +}
> +
> int vcpu_initialise(struct vcpu *v)
> {
> int rc = 0;
> @@ -212,6 +223,62 @@ void arch_domain_destroy(struct domain *d)
> /* domain_vgic_destroy */
> }
>
> +static int is_guest_psr(uint32_t psr)
> +{
> + switch (psr & PSR_MODE_MASK)
> + {
> + case PSR_MODE_USR:
> + case PSR_MODE_FIQ:
> + case PSR_MODE_IRQ:
> + case PSR_MODE_SVC:
> + case PSR_MODE_ABT:
> + case PSR_MODE_UND:
> + case PSR_MODE_SYS:
> + return 1;
> + case PSR_MODE_MON:
> + case PSR_MODE_HYP:
> + default:
> + return 0;
> + }
> +}
> +
> +/*
> + * Initialise VCPU state. The context can be supplied by either the
> + * toolstack (XEN_DOMCTL_setvcpucontext) or the guest
> + * (VCPUOP_initialise) and therefore must be properly validated.
> + */
> +int arch_set_info_guest(
> + struct vcpu *v, vcpu_guest_context_u c)
> +{
> + struct cpu_user_regs *regs = &c.nat->user_regs;
> +
> + if ( !is_guest_psr(regs->cpsr) )
> + return -EINVAL;
> +
> + if ( regs->spsr_svc && !is_guest_psr(regs->spsr_svc) )
> + return -EINVAL;
> + if ( regs->spsr_abt && !is_guest_psr(regs->spsr_abt) )
> + return -EINVAL;
> + if ( regs->spsr_und && !is_guest_psr(regs->spsr_und) )
> + return -EINVAL;
> + if ( regs->spsr_irq && !is_guest_psr(regs->spsr_irq) )
> + return -EINVAL;
> + if ( regs->spsr_fiq && !is_guest_psr(regs->spsr_fiq) )
> + return -EINVAL;
> +
> + v->arch.cpu_info->guest_cpu_user_regs = *regs;
> +
> + /* XXX other state:
> + * - SCTLR
> + * - TTBR0/1
> + * - TTBCR
> + */
> +
> + clear_bit(_VPF_down, &v->pause_flags);
> +
> + return 0;
> +}
> +
> void arch_dump_domain_info(struct domain *d)
> {
> }
> diff --git a/xen/arch/arm/dummy.S b/xen/arch/arm/dummy.S
> index 016340c..3b48917 100644
> --- a/xen/arch/arm/dummy.S
> +++ b/xen/arch/arm/dummy.S
> @@ -20,11 +20,8 @@ DUMMY(pirq_guest_unbind);
> DUMMY(pirq_set_affinity);
>
> /* VCPU */
> -DUMMY(alloc_vcpu_guest_context);
> DUMMY(arch_get_info_guest);
> -DUMMY(arch_set_info_guest);
> DUMMY(arch_vcpu_reset);
> -DUMMY(free_vcpu_guest_context);
> DUMMY(sync_vcpu_execstate);
> NOP(update_vcpu_system_time);
> DUMMY(vcpu_show_execution_state);
> diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
> index 1b1bcf3..e439727 100644
> --- a/xen/include/public/arch-arm.h
> +++ b/xen/include/public/arch-arm.h
> @@ -124,15 +124,6 @@ typedef uint32_t xen_ulong_t;
>
> struct vcpu_guest_context {
> struct cpu_user_regs user_regs; /* User-level CPU registers */
> - union {
> - uint32_t reg[16];
> - struct {
> - uint32_t __pad[12];
> - uint32_t sp; /* r13 */
> - uint32_t lr; /* r14 */
> - uint32_t pc; /* r15 */
> - };
> - };
> };
> typedef struct vcpu_guest_context vcpu_guest_context_t;
> DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
> --
> 1.7.9.1
>
>
>
>

_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel

Xen devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.