[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 4/9] arm v8M: Forcibly clear negative-priority except
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 4/9] arm v8M: Forcibly clear negative-priority exceptions on deactivate |
Date: |
Thu, 4 Jul 2019 17:07:57 +0100 |
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 <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Message-id: address@hidden
---
hw/intc/armv7m_nvic.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index b8ede30b3cb..330eb728dd5 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -812,15 +812,45 @@ void armv7m_nvic_get_pending_irq_info(void *opaque,
int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
{
NVICState *s = (NVICState *)opaque;
- VecInfo *vec;
+ VecInfo *vec = NULL;
int ret;
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
- if (secure && exc_is_banked(irq)) {
- vec = &s->sec_vectors[irq];
- } else {
- vec = &s->vectors[irq];
+ /*
+ * For negative priorities, v8M will forcibly deactivate the appropriate
+ * NMI or HardFault regardless of what interrupt we're being asked to
+ * 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);
--
2.20.1
- [Qemu-devel] [PULL 0/9] target-arm queue, Peter Maydell, 2019/07/04
- [Qemu-devel] [PULL 2/9] target/arm: Restrict semi-hosting to TCG, Peter Maydell, 2019/07/04
- [Qemu-devel] [PULL 1/9] target/arm: Move debug routines to debug_helper.c, Peter Maydell, 2019/07/04
- [Qemu-devel] [PULL 6/9] target/arm: Use _ra versions of cpu_stl_data() in v7M helpers, Peter Maydell, 2019/07/04
- [Qemu-devel] [PULL 5/9] target/arm: v8M: Check state of exception being returned from, Peter Maydell, 2019/07/04
- [Qemu-devel] [PULL 7/9] hw/timer/armv7m_systick: Forbid non-privileged accesses, Peter Maydell, 2019/07/04
- [Qemu-devel] [PULL 8/9] target/arm: Execute Thumb instructions when their condbits are 0xf, Peter Maydell, 2019/07/04
- [Qemu-devel] [PULL 9/9] target/arm: Correct VMOV_imm_dp handling of short vectors, Peter Maydell, 2019/07/04
- [Qemu-devel] [PULL 4/9] arm v8M: Forcibly clear negative-priority exceptions on deactivate,
Peter Maydell <=
- [Qemu-devel] [PULL 3/9] target/arm/helper: Move M profile routines to m_helper.c, Peter Maydell, 2019/07/04
- Re: [Qemu-devel] [PULL 0/9] target-arm queue, Peter Maydell, 2019/07/04
- Re: [Qemu-devel] [PULL 0/9] target-arm queue, no-reply, 2019/07/05