target/arm: Check for xPSR mismatch usage faults earlier for v8M
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 6 Oct 2017 15:46:48 +0000 (16:46 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 6 Oct 2017 15:46:48 +0000 (16:46 +0100)
commit224e0c300a0098fb577a03bd29d774d0769f632a
treee67abc8a84950bd32d20460b5d91e992abc7ede9
parent3f0cddeee1f266d43c956581f3050058360a810d
target/arm: Check for xPSR mismatch usage faults earlier for v8M

ARM v8M specifies that the INVPC usage fault for mismatched
xPSR exception field and handler mode bit should be checked
before updating the PSR and SP, so that the fault is taken
with the existing stack frame rather than by pushing a new one.
Perform this check in the right place for v8M.

Since v7M specifies in its pseudocode that this usage fault
check should happen later, we have to retain the original
code for that check rather than being able to merge the two.
(The distinction is architecturally visible but only in
very obscure corner cases like attempting an invalid exception
return with an exception frame in read only memory.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1506092407-26985-7-git-send-email-peter.maydell@linaro.org
target/arm/helper.c