Skip to content

Commit 0c22056

Browse files
Nitesh Narayan Lalbonzini
authored andcommitted
KVM: x86: Initializing all kvm_lapic_irq fields in ioapic_write_indirect
Previously all fields of structure kvm_lapic_irq were not initialized before it was passed to kvm_bitmap_or_dest_vcpus(). Which will cause an issue when any of those fields are used for processing a request. For example not initializing the msi_redir_hint field before passing to the kvm_bitmap_or_dest_vcpus(), may lead to a misbehavior of kvm_apic_map_get_dest_lapic(). This will specifically happen when the kvm_lowest_prio_delivery() returns TRUE due to a non-zero garbage value of msi_redir_hint, which should not happen as the request belongs to APIC fixed delivery mode and we do not want to deliver the interrupt only to the lowest priority candidate. This patch initializes all the fields of kvm_lapic_irq based on the values of ioapic redirect_entry object before passing it on to kvm_bitmap_or_dest_vcpus(). Fixes: 7ee30bc ("KVM: x86: deliver KVM IOAPIC scan request to target vCPUs") Signed-off-by: Nitesh Narayan Lal <[email protected]> Reviewed-by: Vitaly Kuznetsov <[email protected]> [Set level to false since the value doesn't really matter. Suggested by Vitaly Kuznetsov. - Paolo] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 7a57c09 commit 0c22056

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/kvm/ioapic.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
378378
if (e->fields.delivery_mode == APIC_DM_FIXED) {
379379
struct kvm_lapic_irq irq;
380380

381-
irq.shorthand = APIC_DEST_NOSHORT;
382381
irq.vector = e->fields.vector;
383382
irq.delivery_mode = e->fields.delivery_mode << 8;
384-
irq.dest_id = e->fields.dest_id;
385383
irq.dest_mode =
386384
kvm_lapic_irq_dest_mode(!!e->fields.dest_mode);
385+
irq.level = false;
386+
irq.trig_mode = e->fields.trig_mode;
387+
irq.shorthand = APIC_DEST_NOSHORT;
388+
irq.dest_id = e->fields.dest_id;
389+
irq.msi_redir_hint = false;
387390
bitmap_zero(&vcpu_bitmap, 16);
388391
kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
389392
&vcpu_bitmap);

0 commit comments

Comments
 (0)