Skip to contentSkip to conversation

KVM: x86/mmu: Use yield-safe TDP MMU root iter in MMU notifier unmapping

PATCH Applied Sean Christopherson 3 participants 3 messages Nov 20, 2021 – Nov 26, 2021

Subsystems (3)
lore
Share & tools
lore

Sean Christopherson

author maintainer
#0 lore raw

PATCH 1/1 KVM: x86/mmu: Use yield-safe TDP MMU root iter in MMU notifier unmapping

Use the yield-safe variant of the TDP MMU iterator when handling an unmapping event from the MMU notifier, as most occurences of the event allow yielding.

Fixes e1eed5847b09 ("KVM: x86/mmu: Allow yielding during MMU notifier unmap/zap, if possible")
---
 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 377a96718a2e..a29ebff1cfa0 100644
@@ -1031,7 +1031,7 @@ bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range,
 {
 	struct kvm_mmu_page *root;
 
-	for_each_tdp_mmu_root(kvm, root, range->slot->as_id)
+	for_each_tdp_mmu_root_yield_safe(kvm, root, range->slot->as_id, false)
 		flush |= zap_gfn_range(kvm, root, range->start, range->end,
 				       range->may_block, flush, false);
 
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
#1 lore raw

I guess it would conflict with c7785d85b6c6 ("KVM: x86/mmu:
Skip tlb flush if it has been done in zap_gfn_range()") from Hou in the recent master branch in kvm tree.

Quoted 4 lines · Sean Christopherson

Use the yield-safe variant of the TDP MMU iterator when handling an unmapping event from the MMU notifier, as most occurences of the event allow yielding.

My spell check add-on in the browser tells:
occurences -> occurrences

Quoted 24 lines
Fixes e1eed5847b09 ("KVM: x86/mmu: Allow yielding during MMU notifier unmap/zap, if possible")
---
 arch/x86/kvm/mmu/tdp_mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/tdp_mmu.c +1 -2
index 377a96718a2e..a29ebff1cfa0 100644
@@ -1031,7 +1031,7 @@ bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range,
 {
        struct kvm_mmu_page *root;
 
-       for_each_tdp_mmu_root(kvm, root, range->slot->as_id)
+       for_each_tdp_mmu_root_yield_safe(kvm, root, range->slot->as_id, false)
                flush |= zap_gfn_range(kvm, root, range->start, range->end,
                                       range->may_block, flush, false);
 
--

2.34.0.rc2.393.gf8c9666880-goog

maintainer Applied
#2 lore raw
In reply to Sean Christopherson
Quoted 17 lines · Sean Christopherson

Use the yield-safe variant of the TDP MMU iterator when handling an unmapping event from the MMU notifier, as most occurences of the event allow yielding.

Fixes e1eed5847b09 ("KVM: x86/mmu: Allow yielding during MMU notifier unmap/zap, if possible")
---
  arch/x86/kvm/mmu/tdp_mmu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/tdp_mmu.c +0 -0
index 377a96718a2e..a29ebff1cfa0 100644

arch/x86/kvm/mmu/tdp_mmu.c bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range, · line 1037

Quoted 8 lines
arch/x86/kvm/mmu/tdp_mmu.c +1 -1
@@ -1031,7 +1031,7 @@ bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range,
  {
  	struct kvm_mmu_page *root;
 
-	for_each_tdp_mmu_root(kvm, root, range->slot->as_id)
+	for_each_tdp_mmu_root_yield_safe(kvm, root, range->slot->as_id, false)
  		flush |= zap_gfn_range(kvm, root, range->start, range->end,
  				       range->may_block, flush, false);
 

Queued, thanks.

Paolo