@@ -1624,6 +1624,7 @@ struct kvm_lapic_irq {
u32 shorthand;
u32 dest_id;
bool msi_redir_hint;
+ unsigned int target_vmpl;
};
static inline u16 kvm_lapic_irq_dest_mode(bool dest_mode_logical)
@@ -413,6 +413,8 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
irq.shorthand = APIC_DEST_NOSHORT;
irq.dest_id = e->fields.dest_id;
irq.msi_redir_hint = false;
+ irq.target_vmpl = ioapic->kvm->arch.default_irq_vmpl;
+
bitmap_zero(vcpu_bitmap, KVM_MAX_VCPUS);
kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
vcpu_bitmap);
@@ -458,6 +460,7 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
irqe.level = 1;
irqe.shorthand = APIC_DEST_NOSHORT;
irqe.msi_redir_hint = false;
+ irqe.target_vmpl = ioapic->kvm->arch.default_irq_vmpl;
if (irqe.trig_mode == IOAPIC_EDGE_TRIG)
ioapic->irr_delivered |= 1 << irq;
@@ -119,6 +119,7 @@ void kvm_set_msi_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e,
irq->msi_redir_hint = msg.arch_addr_lo.redirect_hint;
irq->level = 1;
irq->shorthand = APIC_DEST_NOSHORT;
+ irq->target_vmpl = kvm->arch.default_irq_vmpl;
}
EXPORT_SYMBOL_GPL(kvm_set_msi_irq);
@@ -836,7 +836,9 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq,
struct dest_map *dest_map)
{
- struct kvm_lapic *apic = vcpu->arch.apic;
+ struct kvm_lapic *apic = vcpu->vcpu_parent->vcpu_vmpl[irq->target_vmpl]->arch.apic;
+ if (!apic)
+ return -EINVAL;
return __apic_accept_irq(apic, irq->delivery_mode, irq->vector,
irq->level, irq->trig_mode, dest_map);
@@ -1528,6 +1530,8 @@ void kvm_apic_send_ipi(struct kvm_lapic *apic, u32 icr_low, u32 icr_high)
irq.trig_mode = icr_low & APIC_INT_LEVELTRIG;
irq.shorthand = icr_low & APIC_SHORT_MASK;
irq.msi_redir_hint = false;
+ /* IPIs always target the same VMPL as the source */
+ irq.target_vmpl = apic->vcpu->vmpl;
if (apic_x2apic_mode(apic))
irq.dest_id = icr_high;
else
Systems that support VMPLs need to decide which VMPL each IRQ is destined for; each VMPL can support its own set of hardware devices that generate interrupts. This commit extends kvm_lapic_irq to include a target_vmpl field the sends the IRQ to the APIC instance at the target VMPL. Signed-off-by: Roy Hopkins <roy.hopkins@suse.com> --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/ioapic.c | 3 +++ arch/x86/kvm/irq_comm.c | 1 + arch/x86/kvm/lapic.c | 6 +++++- 4 files changed, 10 insertions(+), 1 deletion(-)