diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2019-06-14 09:33:55 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2019-06-14 09:33:55 +0100 |
commit | 5ec2eca83dc478ddf24077e02a8b34dd26cd3ff9 (patch) | |
tree | af310ae59f9d697ba784c8b745df4575d54ec8ef /hw/vfio/platform.c | |
parent | d1bf88e56f46c75d472dc60c02bbbc7b474519f9 (diff) | |
parent | 201a733145751aa691e7e3b9c0f263f0c92db0c5 (diff) |
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-updates-20190613.0' into staging
VFIO updates 2019-06-13
- Hide resizable BAR capability to prevent false guest resizing
(Alex Williamson)
- Allow relocation to fix bogus MSI-X hardware (Alex Williamson)
- Condense IRQ setup into a common helper (Eric Auger)
# gpg: Signature made Thu 13 Jun 2019 18:24:43 BST
# gpg: using RSA key 239B9B6E3BB08B22
# gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>" [full]
# gpg: aka "Alex Williamson <alex@shazbot.org>" [full]
# gpg: aka "Alex Williamson <alwillia@redhat.com>" [full]
# gpg: aka "Alex Williamson <alex.l.williamson@gmail.com>" [full]
# Primary key fingerprint: 42F6 C04E 540B D1A9 9E7B 8A90 239B 9B6E 3BB0 8B22
* remotes/awilliam/tags/vfio-updates-20190613.0:
vfio/common: Introduce vfio_set_irq_signaling helper
vfio/pci: Allow MSI-X relocation to fixup bogus PBA
vfio/pci: Hide Resizable BAR capability
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/vfio/platform.c')
-rw-r--r-- | hw/vfio/platform.c | 68 |
1 files changed, 23 insertions, 45 deletions
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index ad29725955..622e609fb4 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -107,26 +107,19 @@ static int vfio_set_trigger_eventfd(VFIOINTp *intp, eventfd_user_side_handler_t handler) { VFIODevice *vbasedev = &intp->vdev->vbasedev; - struct vfio_irq_set *irq_set; - int argsz, ret; - int32_t *pfd; - - argsz = sizeof(*irq_set) + sizeof(*pfd); - irq_set = g_malloc0(argsz); - irq_set->argsz = argsz; - irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER; - irq_set->index = intp->pin; - irq_set->start = 0; - irq_set->count = 1; - pfd = (int32_t *)&irq_set->data; - *pfd = event_notifier_get_fd(intp->interrupt); - qemu_set_fd_handler(*pfd, (IOHandler *)handler, NULL, intp); - ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set); - if (ret < 0) { - error_report("vfio: Failed to set trigger eventfd: %m"); - qemu_set_fd_handler(*pfd, NULL, NULL, NULL); - } - g_free(irq_set); + int32_t fd = event_notifier_get_fd(intp->interrupt); + Error *err = NULL; + int ret; + + qemu_set_fd_handler(fd, (IOHandler *)handler, NULL, intp); + + ret = vfio_set_irq_signaling(vbasedev, intp->pin, 0, + VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err); + if (ret) { + error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); + qemu_set_fd_handler(fd, NULL, NULL, NULL); + } + return ret; } @@ -331,7 +324,6 @@ static void vfio_platform_eoi(VFIODevice *vbasedev) static void vfio_start_eventfd_injection(SysBusDevice *sbdev, qemu_irq irq) { - int ret; VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(sbdev); VFIOINTp *intp; @@ -342,10 +334,7 @@ static void vfio_start_eventfd_injection(SysBusDevice *sbdev, qemu_irq irq) } assert(intp); - ret = vfio_set_trigger_eventfd(intp, vfio_intp_interrupt); - if (ret) { - error_report("vfio: failed to start eventfd signaling for IRQ %d: %m", - intp->pin); + if (vfio_set_trigger_eventfd(intp, vfio_intp_interrupt)) { abort(); } } @@ -362,25 +351,16 @@ static void vfio_start_eventfd_injection(SysBusDevice *sbdev, qemu_irq irq) */ static int vfio_set_resample_eventfd(VFIOINTp *intp) { + int32_t fd = event_notifier_get_fd(intp->unmask); VFIODevice *vbasedev = &intp->vdev->vbasedev; - struct vfio_irq_set *irq_set; - int argsz, ret; - int32_t *pfd; - - argsz = sizeof(*irq_set) + sizeof(*pfd); - irq_set = g_malloc0(argsz); - irq_set->argsz = argsz; - irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_UNMASK; - irq_set->index = intp->pin; - irq_set->start = 0; - irq_set->count = 1; - pfd = (int32_t *)&irq_set->data; - *pfd = event_notifier_get_fd(intp->unmask); - qemu_set_fd_handler(*pfd, NULL, NULL, NULL); - ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set); - g_free(irq_set); - if (ret < 0) { - error_report("vfio: Failed to set resample eventfd: %m"); + Error *err = NULL; + int ret; + + qemu_set_fd_handler(fd, NULL, NULL, NULL); + ret = vfio_set_irq_signaling(vbasedev, intp->pin, 0, + VFIO_IRQ_SET_ACTION_UNMASK, fd, &err); + if (ret) { + error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); } return ret; } @@ -436,8 +416,6 @@ static void vfio_start_irqfd_injection(SysBusDevice *sbdev, qemu_irq irq) return; fail_vfio: kvm_irqchip_remove_irqfd_notifier(kvm_state, intp->interrupt, irq); - error_report("vfio: failed to start eventfd signaling for IRQ %d: %m", - intp->pin); abort(); fail_irqfd: vfio_start_eventfd_injection(sbdev, irq); |