linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: "Baicar, Tyler" <tbaicar@codeaurora.org>
Cc: fu.wei@linaro.org, timur@codeaurora.org, harba@codeaurora.org,
	rruigrok@codeaurora.org, ahs3@redhat.com,
	catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net,
	lenb@kernel.org, matt@codeblueprint.co.uk,
	robert.moore@intel.com, lv.zheng@intel.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-efi@vger.kernel.org, devel@acpica.org,
	Naveen Kaje <nkaje@codeaurora.org>
Subject: Re: [PATCH V2 5/9] arm64: exception: handle instruction abort at current EL
Date: Thu, 7 Apr 2016 08:54:14 +0100	[thread overview]
Message-ID: <20160407085414.5be649f0@arm.com> (raw)
In-Reply-To: <57058140.5040507@codeaurora.org>

On Wed, 6 Apr 2016 15:36:00 -0600
"Baicar, Tyler" <tbaicar@codeaurora.org> wrote:

Hi Tyler,

> Hello Marc,
> 
> On 4/6/2016 9:36 AM, Marc Zyngier wrote:
> > On 06/04/16 16:12, Tyler Baicar wrote:
> >> Add a handler for instruction aborts at the current EL
> >> (ESR_ELx_EC_IABT_CUR) so they are no longer handled in el1_inv.
> >> This allows firmware first handling for possible SEA
> >> (Synchronous External Abort) caused instruction abort at
> >> current EL.
> >>
> >> Signed-off-by: Tyler Baicar <tbaicar@codeaurora.org>
> >> Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
> >> ---
> >>   arch/arm64/kernel/entry.S | 19 +++++++++++++++++++
> >>   1 file changed, 19 insertions(+)
> >>
> >> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> >> index 12e8d2b..f257856 100644
> >> --- a/arch/arm64/kernel/entry.S
> >> +++ b/arch/arm64/kernel/entry.S
> >> @@ -336,6 +336,8 @@ el1_sync:
> >>   	lsr	x24, x1, #ESR_ELx_EC_SHIFT	// exception class
> >>   	cmp	x24, #ESR_ELx_EC_DABT_CUR	// data abort in EL1
> >>   	b.eq	el1_da
> >> +	cmp	x24, #ESR_ELx_EC_IABT_CUR	// instruction abort in EL1
> >> +	b.eq	el1_ia
> >>   	cmp	x24, #ESR_ELx_EC_SYS64		// configurable trap
> >>   	b.eq	el1_undef
> >>   	cmp	x24, #ESR_ELx_EC_SP_ALIGN	// stack alignment exception
> >> @@ -363,6 +365,23 @@ el1_da:
> >>   	// disable interrupts before pulling preserved data off the stack
> >>   	disable_irq
> >>   	kernel_exit 1
> >> +el1_ia:
> >> +	/*
> >> +	 * Instruction abort handling
> >> +	 */
> >> +	mrs	x0, far_el1
> >> +	enable_dbg
> >> +	// re-enable interrupts if they were enabled in the aborted context
> >> +	tbnz	x23, #7, 1f			// PSR_I_BIT
> >> +	enable_irq
> >> +1:
> >> +	orr	x1, x1, #1 << 24		// use reserved ISS bit for instruction aborts
> >> +	mov	x2, sp				// struct pt_regs
> >> +	bl	do_mem_abort
> >> +
> >> +	// disable interrupts before pulling preserved data off the stack
> >> +	disable_irq
> >> +	kernel_exit 1
> >>   el1_sp_pc:
> >>   	/*
> >>   	 * Stack or PC alignment exception handling
> >>
> > What happens if you were running at EL2 when this faults gets injected?
> > It looks like KVM needs something similar, doesn't it?
> >
> > Thanks,
> >
> > 	M.
> Thank you for your comment. I don't think this case is possible, or at 
> least the current KVM code suggests that this case should never happen.  
> In the EL1 code, we get to this case via the vector:
> 
> ventry  el1_sync                        // Synchronous EL1h
> 
> The EL2 KVM equivalent appears to be in arch/arm64/kvm/hyp-entry.S and is:
> 
> ventry  el2h_sync_invalid               // Synchronous EL2h
> 
> This vector is defined as an invalid_vector and has a comment suggesting 
> that it should never happen:
> 
> /* None of these should ever happen */
> ...
>          invalid_vector  el2h_sync_invalid
> 
> Please correct me if I am wrong, but it looks like this case should not 
> be possible.

This comments really means that we shouldn't ever take any of these
exception. If we do, we'll crash and burn (just like the kernel didn't
expect to take an instruction fault from the kernel itself, up until
this patch).

I expect that the firmware does inject the fault into the exception
level it has preempted. So let me turn the question the other way
around: what guarantees that we will never have to handle such a fault
at EL2?

As a corollary, what happens when the firmware injects a fault
triggered by a VM running at EL1, under the control of a hypervisor
running at EL2? There should be some form of exception delegation to
the hypervisor, which makes the lack of handling at EL2 even more
worrying.

Thanks,

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

  reply	other threads:[~2016-04-07  7:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-06 15:12 [PATCH V2 0/9] Add UEFI 2.6 and ACPI 6.1 updates for RAS on ARM64 Tyler Baicar
2016-04-06 15:12 ` [PATCH V2 1/9] acpi: apei: read ack upon ghes record consumption Tyler Baicar
2016-04-06 15:53   ` Suzuki K Poulose
     [not found]     ` <57053100.7050305-5wv7dgnIgG8@public.gmane.org>
2016-04-06 20:43       ` Baicar, Tyler
2016-04-06 15:12 ` [PATCH V2 2/9] ras: acpi/apei: cper: generic error data entry v3 per ACPI 6.1 Tyler Baicar
     [not found]   ` <1459955578-24602-3-git-send-email-tbaicar-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-04-14 10:22     ` Suzuki K Poulose
     [not found]       ` <570F6F76.3060804-5wv7dgnIgG8@public.gmane.org>
2016-04-20 21:25         ` Baicar, Tyler
2016-04-06 15:12 ` [PATCH V2 3/9] efi: parse ARMv8 processor error Tyler Baicar
2016-04-06 15:12 ` [PATCH V2 4/9] arm64: exception: handle Synchronous External Abort Tyler Baicar
2016-04-06 15:12 ` [PATCH V2 5/9] arm64: exception: handle instruction abort at current EL Tyler Baicar
2016-04-06 15:36   ` Marc Zyngier
2016-04-06 21:36     ` Baicar, Tyler
2016-04-07  7:54       ` Marc Zyngier [this message]
2016-04-11 22:57         ` Abdulhamid, Harb
     [not found]           ` <570C2BD4.6070402-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-04-12 14:17             ` Marc Zyngier
2016-04-06 15:12 ` [PATCH V2 6/9] acpi: apei: handle SEA notification type for ARMv8 Tyler Baicar
2016-04-20 21:38   ` Baicar, Tyler
2016-04-06 15:12 ` [PATCH V2 7/9] acpi: apei: panic OS with fatal error status block Tyler Baicar
2016-04-06 15:12 ` [PATCH V2 8/9] efi: print unrecognized CPER section Tyler Baicar
     [not found] ` <1459955578-24602-1-git-send-email-tbaicar-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-04-06 15:12   ` [PATCH V2 9/9] ras: acpi / apei: generate trace event for " Tyler Baicar

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=20160407085414.5be649f0@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=ahs3@redhat.com \
    --cc=catalin.marinas@arm.com \
    --cc=devel@acpica.org \
    --cc=fu.wei@linaro.org \
    --cc=harba@codeaurora.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lv.zheng@intel.com \
    --cc=matt@codeblueprint.co.uk \
    --cc=nkaje@codeaurora.org \
    --cc=rjw@rjwysocki.net \
    --cc=robert.moore@intel.com \
    --cc=rruigrok@codeaurora.org \
    --cc=tbaicar@codeaurora.org \
    --cc=timur@codeaurora.org \
    --cc=will.deacon@arm.com \
    /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).