KVM: x86/mmu: Allow passing '-1' for "all" as_id for TDP MMU iterators
authorSean Christopherson <seanjc@google.com>
Thu, 11 Jan 2024 02:00:43 +0000 (18:00 -0800)
committerSean Christopherson <seanjc@google.com>
Fri, 23 Feb 2024 00:28:45 +0000 (16:28 -0800)
commit6577f1efdff443277b19c0fbe4b933404e7c84e6
treede2fa5836dc418600fa9e8b406c46e8bbd20d2bc
parentfcdffe97f80e6fb488f6b5c6bd38f6cd899944ab
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>
arch/x86/kvm/mmu/tdp_mmu.c