Skip to content

Commit 28e4b45

Browse files
dmatlacksean-jc
authored andcommitted
KVM: x86/mmu: Collapse kvm_flush_remote_tlbs_with_{range,address}() together
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>
1 parent 141705b commit 28e4b45

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,27 +261,20 @@ static inline bool kvm_available_flush_tlb_with_range(void)
261261
return kvm_x86_ops.tlb_remote_flush_with_range;
262262
}
263263

264-
static void kvm_flush_remote_tlbs_with_range(struct kvm *kvm,
265-
struct kvm_tlb_range *range)
266-
{
267-
int ret = -ENOTSUPP;
268-
269-
if (range && kvm_x86_ops.tlb_remote_flush_with_range)
270-
ret = static_call(kvm_x86_tlb_remote_flush_with_range)(kvm, range);
271-
272-
if (ret)
273-
kvm_flush_remote_tlbs(kvm);
274-
}
275-
276264
void kvm_flush_remote_tlbs_with_address(struct kvm *kvm,
277265
u64 start_gfn, u64 pages)
278266
{
279267
struct kvm_tlb_range range;
268+
int ret = -EOPNOTSUPP;
280269

281270
range.start_gfn = start_gfn;
282271
range.pages = pages;
283272

284-
kvm_flush_remote_tlbs_with_range(kvm, &range);
273+
if (kvm_x86_ops.tlb_remote_flush_with_range)
274+
ret = static_call(kvm_x86_tlb_remote_flush_with_range)(kvm, &range);
275+
276+
if (ret)
277+
kvm_flush_remote_tlbs(kvm);
285278
}
286279

287280
static gfn_t kvm_mmu_page_get_gfn(struct kvm_mmu_page *sp, int index);

0 commit comments

Comments
 (0)