KVM: x86/mmu: Collapse kvm_flush_remote_tlbs_with_{range,address}() together
authorDavid Matlack <dmatlack@google.com>
Thu, 26 Jan 2023 18:40:21 +0000 (10:40 -0800)
committerSean Christopherson <seanjc@google.com>
Fri, 17 Mar 2023 22:08:41 +0000 (15:08 -0700)
Collapse kvm_flush_remote_tlbs_with_range() and
kvm_flush_remote_tlbs_with_address() into a single function. This
eliminates some lines of code and a useless NULL check on the range
struct.

Opportunistically switch from ENOTSUPP to EOPNOTSUPP to make checkpatch
happy.

Signed-off-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20230126184025.2294823-4-dmatlack@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/mmu.c

index 9655656dce50c13eadf6d3f4dc6bf58b882c470b..ed1df733f12a5fe5b92fc66c5b5f006114bc9d18 100644 (file)
@@ -261,27 +261,20 @@ static inline bool kvm_available_flush_tlb_with_range(void)
        return kvm_x86_ops.tlb_remote_flush_with_range;
 }
 
-static void kvm_flush_remote_tlbs_with_range(struct kvm *kvm,
-               struct kvm_tlb_range *range)
-{
-       int ret = -ENOTSUPP;
-
-       if (range && kvm_x86_ops.tlb_remote_flush_with_range)
-               ret = static_call(kvm_x86_tlb_remote_flush_with_range)(kvm, range);
-
-       if (ret)
-               kvm_flush_remote_tlbs(kvm);
-}
-
 void kvm_flush_remote_tlbs_with_address(struct kvm *kvm,
                u64 start_gfn, u64 pages)
 {
        struct kvm_tlb_range range;
+       int ret = -EOPNOTSUPP;
 
        range.start_gfn = start_gfn;
        range.pages = pages;
 
-       kvm_flush_remote_tlbs_with_range(kvm, &range);
+       if (kvm_x86_ops.tlb_remote_flush_with_range)
+               ret = static_call(kvm_x86_tlb_remote_flush_with_range)(kvm, &range);
+
+       if (ret)
+               kvm_flush_remote_tlbs(kvm);
 }
 
 static gfn_t kvm_mmu_page_get_gfn(struct kvm_mmu_page *sp, int index);