arm v8M: Forcibly clear negative-priority exceptions on deactivate
To prevent execution priority remaining negative if the guest returns from an NMI or HardFault with a corrupted IPSR, the v8M interrupt deactivation process forces the HardFault and NMI to inactive based on the current raw execution priority, even if the interrupt the guest is trying to deactivate is something else. In the pseudocode this is done in the Deactivate() function. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20190617175317.27557-3-peter.maydell@linaro.org
This commit is contained in:
parent
7aab5a8c8b
commit
077d744910
@ -812,15 +812,45 @@ void armv7m_nvic_get_pending_irq_info(void *opaque,
|
|||||||
int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
|
int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
|
||||||
{
|
{
|
||||||
NVICState *s = (NVICState *)opaque;
|
NVICState *s = (NVICState *)opaque;
|
||||||
VecInfo *vec;
|
VecInfo *vec = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
|
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
|
||||||
|
|
||||||
if (secure && exc_is_banked(irq)) {
|
/*
|
||||||
vec = &s->sec_vectors[irq];
|
* For negative priorities, v8M will forcibly deactivate the appropriate
|
||||||
} else {
|
* NMI or HardFault regardless of what interrupt we're being asked to
|
||||||
vec = &s->vectors[irq];
|
* deactivate (compare the DeActivate() pseudocode). This is a guard
|
||||||
|
* against software returning from NMI or HardFault with a corrupted
|
||||||
|
* IPSR and leaving the CPU in a negative-priority state.
|
||||||
|
* v7M does not do this, but simply deactivates the requested interrupt.
|
||||||
|
*/
|
||||||
|
if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) {
|
||||||
|
switch (armv7m_nvic_raw_execution_priority(s)) {
|
||||||
|
case -1:
|
||||||
|
if (s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
|
||||||
|
vec = &s->vectors[ARMV7M_EXCP_HARD];
|
||||||
|
} else {
|
||||||
|
vec = &s->sec_vectors[ARMV7M_EXCP_HARD];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
vec = &s->vectors[ARMV7M_EXCP_NMI];
|
||||||
|
break;
|
||||||
|
case -3:
|
||||||
|
vec = &s->sec_vectors[ARMV7M_EXCP_HARD];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vec) {
|
||||||
|
if (secure && exc_is_banked(irq)) {
|
||||||
|
vec = &s->sec_vectors[irq];
|
||||||
|
} else {
|
||||||
|
vec = &s->vectors[irq];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_nvic_complete_irq(irq, secure);
|
trace_nvic_complete_irq(irq, secure);
|
||||||
|
Loading…
Reference in New Issue
Block a user