Skip to content

RFC KVM: x86/mmu: Preserve Accessed bits on PROT changes

Sean Christopherson kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest9 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9KVM: x86/mmu: Add a dedicated flag to track if A/D bits are globally enabledarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/spte.c arch/x86/kvm/mmu/spte.h +1 more+20 -160 replies
2/9KVM: x86/mmu: Set shadow_accessed_mask for EPT even if A/D bits disabledarch/x86/kvm/mmu/spte.c+1 -10 replies
3/9KVM: x86/mmu: Set shadow_dirty_mask for EPT even if A/D bits disabledarch/x86/kvm/mmu/spte.c+1 -10 replies
4/9KVM: x86/mmu: Use Accessed bit even when _hardware_ A/D bits are disabledarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/spte.c arch/x86/kvm/mmu/spte.h+8 -151 reply
5/9KVM: x86/mmu: Free up A/D bits in FROZEN_SPTEarch/x86/kvm/mmu/spte.h+5 -33 replies
6/9KVM: x86/mmu: Process only valid TDP MMU roots when aging a gfn rangearch/x86/kvm/mmu/tdp_mmu.c+4 -20 replies
7/9KVM: x86/mmu: Stop processing TDP MMU roots for test_age if young SPTE foundarch/x86/kvm/mmu/tdp_mmu.c+40 -440 replies
8/9KVM: Plumb mmu_notifier invalidation event type into arch codeinclude/linux/kvm_host.h virt/kvm/kvm_main.c+2 -00 replies
9/9KVM: x86/mmu: Track SPTE accessed info across mmu_notifier PROT changesarch/x86/kvm/mmu/tdp_mmu.c+25 -63 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [RFC PATCH 0/9] KVM: x86/mmu: Preserve Accessed bits on PROT changes

This applies on top of the massive "follow pfn" rework[*]. The gist is to avoid losing accessed information, e.g. because NUMA balancing mucks with PTEs, by preserving accessed state when KVM zaps SPTEs in response to mmu_notifier invalidations that are for protection changes, e.g. PROT_NUMA.

RFC as I haven't done any testing to verify whether or not this has any impact on page aging, let alone has _postivie_ impact. Personally, I'm not at all convinced that this is necessary outside of tests that care about exact counts, e.g. KVM selftests.

That said, I do think patches 1-7 would be worth merging on their own. Using A/D bits to track state even when A/D bits are disabled in hardware is a nice cleanup.

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

Sean Christopherson (9):
KVM: x86/mmu: Add a dedicated flag to track if A/D bits are globally
enabled
KVM: x86/mmu: Set shadow_accessed_mask for EPT even if A/D bits
disabled
KVM: x86/mmu: Set shadow_dirty_mask for EPT even if A/D bits disabled
KVM: x86/mmu: Use Accessed bit even when _hardware_ A/D bits are
disabled
KVM: x86/mmu: Free up A/D bits in FROZEN_SPTE
KVM: x86/mmu: Process only valid TDP MMU roots when aging a gfn range
KVM: x86/mmu: Stop processing TDP MMU roots for test_age if young SPTE
found
KVM: Plumb mmu_notifier invalidation event type into arch code
KVM: x86/mmu: Track SPTE accessed info across mmu_notifier PROT
changes

 arch/x86/kvm/mmu/mmu.c     |  10 ++--
 arch/x86/kvm/mmu/spte.c    |  16 ++++--
 arch/x86/kvm/mmu/spte.h    |  39 +++++--------
 arch/x86/kvm/mmu/tdp_mmu.c | 113 +++++++++++++++++++++----------------
 include/linux/kvm_host.h   |   1 +
 virt/kvm/kvm_main.c        |   1 +
 6 files changed, 99 insertions(+), 81 deletions(-)

base-commit: 93a198738e0aeb3193ca39c9f01f66060b3c4910

Signature · 1 line
2.46.0.rc1.232.g9752f9e123-goog