From: Ian Campbell Subject: Re: [PATCH RFC 13/15] libxc: arm64 vcpu initialisation Date: Thu, 10 Oct 2013 16:59:49 +0100 Message-ID: <1381420789.17758.51.camel@kazak.uk.xensource.com> References: <1381163944.21562.129.camel@kazak.uk.xensource.com> <1381164001-1446-13-git-send-email-ian.campbell@citrix.com> <5256CDBA.5000902@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5256CDBA.5000902@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: stefano.stabellini@eu.citrix.com, tim@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, 2013-10-10 at 16:54 +0100, Julien Grall wrote: > On 10/07/2013 05:39 PM, Ian Campbell wrote: > > Signed-off-by: Ian Campbell > > --- > > tools/libxc/xc_dom_arm.c | 90 ++++++++++++++++++++++++++++++++++++++++++++-- > > 1 file changed, 88 insertions(+), 2 deletions(-) > > > > diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c > > index ecdaea9..a6d2259 100644 > > --- a/tools/libxc/xc_dom_arm.c > > +++ b/tools/libxc/xc_dom_arm.c > > @@ -105,7 +105,7 @@ static int shared_info_arm(struct xc_dom_image *dom, void *ptr) > > > > /* ------------------------------------------------------------------------ */ > > > > -static int vcpu_arm(struct xc_dom_image *dom, void *ptr) > > +static int vcpu_arm32(struct xc_dom_image *dom, void *ptr) > > { > > vcpu_guest_context_t *ctxt = ptr; > > > > @@ -143,6 +143,41 @@ static int vcpu_arm(struct xc_dom_image *dom, void *ptr) > > return 0; > > } > > > > +static int vcpu_arm64(struct xc_dom_image *dom, void *ptr) > > +{ > > + vcpu_guest_context_t *ctxt = ptr; > > + > > + DOMPRINTF_CALLED(dom->xch); > > + /* clear everything */ > > + memset(ctxt, 0, sizeof(*ctxt)); > > + > > + ctxt->user_regs.pc64 = dom->parms.virt_entry; > > + > > + /* Linux boot protocol. See linux.Documentation/arm/Booting. */ > > + ctxt->user_regs.x0 = dom->devicetree_blob ? > > + dom->devicetree_seg.vstart : 0xffffffff; > > + ctxt->user_regs.x1 = 0; > > + ctxt->user_regs.x2 = 0; > > + ctxt->user_regs.x3 = 0; > > + > > + DOMPRINTF("DTB %"PRIx64, ctxt->user_regs.x0); > > + > > + ctxt->sctlr = /* #define SCTLR_BASE */0x00c50078; > > + > > + ctxt->ttbr0 = 0; > > + ctxt->ttbr1 = 0; > > + ctxt->ttbcr = 0; /* Defined Reset Value */ > > + > > + ctxt->user_regs.cpsr = PSR_ABT_MASK|PSR_FIQ_MASK|PSR_IRQ_MASK|PSR_MODE_EL1h; > > PSR_MODE_EL1h is only defined on arm64. I think you will need to prefix > all the code by #ifdef __aarch64__ Correct. > BTW, can you use PSR_GUEST64_INIT here? So if we modified it in Xen, the > behaviour will also change here. It's a bit annoying, but PSR_GUEST*_INIT are no in the public interfaces and libxc can't include anything else. I don't want to expose this to guests incase it becomes ABI... Oh, maybe I can just us #if on __XEN_TOOLS__ and/or __XEN__ as appropaite. I'll have a play with that.