[PATCH 2/4] KVM: x86/mmu: Drop for_each_shadow_entry_using_root()
From: Yosry Ahmed
Date: Tue Oct 13 2026 - 19:18:34 EST
Drop for_each_shadow_entry_using_root() and open code the walk in
__kvm_mmu_invalidate_addr(), the macro's only user, in preparation for
handling failure to initialize the walk, e.g. if a cached root was created
for a different MMU context and so can't be walked.
No functional change intended.
Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: LLM
Signed-off-by: Yosry Ahmed <yosry@xxxxxxxxxx>
---
arch/x86/kvm/mmu/mmu.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 126faef5a6476..2fc23a36433c5 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -166,12 +166,6 @@ struct kvm_shadow_walk_iterator {
unsigned index;
};
-#define for_each_shadow_entry_using_root(_vcpu, _root, _addr, _walker) \
- for (shadow_walk_init_using_root(&(_walker), (_vcpu), \
- (_root), (_addr)); \
- shadow_walk_okay(&(_walker)); \
- shadow_walk_next(&(_walker)))
-
#define for_each_shadow_entry(_vcpu, _addr, _walker) \
for (shadow_walk_init(&(_walker), _vcpu, _addr); \
shadow_walk_okay(&(_walker)); \
@@ -6754,7 +6748,8 @@ static void __kvm_mmu_invalidate_addr(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu
return;
write_lock(&vcpu->kvm->mmu_lock);
- for_each_shadow_entry_using_root(vcpu, root_hpa, addr, iterator) {
+ shadow_walk_init_using_root(&iterator, vcpu, root_hpa, addr);
+ for ( ; shadow_walk_okay(&iterator); shadow_walk_next(&iterator)) {
struct kvm_mmu_page *sp = sptep_to_sp(iterator.sptep);
if (sp->unsync) {
--
2.56.0.385.gd3acb90ef8-goog