KVM: arm64, x86: make kvm_arch_has_irq_bypass() inline
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 18 Apr 2025 17:03:08 +0000 (13:03 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 24 Apr 2025 13:46:58 +0000 (09:46 -0400)
kvm_arch_has_irq_bypass() is a small function and even though it does
not appear in any *really* hot paths, it's also not entirely rare.
Make it inline---it also works out nicely in preparation for using it in
kvm-intel.ko and kvm-amd.ko, since the function is not currently exported.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/arm.c
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/x86.c

index e98cfe7855a62427c9445e45f951955e42ee230c..08ba91e6fb035a1dab1304327e4f596bede3b6f8 100644 (file)
@@ -1588,4 +1588,9 @@ void kvm_set_vm_id_reg(struct kvm *kvm, u32 reg, u64 val);
 #define kvm_has_s1poe(k)                               \
        (kvm_has_feat((k), ID_AA64MMFR3_EL1, S1POE, IMP))
 
+static inline bool kvm_arch_has_irq_bypass(void)
+{
+       return true;
+}
+
 #endif /* __ARM64_KVM_HOST_H__ */
index 68fec8c95feef96d6c73c4fdbc69729518c69b70..19ca57def6292bbbf0fcb1957de9158a6237eb16 100644 (file)
@@ -2743,11 +2743,6 @@ bool kvm_arch_irqchip_in_kernel(struct kvm *kvm)
        return irqchip_in_kernel(kvm);
 }
 
-bool kvm_arch_has_irq_bypass(void)
-{
-       return true;
-}
-
 int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
                                      struct irq_bypass_producer *prod)
 {
index 3bdae454a95976dcde8ec7d9bc1365c19ed3af71..7bc174a1f1cb8c7f1c3278a1b0fea2a7e717ad27 100644 (file)
@@ -35,6 +35,7 @@
 #include <asm/mtrr.h>
 #include <asm/msr-index.h>
 #include <asm/asm.h>
+#include <asm/irq_remapping.h>
 #include <asm/kvm_page_track.h>
 #include <asm/kvm_vcpu_regs.h>
 #include <asm/reboot.h>
@@ -2423,4 +2424,9 @@ int memslot_rmap_alloc(struct kvm_memory_slot *slot, unsigned long npages);
  */
 #define KVM_EXIT_HYPERCALL_MBZ         GENMASK_ULL(31, 1)
 
+static inline bool kvm_arch_has_irq_bypass(void)
+{
+       return enable_apicv && irq_remapping_cap(IRQ_POSTING_CAP);
+}
+
 #endif /* _ASM_X86_KVM_HOST_H */
index 3712dde0bf9d1fb829d58708725ad5d8136a716f..c1fdd527044c97d1c64fa67129f689f6db8706a2 100644 (file)
@@ -13556,11 +13556,6 @@ bool kvm_arch_has_noncoherent_dma(struct kvm *kvm)
 }
 EXPORT_SYMBOL_GPL(kvm_arch_has_noncoherent_dma);
 
-bool kvm_arch_has_irq_bypass(void)
-{
-       return enable_apicv && irq_remapping_cap(IRQ_POSTING_CAP);
-}
-
 int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
                                      struct irq_bypass_producer *prod)
 {