KVM: x86: Move kvm_intr_is_single_vcpu() to lapic.c

Move kvm_intr_is_single_vcpu() to lapic.c, drop its export, and make its
"fast" helper local to lapic.c. kvm_intr_is_single_vcpu() is only usable
if the local APIC is in-kernel, i.e. it most definitely belongs in the
local APIC code.

No functional change intended.

Fixes: cf04ec393ed0 ("KVM: x86: Dedup AVIC vs. PI code for identifying target vCPU")
Link: https://lore.kernel.org/r/20250919003303.1355064-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Sean Christopherson and committed by
Paolo Bonzini
d273b52b 20c48920

+33 -35
-3
arch/x86/include/asm/kvm_host.h
··· 2416 2416 bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu); 2417 2417 bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu); 2418 2418 2419 - bool kvm_intr_is_single_vcpu(struct kvm *kvm, struct kvm_lapic_irq *irq, 2420 - struct kvm_vcpu **dest_vcpu); 2421 - 2422 2419 static inline bool kvm_irq_is_postable(struct kvm_lapic_irq *irq) 2423 2420 { 2424 2421 /* We can only post Fixed and LowPrio IRQs */
-28
arch/x86/kvm/irq.c
··· 354 354 return 0; 355 355 } 356 356 357 - bool kvm_intr_is_single_vcpu(struct kvm *kvm, struct kvm_lapic_irq *irq, 358 - struct kvm_vcpu **dest_vcpu) 359 - { 360 - int r = 0; 361 - unsigned long i; 362 - struct kvm_vcpu *vcpu; 363 - 364 - if (kvm_intr_is_single_vcpu_fast(kvm, irq, dest_vcpu)) 365 - return true; 366 - 367 - kvm_for_each_vcpu(i, vcpu, kvm) { 368 - if (!kvm_apic_present(vcpu)) 369 - continue; 370 - 371 - if (!kvm_apic_match_dest(vcpu, NULL, irq->shorthand, 372 - irq->dest_id, irq->dest_mode)) 373 - continue; 374 - 375 - if (++r == 2) 376 - return false; 377 - 378 - *dest_vcpu = vcpu; 379 - } 380 - 381 - return r == 1; 382 - } 383 - EXPORT_SYMBOL_GPL(kvm_intr_is_single_vcpu); 384 - 385 357 void kvm_scan_ioapic_irq(struct kvm_vcpu *vcpu, u32 dest_id, u16 dest_mode, 386 358 u8 vector, unsigned long *ioapic_handled_vectors) 387 359 {
+31 -2
arch/x86/kvm/lapic.c
··· 1237 1237 * interrupt. 1238 1238 * - Otherwise, use remapped mode to inject the interrupt. 1239 1239 */ 1240 - bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, struct kvm_lapic_irq *irq, 1241 - struct kvm_vcpu **dest_vcpu) 1240 + static bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, 1241 + struct kvm_lapic_irq *irq, 1242 + struct kvm_vcpu **dest_vcpu) 1242 1243 { 1243 1244 struct kvm_apic_map *map; 1244 1245 unsigned long bitmap; ··· 1265 1264 rcu_read_unlock(); 1266 1265 return ret; 1267 1266 } 1267 + 1268 + bool kvm_intr_is_single_vcpu(struct kvm *kvm, struct kvm_lapic_irq *irq, 1269 + struct kvm_vcpu **dest_vcpu) 1270 + { 1271 + int r = 0; 1272 + unsigned long i; 1273 + struct kvm_vcpu *vcpu; 1274 + 1275 + if (kvm_intr_is_single_vcpu_fast(kvm, irq, dest_vcpu)) 1276 + return true; 1277 + 1278 + kvm_for_each_vcpu(i, vcpu, kvm) { 1279 + if (!kvm_apic_present(vcpu)) 1280 + continue; 1281 + 1282 + if (!kvm_apic_match_dest(vcpu, NULL, irq->shorthand, 1283 + irq->dest_id, irq->dest_mode)) 1284 + continue; 1285 + 1286 + if (++r == 2) 1287 + return false; 1288 + 1289 + *dest_vcpu = vcpu; 1290 + } 1291 + 1292 + return r == 1; 1293 + } 1294 + EXPORT_SYMBOL_GPL(kvm_intr_is_single_vcpu); 1268 1295 1269 1296 int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, 1270 1297 struct kvm_lapic_irq *irq, struct dest_map *dest_map)
+2 -2
arch/x86/kvm/lapic.h
··· 236 236 void kvm_bitmap_or_dest_vcpus(struct kvm *kvm, struct kvm_lapic_irq *irq, 237 237 unsigned long *vcpu_bitmap); 238 238 239 - bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, struct kvm_lapic_irq *irq, 240 - struct kvm_vcpu **dest_vcpu); 239 + bool kvm_intr_is_single_vcpu(struct kvm *kvm, struct kvm_lapic_irq *irq, 240 + struct kvm_vcpu **dest_vcpu); 241 241 void kvm_lapic_switch_to_sw_timer(struct kvm_vcpu *vcpu); 242 242 void kvm_lapic_switch_to_hv_timer(struct kvm_vcpu *vcpu); 243 243 void kvm_lapic_expired_hv_timer(struct kvm_vcpu *vcpu);