mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
target/arm: Track the state of our irq lines from the GIC explicitly
Currently we track the state of the four irq lines from the GIC
only via the cs->interrupt_request or KVM irq state. That means
that we assume that an interrupt is asserted if and only if the
external line is set. This assumption is incorrect for VIRQ
and VFIQ, because the HCR_EL2.{VI,VF} bits allow assertion
of VIRQ and VFIQ separately from the state of the external line.
To handle this, start tracking the state of the external lines
explicitly in a CPU state struct field, as is common practice
for devices.
The complicated part of this is dealing with inbound migration
from an older QEMU which didn't have this state. We assume in
that case that the older QEMU did not implement the HCR_EL2.{VI,VF}
bits as generating interrupts, and so the line state matches
the current state in cs->interrupt_request. (This is not quite
true between commit 8a0fc3a29f
and its revert, but
that commit is broken and never made it into any released QEMU
version.)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 20181109134731.11605-3-peter.maydell@linaro.org
This commit is contained in:
parent
c624ea0fa7
commit
ed89f078ff
3 changed files with 71 additions and 0 deletions
|
@ -449,6 +449,12 @@ static void arm_cpu_set_irq(void *opaque, int irq, int level)
|
|||
[ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ
|
||||
};
|
||||
|
||||
if (level) {
|
||||
env->irq_line_state |= mask[irq];
|
||||
} else {
|
||||
env->irq_line_state &= ~mask[irq];
|
||||
}
|
||||
|
||||
switch (irq) {
|
||||
case ARM_CPU_VIRQ:
|
||||
case ARM_CPU_VFIQ:
|
||||
|
@ -471,19 +477,30 @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level)
|
|||
{
|
||||
#ifdef CONFIG_KVM
|
||||
ARMCPU *cpu = opaque;
|
||||
CPUARMState *env = &cpu->env;
|
||||
CPUState *cs = CPU(cpu);
|
||||
int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT;
|
||||
uint32_t linestate_bit;
|
||||
|
||||
switch (irq) {
|
||||
case ARM_CPU_IRQ:
|
||||
kvm_irq |= KVM_ARM_IRQ_CPU_IRQ;
|
||||
linestate_bit = CPU_INTERRUPT_HARD;
|
||||
break;
|
||||
case ARM_CPU_FIQ:
|
||||
kvm_irq |= KVM_ARM_IRQ_CPU_FIQ;
|
||||
linestate_bit = CPU_INTERRUPT_FIQ;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if (level) {
|
||||
env->irq_line_state |= linestate_bit;
|
||||
} else {
|
||||
env->irq_line_state &= ~linestate_bit;
|
||||
}
|
||||
|
||||
kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT;
|
||||
kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue