target/arm: NS BusFault on vector table fetch escalates to NS HardFault
commit51c9122e92b776a3f16af0b9282f1dc5012e2a19
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 15 Jul 2019 13:17:04 +0000 (15 14:17 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 15 Jul 2019 13:17:04 +0000 (15 14:17 +0100)
tree3fbe2604b708932aba655431f22b916af99a4808
parentcb7cef8b32033f6284a47d797edd5c19c5491698
target/arm: NS BusFault on vector table fetch escalates to NS HardFault

In the M-profile architecture, when we do a vector table fetch and it
fails, we need to report a HardFault.  Whether this is a Secure HF or
a NonSecure HF depends on several things.  If AIRCR.BFHFNMINS is 0
then HF is always Secure, because there is no NonSecure HardFault.
Otherwise, the answer depends on whether the 'underlying exception'
(MemManage, BusFault, SecureFault) targets Secure or NonSecure.  (In
the pseudocode, this is handled in the Vector() function: the final
exc.isSecure is calculated by looking at the exc.isSecure from the
exception returned from the memory access, not the isSecure input
argument.)

We weren't doing this correctly, because we were looking at
the target security domain of the exception we were trying to
load the vector table entry for. This produces errors of two kinds:
 * a load from the NS vector table which hits the "NS access
   to S memory" SecureFault should end up as a Secure HardFault,
   but we were raising an NS HardFault
 * a load from the S vector table which causes a BusFault
   should raise an NS HardFault if BFHFNMINS == 1 (because
   in that case all BusFaults are NonSecure), but we were raising
   a Secure HardFault

Correct the logic.

We also fix a comment error where we claimed that we might
be escalating MemManage to HardFault, and forgot about SecureFault.
(Vector loads can never hit MPU access faults, because they're
always aligned and always use the default address map.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20190705094823.28905-1-peter.maydell@linaro.org
target/arm/m_helper.c