KVM: arm64: Don't miss pending interrupts for suspended vCPU
PATCH 1/1 KVM: arm64: Don't miss pending interrupts for suspended vCPU
In order to properly emulate the WFI instruction, KVM reads back ICH_VMCR_EL2 and enables doorbells for GICv4. These preparations are necessary in order to recognize pending interrupts in kvm_arch_vcpu_runnable() and return to the guest. Until recently, this work was done by kvm_arch_vcpu_{blocking,unblocking}(). Since commit 6109c5a6ab7f ("KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook"), these callbacks were gutted and superseded by kvm_vcpu_wfi().
It is important to note that KVM implements PSCI CPU_SUSPEND calls as a WFI within the guest. However, the implementation calls directly into kvm_vcpu_halt(), which skips the needed work done in kvm_vcpu_wfi() to detect pending interrupts. Fix the issue by calling the WFI helper.
--- arch/arm64/kvm/psci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kvm/psci.c +1 -2
@@ -46,8 +46,7 @@ static unsigned long kvm_psci_vcpu_suspend(struct kvm_vcpu *vcpu)* specification (ARM DEN 0022A). This means all suspend states * for KVM will preserve the register state. */ -kvm_vcpu_halt (vcpu); -kvm_clear_request (KVM_REQ_UNHALT , vcpu); +kvm_vcpu_wfi (vcpu);return PSCI_RET_SUCCESS ; }
Signature · 1 line
2.35.1.265.g69c8d7142f-goog
Marc Zyngier
maintainerQuoted 35 lines · Oliver Upton
In order to properly emulate the WFI instruction, KVM reads back
ICH_VMCR_EL2and enables doorbells for GICv4. These preparations are necessary in order to recognize pending interrupts inkvm_arch_vcpu_runnable()and return to the guest. Until recently, this work was done by kvm_arch_vcpu_{blocking,unblocking}(). Since commit6109c5a6ab7f("KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook"), these callbacks were gutted and superseded bykvm_vcpu_wfi().It is important to note that KVM implements PSCI
CPU_SUSPENDcalls as a WFI within the guest. However, the implementation calls directly intokvm_vcpu_halt(), which skips the needed work done inkvm_vcpu_wfi()to detect pending interrupts. Fix the issue by calling the WFI helper.Fixes 6109c5a6ab7f ("KVM: arm64: Move vGIC v4 handling for WFI outarch callback hook")
Signed-off-by Oliver Upton <[email protected]>--- arch/arm64/kvm/psci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/arm64/kvm/psci.c +1
-2@@ -46,8 +46,7 @@ static unsigned long kvm_psci_vcpu_suspend(structkvm_vcpu *vcpu) * specification (ARM DEN 0022A). This means all suspend states * for KVM will preserve the register state. */ -kvm_vcpu_halt (vcpu); -kvm_clear_request (KVM_REQ_UNHALT , vcpu); +kvm_vcpu_wfi (vcpu);return PSCI_RET_SUCCESS ;
Quoted 1 line
}
Thanks for picking this up, I kept forgetting about fixing it. I'll merge it once I'm back home.
M.
Signature · 5 lines
Jazz is not dead. It just smells funny... _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 10 lines · Oliver Upton
In order to properly emulate the WFI instruction, KVM reads back
ICH_VMCR_EL2and enables doorbells for GICv4. These preparations are necessary in order to recognize pending interrupts inkvm_arch_vcpu_runnable()and return to the guest. Until recently, this work was done by kvm_arch_vcpu_{blocking,unblocking}(). Since commit6109c5a6ab7f("KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook"), these callbacks were gutted and superseded bykvm_vcpu_wfi().[...]
Applied to fixes, thanks!
[1/1] KVM: arm64: Don't miss pending interrupts for suspended vCPU
commit: a867e9d0cc15039a6ef72e17e2603303dcd1783f