Re: [PATCH 2/3] pci-assign: Use PCI-2.3-based shared legacy interrupts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2012-03-07 at 18:19 +0100, Jan Kiszka wrote:
> 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.
> 
> The feature is controlled by the property 'share_intx' and is off by
> default for now.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
> ---
>  hw/device-assignment.c |   21 +++++++++++++++++++++
>  hw/device-assignment.h |   10 ++++++----
>  qemu-kvm.c             |    9 +++++++++
>  qemu-kvm.h             |    2 ++
>  4 files changed, 38 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index 0e2c7b5..45e7913 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -782,6 +782,13 @@ static int assign_device(AssignedDevice *dev)
>                  "cause host memory corruption if the device issues DMA write "
>                  "requests!\n");
>      }
> +    if (dev->features & ASSIGNED_DEVICE_SHARE_INTX_MASK) {
> +        assigned_dev_data.flags |= KVM_DEV_ASSIGN_PCI_2_3;
> +
> +        /* hide host-side INTx masking from the guest */
> +        dev->emulate_config_read[PCI_COMMAND + 1] |=
> +            PCI_COMMAND_INTX_DISABLE >> 8;
> +    }
>  
>      r = kvm_assign_pci_device(kvm_state, &assigned_dev_data);
>      if (r < 0) {
> @@ -1122,9 +1129,21 @@ static void assigned_dev_pci_write_config(PCIDevice *pci_dev, uint32_t address,
>  {
>      AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
>      uint32_t emulate_mask, full_emulation_mask;
> +    int ret;
>  
>      pci_default_write_config(pci_dev, address, val, len);
>  
> +    if (range_covers_byte(address, len, PCI_COMMAND + 1)) {
> +        bool intx_masked = (pci_get_word(pci_dev->config + PCI_COMMAND) &
> +                            PCI_COMMAND_INTX_DISABLE);
> +
> +        ret = kvm_device_intx_set_mask(kvm_state,
> +                                       calc_assigned_dev_id(assigned_dev),
> +                                       intx_masked);
> +        if (ret) {
> +            perror("assigned_dev_pci_write_config: set intx mask");
> +        }
> +    }

Can we be a little more strategic and only call intx_set_mask when the
bit changes?  Looks ok otherwise.  Thanks,

Alex


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux