target/arm: Implement VI/VF bits
PATCH 1/1 target/arm: Implement VI/VF bits
From: Wedson Almeida Filho <[email protected]>
This lets hypervisors running at EL2 inject virtual interrupts into guest VMs.
--- target/arm/op_helper.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-)
target/arm/op_helper.c +38 -3
@@ -1098,9 +1098,44 @@ void HELPER(exception_return)(CPUARMState *env) goto illegal_return; } -if (new_el ==1 && (env->cp15.hcr_el2 &HCR_TGE ) - && !arm_is_secure_below_el3 (env)) { - goto illegal_return; +if (new_el ==1 ) { +uint64_t hcr = env->cp15.hcr_el2; +bool is_secure =arm_is_secure_below_el3 (env); +bool irq = false, fiq = false; +CPUState *cpu =CPU (arm_env_get_cpu (env)); + +if ((hcr &HCR_TGE ) && !is_secure) { + goto illegal_return; + } + +/* The VI and VF fields of HCR_EL2 include the following note: In an +* implementation that includes EL3, when the value of SCR_EL3.NS +* is 0 the PE behaves as if this field is 0 for all purposes other +* than a direct read or write access of HCR_EL2. +* +* So we only check them if not in secure mode. Additionally, both also +* have the following note: The virtual IRQ/FIQ is enabled only when +* the value of HCR_EL2.{TGE, IMO/FMO} is {0, 1}. +*/ +if (!is_secure) { +if ((hcr & (HCR_VI |HCR_TGE |HCR_IMO )) == (HCR_VI |HCR_IMO )) + irq = true; + +if ((hcr & (HCR_VF |HCR_TGE |HCR_FMO )) == (HCR_VF |HCR_FMO )) + fiq = true; + } + +qemu_mutex_lock_iothread (); +if (irq) +cpu_interrupt (cpu,CPU_INTERRUPT_VIRQ ); +else +cpu_reset_interrupt (cpu,CPU_INTERRUPT_VIRQ ); + +if (fiq) +cpu_interrupt (cpu,CPU_INTERRUPT_VFIQ ); +else +cpu_reset_interrupt (cpu,CPU_INTERRUPT_VFIQ ); +qemu_mutex_unlock_iothread (); }qemu_mutex_lock_iothread ();
Signature · 1 line
2.20.0.rc2.403.gdbc3b29805-goog
Quoted 7 lines · Andrew Walbran
From: Wedson Almeida Filho <[email protected]>
This lets hypervisors running at EL2 inject virtual interrupts into guest VMs.
Signed-off-by Wedson Almeida Filho <[email protected]>Signed-off-by Andrew Walbran <[email protected]>
Hi; thanks for this patch. I'm a bit confused -- can you explain what the patch provides that isn't already implemented by commit 89430fc6f80a5aef1d4cb ?
thanks
-- PMM
Hi Peter,
We put this together months ago and hadn't kept up to date with the changes here.
We're happy to see that support has been added for the VI bit. Is it going to be available in the v3.1.0 release?
Thanks,
-Wedson
Quoted 17 lines · Peter Maydell
Quoted 4 lines · Andrew Walbran
From: Wedson Almeida Filho <[email protected]>
This lets hypervisors running at EL2 inject virtual interrupts into
guest VMs.
Quoted 3 lines
Signed-off-by Wedson Almeida Filho <[email protected]>Signed-off-by Andrew Walbran <[email protected]>Hi; thanks for this patch. I'm a bit confused -- can you explain what the patch provides that isn't already implemented by commit
89430fc6f80a5aef1d4cb?thanks
-- PMM
Quoted 6 lines · Wedson Almeida Filho
Hi Peter,
We put this together months ago and hadn't kept up to date with the changes here.
We're happy to see that support has been added for the VI bit. Is it going to be available in the v3.1.0 release?
Yes, that commit is in 3.1.0 -- do test it and let me know if there's still an issue in this area for your guest code.
thanks
-- PMM
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Wedson Almeida Filho
Hi Peter,
Quoted 9 lines
Quoted 1 line
We put this together months ago and hadn't kept up to date with the
changes here.
Quoted 2 lines
We're happy to see that support has been added for the VI bit. Is it
going to be available in the v3.1.0 release?
Yes, that commit is in 3.1.0 -- do test it and let me know if there's still an issue in this area for your guest code.
Ah, thanks, you're quite right! Everything seems to work fine in v3.1.0-rc5, please ignore this patch.