Skip to content

KVM: Ensure WAIT requests actually wait

Sean Christopherson kvm kvm-riscv kvmarm linux-arm-kernel linux-mips linux-riscv linuxppc-dev lkml loongarch 1 version Applied

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

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 7 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/7KVM: s390: Drop unused and unreachable kvm_arch_vcpu_should_kick()arch/s390/kvm/s390/s390.c+0 -73 replies
2/7KVM: Add a @force param to __kvm_vcpu_kick() for PPC backwards compatibilityinclude/linux/kvm_host.h virt/kvm/kvm_main.c+10 -60 replies
3/7KVM: PPC: Explicitly force IPIs when directly kicking vCPUsarch/powerpc/include/asm/kvm_ppc.h arch/powerpc/kvm/book3s.c arch/powerpc/kvm/book3s_pr.c +3 more+20 -93 replies
4/7KVM: MIPS: Rework kvm_arch_vcpu_should_kick() to use standard implementationarch/mips/kvm/mips.c+1 -10 replies
5/7KVM: Move kvm_arch_vcpu_should_kick() to common code as kvm_vcpu_should_kick()arch/arm64/kvm/arm.c arch/loongarch/kvm/vcpu.c arch/mips/kvm/mips.c +5 more+8 -340 replies
6/7KVM: Plumb the full request into __kvm_vcpu_kick()arch/powerpc/include/asm/kvm_ppc.h include/linux/kvm_host.h virt/kvm/kvm_main.c+13 -120 replies
7/7KVM: Drop kvm_vcpu_should_kick() and use kvm_request_needs_ipi()virt/kvm/kvm_main.c+2 -80 replies

Reviews trailers per patch

1 of 7 patches has a Reviewed-by or Acked-by.

PatchGautam Menghani
1/7
2/7
3/7R-b
4/7
5/7
6/7
7/7

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/7] KVM: Ensure WAIT requests actually wait

Fix a bug in where kvm_make_request_and_kick() won't actually wait if the kick races without another non-waiting kick. The issue is that all of the conditional kvm_arch_vcpu_should_kick() implementations are missing this code:

	if (req & KVM_REQUEST_WAIT)
		return mode != OUTSIDE_GUEST_MODE;

Thankfully, kvm_request_needs_ipi() does the right thing, so this doesn't affect kvm_make_all_cpus_request() or kvm_make_vcpus_request_mask(), i.e. it's limited to x86 SNP's used of kvm_make_request_and_kick().

To fix, address this TODO:

/* TODO: merge with kvm_arch_vcpu_should_kick */

and purge kvm_arch_vcpu_should_kick(). As usual, PPC makes that difficult because it has wonky code that is poorly documented. For reasons unknown, kvm_vcpu_kick() unconditionally returns true on (most flavors of) PPC. To preserve that behavior, add a compatibility wrapper in PPC, along with a @force param to __kvm_vcpu_kick().

This series would ideally go into 7.4, even though it's obviously not small, as guest_memfd in-place conversion massively widens the window where a missed kick+wait can lead to the host trying to reclaim an in-use VMSA page, which is generally fatal to the host.

Sean Christopherson (7):
KVM: s390: Drop unused and unreachable kvm_arch_vcpu_should_kick()
KVM: Add a @force param to __kvm_vcpu_kick() for PPC backwards
compatibility
KVM: PPC: Explicitly force IPIs when directly kicking vCPUs
KVM: MIPS: Rework kvm_arch_vcpu_should_kick() to use standard
implementation
KVM: Move kvm_arch_vcpu_should_kick() to common code as
kvm_vcpu_should_kick()
KVM: Plumb the full request into __kvm_vcpu_kick()
KVM: Drop kvm_vcpu_should_kick() and use kvm_request_needs_ipi()

 arch/arm64/kvm/arm.c               |  5 -----
 arch/loongarch/kvm/vcpu.c          |  5 -----
 arch/mips/kvm/mips.c               |  5 -----
 arch/powerpc/include/asm/kvm_ppc.h | 13 ++++++++++++-
 arch/powerpc/kvm/book3s.c          |  4 ++--
 arch/powerpc/kvm/book3s_pr.c       |  2 +-
 arch/powerpc/kvm/booke.c           |  6 +++---
 arch/powerpc/kvm/e500_emulate.c    |  2 +-
 arch/powerpc/kvm/powerpc.c         |  7 +------
 arch/riscv/kvm/vcpu.c              |  5 -----
 arch/s390/kvm/s390/s390.c          |  7 -------
 arch/x86/kvm/x86.c                 |  5 -----
 include/linux/kvm_host.h           |  7 +++----
 virt/kvm/kvm_main.c                | 28 ++++++++++++++++------------
 14 files changed, 39 insertions(+), 62 deletions(-)

base-commit: 7e60162b16f9da0d2fa83da5c1723b6853a0ac1d

Signature · 1 line
2.56.0.313.g2479322e68-goog