Am 14.12.2010 01:16, Alex Williamson wrote: > On Tue, 2010-12-14 at 00:25 +0100, Jan Kiszka wrote: >> From: Jan Kiszka <jan.kiszka@xxxxxxxxxxx> >> >> Enable the new KVM feature that allows legacy interrupt sharing for >> PCI-2.3-compliant devices. This requires to synchronize any guest >> change of the INTx mask bit to the kernel. >> >> Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx> >> --- >> hw/device-assignment.c | 38 +++++++++++++++++++++++++++++++++----- >> qemu-kvm.c | 8 ++++++++ >> qemu-kvm.h | 3 +++ >> 3 files changed, 44 insertions(+), 5 deletions(-) >> >> diff --git a/hw/device-assignment.c b/hw/device-assignment.c >> index 26d3bd7..cf75c52 100644 >> --- a/hw/device-assignment.c >> +++ b/hw/device-assignment.c >> @@ -423,12 +423,21 @@ static uint8_t pci_find_cap_offset(PCIDevice *d, uint8_t cap, uint8_t start) >> return 0; >> } >> >> +static uint32_t calc_assigned_dev_id(uint16_t seg, uint8_t bus, uint8_t devfn) >> +{ >> + return (uint32_t)seg << 16 | (uint32_t)bus << 8 | (uint32_t)devfn; >> +} >> + >> static void assigned_dev_pci_write_config(PCIDevice *d, uint32_t address, >> uint32_t val, int len) >> { >> int fd; >> ssize_t ret; >> AssignedDevice *pci_dev = container_of(d, AssignedDevice, dev); >> + struct kvm_assigned_pci_dev assigned_dev_data; >> +#ifdef KVM_CAP_PCI_2_3 >> + bool intx_masked, update_intx_mask; >> +#endif /* KVM_CAP_PCI_2_3 */ >> >> DEBUG("(%x.%x): address=%04x val=0x%08x len=%d\n", >> ((d->devfn >> 3) & 0x1F), (d->devfn & 0x7), >> @@ -439,6 +448,26 @@ static void assigned_dev_pci_write_config(PCIDevice *d, uint32_t address, >> } >> >> if (ranges_overlap(address, len, PCI_COMMAND, 2)) { >> +#ifdef KVM_CAP_PCI_2_3 >> + update_intx_mask = false; >> + if (address == PCI_COMMAND+1) { >> + intx_masked = val & (PCI_COMMAND_INTX_DISABLE >> 8); >> + update_intx_mask = true; >> + } else if (len >= 2) { >> + intx_masked = val & PCI_COMMAND_INTX_DISABLE; >> + update_intx_mask = true; >> + } > > I wonder if this might be a little cleaner as something like this. > > if (ranges_overlap(address, len, PCI_COMMAND + 1, 1) { > update_intx_mask = true; > intx_masked = (len == 1 ? val << 8 : val) & PCI_COMMAND_INTX_DISABLE; > } That should even obsolete update_intx_mask - will look into this, and also the merge bits thing. Thanks! Jan
Attachment:
signature.asc
Description: OpenPGP digital signature