linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 09/19] arm64: KVM: Handle async aborts delivered while at EL2
Date: Wed, 7 Sep 2016 18:21:55 +0100	[thread overview]
Message-ID: <57D04CB3.1030208@arm.com> (raw)
In-Reply-To: <20160907170304.GT23592@cbox>

On 07/09/16 18:03, Christoffer Dall wrote:
> On Tue, Sep 06, 2016 at 02:02:07PM +0100, Marc Zyngier wrote:
>> If EL1 generates an asynchronous abort and then traps into EL2
>> before the abort has been delivered, we may end-up with the
>> abort firing at the worse possible place: on the host.
>>
>> In order to avoid this, it is necessary to take the abort at EL2,
>> by clearing the PSTATE.A bit. In order to survive this abort,
>> we do it at a point where we're in a known state with respect
>> to the world switch, and handle the resulting exception,
>> overloading the exit code in the process.
>>
>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>> ---
>>  arch/arm64/kvm/hyp/entry.S     | 33 ++++++++++++++++++++++++++++++++-
>>  arch/arm64/kvm/hyp/hyp-entry.S | 25 +++++++++++++++++++++++--
>>  arch/arm64/kvm/hyp/switch.c    |  6 ++++++
>>  3 files changed, 61 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S
>> index 3967c231..7662ef5 100644
>> --- a/arch/arm64/kvm/hyp/entry.S
>> +++ b/arch/arm64/kvm/hyp/entry.S
>> @@ -122,7 +122,38 @@ ENTRY(__guest_exit)
>>  	// Now restore the host regs
>>  	restore_callee_saved_regs x2
>>  
>> -	ret
>> +	// If we have a pending asynchronous abort, now is the
>> +	// time to find out. From your VAXorcist book, page 666:
>> +	// "Threaten me not, oh Evil one!  For I speak with
>> +	// the power of DEC, and I command thee to show thyself!"
>> +	mrs	x2, elr_el2
>> +	mrs	x3, esr_el2
>> +	mrs	x4, spsr_el2
>> +	mov	x5, x0
>> +
>> +	dsb	sy		// Synchronize against in-flight ld/st
>> +	msr	daifclr, #4	// Unmask aborts
>> +
>> +	// This is our single instruction exception window. A pending
>> +	// SError is guaranteed to occur at the earliest when we unmask
>> +	// it, and at the latest just after the ISB.
> 
> Why is it guaranteed to to occur at the latest after the ISB?  I thought
> that asynchronous exceptions could in theory be deferred until forever,
> but I am probably wrong about this.

The DSB is going to force all transactions to be completed and at that
point, we shouldn't have anything being further delayed (this is not an
architectural guarantee, but something that happens to work on the cores
I have access to), and the potential exception becomes pending.

At this point, we perform the unmask. A pending exception *can* fire at
that point, but is not guaranteed to do so. But the ISB, being a
"context synchronization event", guarantees that the exception fires
before the first instruction that follows the ISB (see D1.14.4). This is
what gives us this one instruction window (after the unmask, or after
the isb).

Hope this helps,

	M.
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2016-09-07 17:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 13:01 [PATCH 00/19] Handle guest-generated SErrors/Aborts Marc Zyngier
2016-09-06 13:01 ` [PATCH 01/19] arm64: KVM: Rename HCR_VA to HCR_VSE Marc Zyngier
2016-09-06 13:02 ` [PATCH 02/19] arm64: KVM: Preserve pending vSError in world switch Marc Zyngier
2016-09-06 13:02 ` [PATCH 03/19] arm64: KVM: Add Virtual Abort injection helper Marc Zyngier
2016-09-06 13:02 ` [PATCH 04/19] arm64: KVM: Add exception code to report EL1 asynchronous aborts Marc Zyngier
2016-09-06 13:02 ` [PATCH 05/19] arm64: KVM: Add EL1 async abort handler Marc Zyngier
2016-09-06 13:02 ` [PATCH 06/19] arm64: KVM: Route asynchronous aborts Marc Zyngier
2016-09-06 13:02 ` [PATCH 07/19] arm64: KVM: Allow an exit code to be tagged with an SError Marc Zyngier
2016-09-06 13:02 ` [PATCH 08/19] arm64: KVM: Inject a Virtual SError if it was pending Marc Zyngier
2016-09-06 13:02 ` [PATCH 09/19] arm64: KVM: Handle async aborts delivered while at EL2 Marc Zyngier
2016-09-07 17:03   ` Christoffer Dall
2016-09-07 17:21     ` Marc Zyngier [this message]
2016-09-08  8:47       ` Christoffer Dall
2016-09-06 13:02 ` [PATCH 10/19] arm: KVM: Preserve pending Virtual Abort in world switch Marc Zyngier
2016-09-06 13:02 ` [PATCH 11/19] arm: KVM: Add Virtual Abort injection helper Marc Zyngier
2016-09-06 13:02 ` [PATCH 12/19] arm: KVM: Add HYP async abort handler Marc Zyngier
2016-09-06 13:02 ` [PATCH 13/19] arm: KVM: Allow an exit code to be tagged with a Virtual Abort Marc Zyngier
2016-09-06 13:02 ` [PATCH 14/19] arm: KVM: Handle async aborts delivered while at HYP Marc Zyngier
2016-09-06 13:02 ` [PATCH 15/19] arm: KVM: Inject a Virtual Abort if it was pending Marc Zyngier
2016-09-06 13:02 ` [PATCH 16/19] arm: KVM: Drop unreachable HYP abort handlers Marc Zyngier
2016-09-06 13:02 ` [PATCH 17/19] arm/arm64: KVM: Inject virtual abort when guest exits on external abort Marc Zyngier
2016-09-08  9:09   ` Christoffer Dall
2016-09-06 13:02 ` [PATCH 18/19] arm/arm64: KVM: Remove external abort test from MMIO handling Marc Zyngier
2016-09-06 13:02 ` [PATCH 19/19] arm64: KVM: Inject a vSerror if detecting a bad GICV access at EL2 Marc Zyngier
2016-09-08  9:44 ` [PATCH 00/19] Handle guest-generated SErrors/Aborts Christoffer Dall
2016-09-08  9:55   ` Marc Zyngier
2016-09-08  9:47 ` Wei Chen
2016-09-08 10:02   ` Marc Zyngier

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=57D04CB3.1030208@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).