Skip to content

KVM: Clean up "preempted in-kernel" logic

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Applied to kvm-x86 misc, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 6 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/4KVM: Add dedicated arch hook for querying if vCPU was preempted in-kernelarch/x86/kvm/x86.c include/linux/kvm_host.h virt/kvm/kvm_main.c+19 -21 reply
2/4KVM: x86: Rely solely on preempted_in_kernel flag for directed yieldarch/x86/kvm/x86.c+2 -63 replies
3/4KVM: x86: Clean up directed yield API for "has pending interrupt"arch/x86/kvm/x86.c+2 -51 reply
4/4KVM: Add a comment explaining the directed yield pending interrupt logicvirt/kvm/kvm_main.c+7 -00 replies

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchYuan Yao
1/4R-b
2/4R-b
3/4R-b
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/4] KVM: Clean up "preempted in-kernel" logic

Provide a dedicated helper to query if a *different* vCPU was preempted in-kernel. x86's VMX is an oddball and can only check if the vCPU is in kernel (versus userspace) if the vCPU is loaded on the current pCPU.

The existing kvm_arch_vcpu_in_kernel() "works", but it's an ugly mess as KVM x86 is forced to check kvm_get_running_vcpu() to effectively undo the multiplexing.

Note, I was sorely tempted to eliminate kvm_arch_dy_has_pending_interrupt() and bury that logic in VMX code, but I ultimately decided to keep it as an arch hook as it's entirely plausible that some other architecture can do cross-vCPU IRQ checks, and if KVM is going to have the (somewhat dubious IMO) logic, it's probably best to keep it in common code.

Sean Christopherson (4):
KVM: Add dedicated arch hook for querying if vCPU was preempted
in-kernel
KVM: x86: Rely solely on preempted_in_kernel flag for directed yield
KVM: x86: Clean up directed yield API for "has pending interrupt"
KVM: Add a comment explaining the directed yield pending interrupt
logic

 arch/x86/kvm/x86.c       | 16 +++++++---------
 include/linux/kvm_host.h |  1 +
 virt/kvm/kvm_main.c      | 22 ++++++++++++++++++++--
 3 files changed, 28 insertions(+), 11 deletions(-)

base-commit: 1c6d984f523f67ecfad1083bb04c55d91977bb15

Signature · 1 line
2.43.0.472.g3155946c3a-goog