Skip to content

KVM: Fix deadlock for invalid memslots

Yan Zhao kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest3 patches 9 repliesIn review

Changes in v2 from the cover letter

- Use Sean suggested fixes (patches 1-2).
- Updated selftest for the prefault case accordingly.
- code base: kvm-x86-next-2025.08.21

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3KVM: x86/mmu: Return -EAGAIN if userspace deletes/moves memslot during prefaultarch/x86/kvm/mmu/mmu.c+8 -21 reply
2/3KVM: TDX: Do not retry locally when the retry is caused by invalid memslotarch/x86/kvm/vmx/tdx.c virt/kvm/kvm_main.c+12 -03 replies
3/3KVM: selftests: Test prefault memory during concurrent memslot removaltools/testing/selftests/kvm/pre_fault_memory_test.c+78 -164 replies

Reviews trailers per patch

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

PatchYan ZhaoBinbin Wu
1/3Debugged-by R-b
2/3
3/3

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

Read the v2 thread

Cover letter [PATCH v2 0/3] KVM: Fix deadlock for invalid memslots

Hi,

This series addresses the deadlock issue encountered with invalid memslots during prefaulting or TDX private EPT violations.

Patches 1-2 are the new fixes from Sean.
Patch 1 is for the prefaulting case, patch 2 for the TDX private EPT violation case.

Patch 3 updates the selftest for prefaulting.
The ioctl KVM_PRE_FAULT_MEMORY is now expected to return EAGAIN instead of ENOENT when prefaulting GFNs in an invalid memslot.

The TDX-specific selftest is not included in this series, though it's passed locally.

v2:
- Use Sean suggested fixes (patches 1-2).
- Updated selftest for the prefault case accordingly.
- code base: kvm-x86-next-2025.08.21

v1:
https://lore.kernel.org/all/[email protected]

Sean Christopherson (2):
KVM: x86/mmu: Return -EAGAIN if userspace deletes/moves memslot during
prefault
KVM: TDX: Do not retry locally when the retry is caused by invalid
memslot

Yan Zhao (1):
KVM: selftests: Test prefault memory during concurrent memslot removal

 arch/x86/kvm/mmu/mmu.c                        | 10 +-
 arch/x86/kvm/vmx/tdx.c                        | 11 +++
 .../selftests/kvm/pre_fault_memory_test.c     | 94 +++++++++++++++----
 virt/kvm/kvm_main.c                           |  1 +
 4 files changed, 98 insertions(+), 18 deletions(-)
Signature · 1 line
2.43.2