diff options
author | Sean Christopherson <seanjc@google.com> | 2024-01-10 01:39:38 +0100 |
---|---|---|
committer | Sean Christopherson <seanjc@google.com> | 2024-02-23 01:27:41 +0100 |
commit | dafc17dd529a6194e199b837916062090562ff80 (patch) | |
tree | 80a168a0ebff73e60d62a296152f4f3d5dd15548 /virt | |
parent | KVM: x86: Clean up directed yield API for "has pending interrupt" (diff) | |
download | linux-dafc17dd529a6194e199b837916062090562ff80.tar.xz linux-dafc17dd529a6194e199b837916062090562ff80.zip |
KVM: Add a comment explaining the directed yield pending interrupt logic
Add a comment to explain why KVM treats vCPUs with pending interrupts as
in-kernel when a vCPU wants to yield to a vCPU that was preempted while
running in kernel mode.
Link: https://lore.kernel.org/r/20240110003938.490206-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9b92858c8b72..c0c2fcdabe1b 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4090,6 +4090,13 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me, bool yield_to_kernel_mode) continue; if (kvm_vcpu_is_blocking(vcpu) && !vcpu_dy_runnable(vcpu)) continue; + + /* + * Treat the target vCPU as being in-kernel if it has a + * pending interrupt, as the vCPU trying to yield may + * be spinning waiting on IPI delivery, i.e. the target + * vCPU is in-kernel for the purposes of directed yield. + */ if (READ_ONCE(vcpu->preempted) && yield_to_kernel_mode && !kvm_arch_dy_has_pending_interrupt(vcpu) && !kvm_arch_vcpu_preempted_in_kernel(vcpu)) |