Skip to contentSkip to conversation

KVM: x86/mmu: Wrap kvm_mmu_zap_all_fast TDP MMU code in ifdefs

PATCH New Ben Gardon 1 participant 2 messages Apr 19, 2021

Subsystems (3)
lore
Share & tools
lore

Ben Gardon

author
#0 lore raw

PATCH 1/2 KVM: x86/mmu: Wrap kvm_mmu_zap_all_fast TDP MMU code in ifdefs

The TDP MMU code in kvm_mmu_zap_all_fast is only needed with CONFIG_X86_64 and creates a build error without that setting. Since the TDP MMU can only be enabled with CONFIG_X86_64, wrap those code blocks in ifdefs.

Fixes 1336c692abad ("KVM: x86/mmu: Fast invalidation for TDP MMU")
---
 arch/x86/kvm/mmu/mmu.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/kvm/mmu/mmu.c +6 -0
index 0f311c9bf9c6..3ae59c8e129b 100644
@@ -5407,7 +5407,9 @@ static void kvm_zap_obsolete_pages(struct kvm *kvm)
  */
 static void kvm_mmu_zap_all_fast(struct kvm *kvm)
 {
+#ifdef CONFIG_X86_64
 	struct kvm_mmu_page *root;
+#endif /* CONFIG_X86_64 */
 
 	lockdep_assert_held(&kvm->slots_lock);
 
@@ -5424,6 +5426,7 @@ static void kvm_mmu_zap_all_fast(struct kvm *kvm)
 	kvm->arch.mmu_valid_gen = kvm->arch.mmu_valid_gen ? 0 : 1;
 
 
+#ifdef CONFIG_X86_64
 	if (is_tdp_mmu_enabled(kvm)) {
 		/*
 		 * Mark each TDP MMU root as invalid so that other threads
@@ -5456,6 +5459,7 @@ static void kvm_mmu_zap_all_fast(struct kvm *kvm)
 			if (refcount_inc_not_zero(&root->tdp_mmu_root_count))
 				root->role.invalid = true;
 	}
+#endif /* CONFIG_X86_64 */
 
 	/*
 	 * Notify all vcpus to reload its shadow page table and flush TLB.
@@ -5471,11 +5475,13 @@ static void kvm_mmu_zap_all_fast(struct kvm *kvm)
 
 	write_unlock(&kvm->mmu_lock);
 
+#ifdef CONFIG_X86_64
 	if (is_tdp_mmu_enabled(kvm)) {
 		read_lock(&kvm->mmu_lock);
 		kvm_tdp_mmu_zap_invalidated_roots(kvm);
 		read_unlock(&kvm->mmu_lock);
 	}
+#endif /* CONFIG_X86_64 */
 }
 
 static bool kvm_has_zapped_obsolete_pages(struct kvm *kvm)
Signature · 1 line
2.31.1.368.gbe11c130af-goog
author
#1 lore raw

PATCH 2/2 KVM: x86/mmu: Fix typo in for_each_tdp_mmu_root

There's a typo in for_each_tdp_mmu_root which breaks compilation with certain configurations. Fix it.

Fixes 078d47ee71d6 ("KVM: x86/mmu: Protect the tdp_mmu_roots list with RCU")
---
 arch/x86/kvm/mmu/tdp_mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/tdp_mmu.c +1 -1
index 8ce8d0916042..f0aef4969754 100644
@@ -152,7 +152,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_rcu(_root, &_kvm->arch.tdp_mmu_roots, link,		\
 				lockdep_is_held_type(&kvm->mmu_lock, 0) ||	\
-				lockdep_is_help(&kvm->arch.tdp_mmu_pages_lock))	\
+				lockdep_is_held(&kvm->arch.tdp_mmu_pages_lock))	\
 		if (kvm_mmu_page_as_id(_root) != _as_id) {		\
 		} else
 
Signature · 1 line
2.31.1.368.gbe11c130af-goog