Skip to content

Commit a211363

Browse files
Sean Christophersonbonzini
Sean Christopherson
authored andcommitted
KVM: x86/mmu: Split remote_flush+zap case out of kvm_mmu_flush_or_zap()
...and into a separate helper, kvm_mmu_remote_flush_or_zap(), that does not require a vcpu so that the code can be (re)used by kvm_mmu_invalidate_zap_pages_in_memslot(). Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 85875a1 commit a211363

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

arch/x86/kvm/mmu.c

+16-6
Original file line numberDiff line numberDiff line change
@@ -2240,18 +2240,28 @@ static bool __kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
22402240
return true;
22412241
}
22422242

2243+
static bool kvm_mmu_remote_flush_or_zap(struct kvm *kvm,
2244+
struct list_head *invalid_list,
2245+
bool remote_flush)
2246+
{
2247+
if (!remote_flush && !list_empty(invalid_list))
2248+
return false;
2249+
2250+
if (!list_empty(invalid_list))
2251+
kvm_mmu_commit_zap_page(kvm, invalid_list);
2252+
else
2253+
kvm_flush_remote_tlbs(kvm);
2254+
return true;
2255+
}
2256+
22432257
static void kvm_mmu_flush_or_zap(struct kvm_vcpu *vcpu,
22442258
struct list_head *invalid_list,
22452259
bool remote_flush, bool local_flush)
22462260
{
2247-
if (!list_empty(invalid_list)) {
2248-
kvm_mmu_commit_zap_page(vcpu->kvm, invalid_list);
2261+
if (kvm_mmu_remote_flush_or_zap(vcpu->kvm, invalid_list, remote_flush))
22492262
return;
2250-
}
22512263

2252-
if (remote_flush)
2253-
kvm_flush_remote_tlbs(vcpu->kvm);
2254-
else if (local_flush)
2264+
if (local_flush)
22552265
kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
22562266
}
22572267

0 commit comments

Comments
 (0)