mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
KVM: x86/mmu: Allow passing '-1' for "all" as_id for TDP MMU iterators
Modify for_each_tdp_mmu_root() and __for_each_tdp_mmu_root_yield_safe() to accept -1 for _as_id to mean "process all memslot address spaces". That way code that wants to process both SMM and !SMM doesn't need to iterate over roots twice (and likely copy+paste code in the process). Deliberately don't cast _as_id to an "int", just in case not casting helps the compiler elide the "_as_id >=0" check when being passed an unsigned value, e.g. from a memslot. No functional change intended. Link: https://lore.kernel.org/r/20240111020048.844847-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
fcdffe97f8
commit
6577f1efdf
@ -153,7 +153,7 @@ static struct kvm_mmu_page *tdp_mmu_next_root(struct kvm *kvm,
|
||||
for (_root = tdp_mmu_next_root(_kvm, NULL, _only_valid); \
|
||||
({ lockdep_assert_held(&(_kvm)->mmu_lock); }), _root; \
|
||||
_root = tdp_mmu_next_root(_kvm, _root, _only_valid)) \
|
||||
if (kvm_mmu_page_as_id(_root) != _as_id) { \
|
||||
if (_as_id >= 0 && kvm_mmu_page_as_id(_root) != _as_id) { \
|
||||
} else
|
||||
|
||||
#define for_each_valid_tdp_mmu_root_yield_safe(_kvm, _root, _as_id) \
|
||||
@ -174,7 +174,7 @@ static struct kvm_mmu_page *tdp_mmu_next_root(struct kvm *kvm,
|
||||
#define for_each_tdp_mmu_root(_kvm, _root, _as_id) \
|
||||
list_for_each_entry(_root, &_kvm->arch.tdp_mmu_roots, link) \
|
||||
if (kvm_lockdep_assert_mmu_lock_held(_kvm, false) && \
|
||||
kvm_mmu_page_as_id(_root) != _as_id) { \
|
||||
_as_id >= 0 && kvm_mmu_page_as_id(_root) != _as_id) { \
|
||||
} else
|
||||
|
||||
static struct kvm_mmu_page *tdp_mmu_alloc_sp(struct kvm_vcpu *vcpu)
|
||||
|
Loading…
Reference in New Issue
Block a user