Skip to content

Commit d273b52

Browse files
sean-jcbonzini
authored andcommitted
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: cf04ec3 ("KVM: x86: Dedup AVIC vs. PI code for identifying target vCPU") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 20c4892 commit d273b52

File tree

4 files changed

+33
-35
lines changed

4 files changed

+33
-35
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,9 +2416,6 @@ void __user *__x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa,
24162416
bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu);
24172417
bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu);
24182418

2419-
bool kvm_intr_is_single_vcpu(struct kvm *kvm, struct kvm_lapic_irq *irq,
2420-
struct kvm_vcpu **dest_vcpu);
2421-
24222419
static inline bool kvm_irq_is_postable(struct kvm_lapic_irq *irq)
24232420
{
24242421
/* We can only post Fixed and LowPrio IRQs */

arch/x86/kvm/irq.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -354,34 +354,6 @@ int kvm_set_routing_entry(struct kvm *kvm,
354354
return 0;
355355
}
356356

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-
385357
void kvm_scan_ioapic_irq(struct kvm_vcpu *vcpu, u32 dest_id, u16 dest_mode,
386358
u8 vector, unsigned long *ioapic_handled_vectors)
387359
{

arch/x86/kvm/lapic.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,9 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
12371237
* interrupt.
12381238
* - Otherwise, use remapped mode to inject the interrupt.
12391239
*/
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)
12421243
{
12431244
struct kvm_apic_map *map;
12441245
unsigned long bitmap;
@@ -1265,6 +1266,34 @@ bool kvm_intr_is_single_vcpu_fast(struct kvm *kvm, struct kvm_lapic_irq *irq,
12651266
return ret;
12661267
}
12671268

1269+
bool kvm_intr_is_single_vcpu(struct kvm *kvm, struct kvm_lapic_irq *irq,
1270+
struct kvm_vcpu **dest_vcpu)
1271+
{
1272+
int r = 0;
1273+
unsigned long i;
1274+
struct kvm_vcpu *vcpu;
1275+
1276+
if (kvm_intr_is_single_vcpu_fast(kvm, irq, dest_vcpu))
1277+
return true;
1278+
1279+
kvm_for_each_vcpu(i, vcpu, kvm) {
1280+
if (!kvm_apic_present(vcpu))
1281+
continue;
1282+
1283+
if (!kvm_apic_match_dest(vcpu, NULL, irq->shorthand,
1284+
irq->dest_id, irq->dest_mode))
1285+
continue;
1286+
1287+
if (++r == 2)
1288+
return false;
1289+
1290+
*dest_vcpu = vcpu;
1291+
}
1292+
1293+
return r == 1;
1294+
}
1295+
EXPORT_SYMBOL_GPL(kvm_intr_is_single_vcpu);
1296+
12681297
int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
12691298
struct kvm_lapic_irq *irq, struct dest_map *dest_map)
12701299
{

arch/x86/kvm/lapic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ void kvm_wait_lapic_expire(struct kvm_vcpu *vcpu);
236236
void kvm_bitmap_or_dest_vcpus(struct kvm *kvm, struct kvm_lapic_irq *irq,
237237
unsigned long *vcpu_bitmap);
238238

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);
241241
void kvm_lapic_switch_to_sw_timer(struct kvm_vcpu *vcpu);
242242
void kvm_lapic_switch_to_hv_timer(struct kvm_vcpu *vcpu);
243243
void kvm_lapic_expired_hv_timer(struct kvm_vcpu *vcpu);

0 commit comments

Comments
 (0)