From: Ian Campbell <ian.campbell@citrix.com>
To: Julien Grall <julien.grall@citrix.com>, xen-devel@lists.xenproject.org
Cc: Marc Zyngier <Marc.Zyngier@arm.com>, stefano.stabellini@eu.citrix.com
Subject: Re: [PATCH 4/4] xen/arm64: Emulate correctly the register {w, x}zr
Date: Tue, 15 Dec 2015 11:51:57 +0000 [thread overview]
Message-ID: <1450180317.16856.144.camel@citrix.com> (raw)
In-Reply-To: <566FFC56.8010007@citrix.com>
On Tue, 2015-12-15 at 11:41 +0000, Julien Grall wrote:
> Hi Ian,
Thanks for the replies, I think mostly adding the further exposition from
this thread to the commit message would make this patch OK.
>
> On 15/12/15 11:10, Ian Campbell wrote:
> > On Fri, 2015-12-11 at 15:28 +0000, Julien Grall wrote:
> > > On AArch64, the encoding 31 could be used to represent {x,w}sp or
> > > {x,w}zr (See C1.2.4 in ARM DDI 0486A.d). The choice will depend how
> > > the
> > > register field is interpreted by the instruction.
> > >
> > > All the instructions trapped by Xen (either via a sysreg access or
> > > data
> > > abort) interprets the encoding 31 as zr. Therefore we don't have to
> > > worry about decoding the instruction.
> >
> > Is decoding the only way we could tell? i.e. there's no indication in
> > the
> > syndrome reg?
>
> Unfortunately yes, the syndrome reg will only contain the encoding of
> the transferred register.
>
> However, by looking to the list of instruction that could be trapped by
> Xen and contain valid ISS, the encoding 31 will always mean zr.
Great.
> > Is there no way a data abort could result from an access which involved
> > SP
> > rather than XZ? e.g. if the OS was to (stupidly) point SP at an MMIO
> > area
> > and then try a stp x0, x1, [sp] for example? Ah, perhaps in that case
> > we
> > would get a trap with x0 or x1 but sp would be in the FAR and not in
> > the
> > HSR?
>
> First if the instruction stp trap into Xen, the ISS would be invalid.
>
> For AArch64, only loads and store of a single general-purpose register
> would result to a valid ISS (see D7-1880 in ARM DDI 0487A.d).
>
> If we take an instruction producing a valid ISS:
>
> ldr x0, [x2]
> str x0, [x2]
>
> The ISS will always contains the transfered register, i.e x0 here. The
> faulting address (x2) will be in FAR.
Great. And the SP can only appear as the [sp] slot, so ldr x0 [sp] but
never ldr sp [x0], so that's ok for us too.
>
> > Or maybe a less lunatic case, could xenaccess not result in a faulting
> > stack access? I suppose the answer there is that xenaccess faults are
> > handled without actually caring which register it was and then the
> > instruction is replayed in guest context?
>
> xenaccess can't rely on the instruction syndrome because the fault may
> happen with instruction producing invalid ISS.
Right, this was my theory too.
> > What happens if an aarch32 guest accesses r15 in one of these ways on an
> > aarch64 hypervisor? Is it verboten in ARM v8 or something else? E1.2.3
> > describes it as deprecated, but not forbidden, but I suspect that "and the
> > source address of the ldr is in MMIO space" is not covered there or
> > something.
>
> Based on the description of the ISS encoding for data abort, the
> syndrome would be invalid.
>
> Our data abort handler will inject a data abort to the guest for any
> invalid instruction.
>
> If we ever want to support the guest to write pc in an emulated MMIO, we
> would have to decode the instruction.
I doubt we would want to, but so long as the worst which can happen is that
we kill the guest (rather than the host) then I'm happy.
> > Alternatively we could return NULL here to represent XZR and handle that
> > appropriately in the {get,set}_user_reg, replacing the check for reg == 31 in both places.
>
> I would rather avoid select_user_regs to return NULL. The explicit
> encoding check in {get,set}_user_reg is better.
OK.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-12-15 11:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-11 15:28 [PATCH 0/4] xen/arm64: Emulate correctly the register {w, x}zr Julien Grall
2015-12-11 15:28 ` [PATCH 1/4] xen/arm: io: handle_read: Use a local variable to store dabt Julien Grall
2015-12-15 10:27 ` Ian Campbell
2015-12-11 15:28 ` [PATCH 2/4] xen/arm64: Document the register mapping aarch64 <-> aarch32 Julien Grall
2015-12-15 10:33 ` Ian Campbell
2015-12-11 15:28 ` [PATCH 3/4] xen/arm: vtimer: Introduce vtimer_emulate_sysreg{32, 64} Julien Grall
2015-12-15 10:38 ` Ian Campbell
2015-12-15 10:55 ` Julien Grall
2015-12-11 15:28 ` [PATCH 4/4] xen/arm64: Emulate correctly the register {w, x}zr Julien Grall
2015-12-15 11:10 ` Ian Campbell
2015-12-15 11:41 ` Julien Grall
2015-12-15 11:51 ` Ian Campbell [this message]
2015-12-17 17:17 ` [PATCH 0/4] " Julien Grall
2015-12-17 17:36 ` Ian Campbell
2016-01-05 14:54 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450180317.16856.144.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=Marc.Zyngier@arm.com \
--cc=julien.grall@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.