Skip to content

KVM: x86/mmu: Fix pre-fault and map private loops

Sean Christopherson kvm lkml sashiko-reviews 2 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 4 repliesApplied
  2. v14 patches 24 repliesSuperseded

Changes in v2 from the cover letter

- Collect reviews. [Rick, Kai]
- Tweak the slots_comment in kvm_tdp_mmu_map_private_pfn() to better capture the nuances of KVM_REQ_MMU_FREE_OBSOLETE_ROOTS. [Rick]
- Call out in the changelog for patch 2 that simply warning on KVM_REQ_MMU_FREE_OBSOLETE_ROOTS is flawed, but handled in a subsequent patch. [Sashiko]
- Make it more clear that encountering retry in kvm_tdp_mmu_map_private_pfn() can only happen if there are KVM bugs. [Rick]
- Set r to RET_PF_RETRY when a stale page fault is detected. [Sashiko]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/4KVM: x86/mmu: Reload MMU on *every* page pre-fault attempt/iterationarch/x86/kvm/mmu/mmu.c+4 -80 replies
2/4KVM: x86/mmu: Harden "map private PFN" against unexpected root invalidationarch/x86/kvm/mmu/mmu.c+12 -41 reply
3/4KVM: x86/mmu: Top-up memory caches when retrying "map private PFN"arch/x86/kvm/mmu/mmu.c+4 -40 replies
4/4KVM: x86/mmu: Add sanity check to detect stale page faults in "map private PFN"arch/x86/kvm/mmu/mmu.c+12 -00 replies

Reviews trailers per patch

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

PatchRick EdgecombeKai Huang
1/4R-b R-b
2/4
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 v2 thread

Cover letter [PATCH v2 0/4] KVM: x86/mmu: Fix pre-fault and map private loops

Fix a bug in the pre-fault path where KVM fails to reload an invalidated MMU root, which puts the KVM_PRE_FAULT_MEMORY task into an infinite loop (although it's breakable, so not fatal to the host). My best guess is that the test started failing once PREEMPT_LAZY was enabled by default. Note, the bug is *really* easy to repro with a to-be-proposed patch to have KVM do auto-pre-faulting[*], i.e. prefetch surrounding pages on fault.

Then harden the similar "map private PFN" to also guard against unexpected root invalidations, because Sashiko keeps pointing out that it's theoretically possible for that code to end up in the same type of infinite loop.

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

v2:
- Collect reviews. [Rick, Kai]
- Tweak the slots_comment in kvm_tdp_mmu_map_private_pfn() to better capture the nuances of KVM_REQ_MMU_FREE_OBSOLETE_ROOTS. [Rick]
- Call out in the changelog for patch 2 that simply warning on KVM_REQ_MMU_FREE_OBSOLETE_ROOTS is flawed, but handled in a subsequent patch. [Sashiko]
- Make it more clear that encountering retry in kvm_tdp_mmu_map_private_pfn() can only happen if there are KVM bugs. [Rick]
- Set r to RET_PF_RETRY when a stale page fault is detected. [Sashiko]

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

Sean Christopherson (4):
KVM: x86/mmu: Reload MMU on *every* page pre-fault attempt/iteration
KVM: x86/mmu: Harden "map private PFN" against unexpected root
invalidation
KVM: x86/mmu: Top-up memory caches when retrying "map private PFN"
KVM: x86/mmu: Add sanity check to detect stale page faults in "map
private PFN"

 arch/x86/kvm/mmu/mmu.c | 48 ++++++++++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 16 deletions(-)

base-commit: 76671054f9a1ff6abb976583cd8da37650acdc97

Signature · 1 line
2.55.0.860.g4b6b3295ed-goog