mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
target/arm: Correctly implement handling of HCR_EL2.{VI, VF}
In commit8a0fc3a29f
we tried to implement HCR_EL2.{VI,VF}, but we got it wrong and had to revert it. In that commit we implemented them as simply tracking whether there is a pending virtual IRQ or virtual FIQ. This is not correct -- these bits cause a software-generated VIRQ/VFIQ, which is distinct from whether there is a hardware-generated VIRQ/VFIQ caused by the external interrupt controller. So we need to track separately the HCR_EL2 bit state and the external virq/vfiq line state, and OR the two together to get the actual pending VIRQ/VFIQ state. Fixes:8a0fc3a29f
Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20181109134731.11605-4-peter.maydell@linaro.org
This commit is contained in:
parent
ed89f078ff
commit
89430fc6f8
3 changed files with 83 additions and 3 deletions
|
@ -436,6 +436,48 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
|
|||
}
|
||||
#endif
|
||||
|
||||
void arm_cpu_update_virq(ARMCPU *cpu)
|
||||
{
|
||||
/*
|
||||
* Update the interrupt level for VIRQ, which is the logical OR of
|
||||
* the HCR_EL2.VI bit and the input line level from the GIC.
|
||||
*/
|
||||
CPUARMState *env = &cpu->env;
|
||||
CPUState *cs = CPU(cpu);
|
||||
|
||||
bool new_state = (env->cp15.hcr_el2 & HCR_VI) ||
|
||||
(env->irq_line_state & CPU_INTERRUPT_VIRQ);
|
||||
|
||||
if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VIRQ) != 0)) {
|
||||
if (new_state) {
|
||||
cpu_interrupt(cs, CPU_INTERRUPT_VIRQ);
|
||||
} else {
|
||||
cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void arm_cpu_update_vfiq(ARMCPU *cpu)
|
||||
{
|
||||
/*
|
||||
* Update the interrupt level for VFIQ, which is the logical OR of
|
||||
* the HCR_EL2.VF bit and the input line level from the GIC.
|
||||
*/
|
||||
CPUARMState *env = &cpu->env;
|
||||
CPUState *cs = CPU(cpu);
|
||||
|
||||
bool new_state = (env->cp15.hcr_el2 & HCR_VF) ||
|
||||
(env->irq_line_state & CPU_INTERRUPT_VFIQ);
|
||||
|
||||
if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VFIQ) != 0)) {
|
||||
if (new_state) {
|
||||
cpu_interrupt(cs, CPU_INTERRUPT_VFIQ);
|
||||
} else {
|
||||
cpu_reset_interrupt(cs, CPU_INTERRUPT_VFIQ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
static void arm_cpu_set_irq(void *opaque, int irq, int level)
|
||||
{
|
||||
|
@ -457,9 +499,13 @@ static void arm_cpu_set_irq(void *opaque, int irq, int level)
|
|||
|
||||
switch (irq) {
|
||||
case ARM_CPU_VIRQ:
|
||||
assert(arm_feature(env, ARM_FEATURE_EL2));
|
||||
arm_cpu_update_virq(cpu);
|
||||
break;
|
||||
case ARM_CPU_VFIQ:
|
||||
assert(arm_feature(env, ARM_FEATURE_EL2));
|
||||
/* fall through */
|
||||
arm_cpu_update_vfiq(cpu);
|
||||
break;
|
||||
case ARM_CPU_IRQ:
|
||||
case ARM_CPU_FIQ:
|
||||
if (level) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue