diff options
author | Sean Christopherson <seanjc@google.com> | 2024-01-10 18:00:45 -0800 |
---|---|---|
committer | Sean Christopherson <seanjc@google.com> | 2024-02-22 16:28:45 -0800 |
commit | d746182337c205660fd4d8eaa5fdc4f4e8320b9a (patch) | |
tree | a6c3f25fc3fc490492b90a6c17d12baa9771b506 /arch/x86/kvm/mmu/mmu.c | |
parent | 99b85fda91b164b91a0d4e0aae376f32dc38d59c (diff) | |
download | linux-d746182337c205660fd4d8eaa5fdc4f4e8320b9a.tar.gz linux-d746182337c205660fd4d8eaa5fdc4f4e8320b9a.tar.bz2 linux-d746182337c205660fd4d8eaa5fdc4f4e8320b9a.zip |
KVM: x86/mmu: Skip invalid TDP MMU roots when write-protecting SPTEs
When write-protecting SPTEs, don't process invalid roots as invalid roots
are unreachable, i.e. can't be used to access guest memory and thus don't
need to be write-protected.
Note, this is *almost* a nop for kvm_tdp_mmu_clear_dirty_pt_masked(),
which is called under slots_lock, i.e. is mutually exclusive with
kvm_mmu_zap_all_fast(). But it's possible for something other than the
"fast zap" thread to grab a reference to an invalid root and thus keep a
root alive (but completely empty) after kvm_mmu_zap_all_fast() completes.
The kvm_tdp_mmu_write_protect_gfn() case is more interesting as KVM write-
protects SPTEs for reasons other than dirty logging, e.g. if a KVM creates
a SPTE for a nested VM while a fast zap is in-progress.
Add another TDP MMU iterator to visit only valid roots, and
opportunistically convert kvm_tdp_mmu_get_vcpu_root_hpa() to said iterator.
Link: https://lore.kernel.org/r/20240111020048.844847-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'arch/x86/kvm/mmu/mmu.c')
0 files changed, 0 insertions, 0 deletions