devices: pci: fix registration of PCI IRQs

MPTABLE needs the PCI device number, not the IRQ; modify the information
passed via pci_irqs so that it contains a (device index, interrupt pin)
tuple.

Change-Id: Ia1dcb478cdab6654087925093ef9d1204edb21c9
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1237362
Reviewed-by: Dylan Reid <dgreid@chromium.org>
This commit is contained in:
Dylan Reid 2018-09-17 14:42:59 -07:00 committed by chrome-bot
parent 90c6ad029f
commit 9f2bbc8a91
2 changed files with 5 additions and 2 deletions

View file

@ -157,8 +157,11 @@ pub fn generate_pci_root(devices: Vec<(Box<PciDevice + 'static>, Minijail)>,
3 => PciInterruptPin::IntD,
_ => panic!(""), // Obviously not possible, but the compiler is not smart enough.
};
vm.register_irqfd(&irqfd, irq_num)
.map_err(DeviceRegistrationError::RegisterIrqfd)?;
keep_fds.push(irqfd.as_raw_fd());
device.assign_irq(irqfd, irq_num, pci_irq_pin);
pci_irqs.push((irq_num, pci_irq_pin));
pci_irqs.push((dev_idx as u32, pci_irq_pin));
let ranges = device
.allocate_io_bars(resources)

View file

@ -251,7 +251,7 @@ pub fn setup_mptable(mem: &GuestMemory, num_cpus: u8,
mpc_intsrc.irqtype = mp_irq_source_types_mp_INT as u8;
mpc_intsrc.irqflag = MP_IRQDIR_DEFAULT as u16;
mpc_intsrc.srcbus = PCI_BUS_ID;
mpc_intsrc.srcbusirq = 1 << 2 | pci_irq.1.to_mask() as u8; // slot <<2 | int A(0)
mpc_intsrc.srcbusirq = (pci_irq.0 as u8 + 1) << 2 | pci_irq.1.to_mask() as u8;
mpc_intsrc.dstapic = ioapicid;
mpc_intsrc.dstirq = 5 + i as u8;
mem.write_obj_at_addr(mpc_intsrc, base_mp)