Skip to content

Commit 15daa58

Browse files
committed
KVM: x86: Add kvm_icr_to_lapic_irq() helper to allow for fastpath IPIs
Extract the code for converting an ICR message into a kvm_lapic_irq structure into a local helper so that a fast-only IPI path can share the conversion logic. No functional change intended. Link: https://lore.kernel.org/r/20250805190526.1453366-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent cc63f91 commit 15daa58

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

arch/x86/kvm/lapic.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,24 +1474,30 @@ void kvm_apic_set_eoi_accelerated(struct kvm_vcpu *vcpu, int vector)
14741474
}
14751475
EXPORT_SYMBOL_GPL(kvm_apic_set_eoi_accelerated);
14761476

1477-
void kvm_apic_send_ipi(struct kvm_lapic *apic, u32 icr_low, u32 icr_high)
1477+
static void kvm_icr_to_lapic_irq(struct kvm_lapic *apic, u32 icr_low,
1478+
u32 icr_high, struct kvm_lapic_irq *irq)
14781479
{
1479-
struct kvm_lapic_irq irq;
1480-
14811480
/* KVM has no delay and should always clear the BUSY/PENDING flag. */
14821481
WARN_ON_ONCE(icr_low & APIC_ICR_BUSY);
14831482

1484-
irq.vector = icr_low & APIC_VECTOR_MASK;
1485-
irq.delivery_mode = icr_low & APIC_MODE_MASK;
1486-
irq.dest_mode = icr_low & APIC_DEST_MASK;
1487-
irq.level = (icr_low & APIC_INT_ASSERT) != 0;
1488-
irq.trig_mode = icr_low & APIC_INT_LEVELTRIG;
1489-
irq.shorthand = icr_low & APIC_SHORT_MASK;
1490-
irq.msi_redir_hint = false;
1483+
irq->vector = icr_low & APIC_VECTOR_MASK;
1484+
irq->delivery_mode = icr_low & APIC_MODE_MASK;
1485+
irq->dest_mode = icr_low & APIC_DEST_MASK;
1486+
irq->level = (icr_low & APIC_INT_ASSERT) != 0;
1487+
irq->trig_mode = icr_low & APIC_INT_LEVELTRIG;
1488+
irq->shorthand = icr_low & APIC_SHORT_MASK;
1489+
irq->msi_redir_hint = false;
14911490
if (apic_x2apic_mode(apic))
1492-
irq.dest_id = icr_high;
1491+
irq->dest_id = icr_high;
14931492
else
1494-
irq.dest_id = GET_XAPIC_DEST_FIELD(icr_high);
1493+
irq->dest_id = GET_XAPIC_DEST_FIELD(icr_high);
1494+
}
1495+
1496+
void kvm_apic_send_ipi(struct kvm_lapic *apic, u32 icr_low, u32 icr_high)
1497+
{
1498+
struct kvm_lapic_irq irq;
1499+
1500+
kvm_icr_to_lapic_irq(apic, icr_low, icr_high, &irq);
14951501

14961502
trace_kvm_apic_ipi(icr_low, irq.dest_id);
14971503

0 commit comments

Comments
 (0)