Skip to content

Small changes related to prefetch and spurious faults

Yan Zhao kvm lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 1 replyIn review
  2. v14 patches 11 repliesSuperseded

Changes in v2 from the cover letter

- Check both fault->prefetch and is_access_allowed() in patch 2. (Sean)
- Split patch 3 in v1 into patches 3 and 4.
- Only warn on PFN changes in case of spurious fault in TDP MMU in patch 3. (Sean).
- Add patch 4 to warn on PFN changes on shadow-present SPTE in shadow MMU.
- Move kvm_mmu_free_obsolete_roots() from kvm_arch_vcpu_pre_fault_memory() to kvm_mmu_reload() in patch 5. (Sean)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5KVM: x86/mmu: Further check old SPTE is leaf for spurious prefetch faultarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/tdp_mmu.c+3 -20 replies
2/5KVM: x86/tdp_mmu: Merge prefetch and access checks for spurious faultsarch/x86/kvm/mmu/tdp_mmu.c+1 -50 replies
3/5KVM: x86/tdp_mmu: WARN if PFN changes for spurious faultsarch/x86/kvm/mmu/tdp_mmu.c+3 -10 replies
4/5KVM: x86/mmu: Warn if PFN changes on shadow-present SPTE in shadow MMUarch/x86/kvm/mmu/mmu.c+3 -20 replies
5/5KVM: x86/mmu: Check and free obsolete roots in kvm_mmu_reload()arch/x86/kvm/mmu.h arch/x86/kvm/mmu/mmu.c+4 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/5] Small changes related to prefetch and spurious faults

Hi

This is v2 of the series for some small changes related to prefetch/prefault and spurious faults.

Patch 1: Checks if a shadow-present old SPTE is leaf to determine a
prefetch fault is spurious.

Patch 2: Merges the checks for prefetch and is_access_allowed() for
spurious faults into a common path.

Patch 3: Adds a warning when the PFN changes on a spurious fault in the TDP
MMU

Patch 4: Adds a warning when the PFN changes on a shadow-present SPTE in
the shadow MMU. This implementation differs from the v1 discussion. Upon reconsideration, I realized that WARN_ON_ONCE() in mmu_spte_update() cannot warn when the PFN changes on a shadow-present SPTE. Add the warning in mmu_set_spte() and have the prefetch fault to leverage the warning.

Patch 5: Checks req and frees obsolete roots in each MMU reload.

With below scenario
1. add a memslot with size 4K
2. prefault GPA A in the memslot
3. delete the memslot
4. re-add the memslot with size 2M
5. prefault GPA A again.

Patch 1 is required if zap all quirk is disabled in step 3. Patch 5 is required if zap all is performed in step 3 and if step 2/5 are
executed before any vcpu_run().

Change log:
v2:
- Check both fault->prefetch and is_access_allowed() in patch 2. (Sean)
- Split patch 3 in v1 into patches 3 and 4.
- Only warn on PFN changes in case of spurious fault in TDP MMU in patch 3. (Sean).
- Add patch 4 to warn on PFN changes on shadow-present SPTE in shadow MMU.
- Move kvm_mmu_free_obsolete_roots() from kvm_arch_vcpu_pre_fault_memory() to kvm_mmu_reload() in patch 5. (Sean)

Thanks
Yan

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

Yan Zhao (5):
KVM: x86/mmu: Further check old SPTE is leaf for spurious prefetch
fault
KVM: x86/tdp_mmu: Merge prefetch and access checks for spurious faults
KVM: x86/tdp_mmu: WARN if PFN changes for spurious faults
KVM: x86/mmu: Warn if PFN changes on shadow-present SPTE in shadow MMU
KVM: x86/mmu: Check and free obsolete roots in kvm_mmu_reload()

 arch/x86/kvm/mmu.h         | 3 +++
 arch/x86/kvm/mmu/mmu.c     | 6 ++++--
 arch/x86/kvm/mmu/tdp_mmu.c | 9 ++++-----
 3 files changed, 11 insertions(+), 7 deletions(-)

base-commit: c9ea48bb6ee6b28bbc956c1e8af98044618fed5e

Signature · 1 line
2.43.2