|
|
5d360b |
From c0cad7dde740ad701c4a095c607970e1f76ad720 Mon Sep 17 00:00:00 2001
|
|
|
5d360b |
From: Alex Williamson <alex.williamson@redhat.com>
|
|
|
5d360b |
Date: Fri, 29 Sep 2017 21:44:12 +0200
|
|
|
5d360b |
Subject: [PATCH 02/27] hw/vfio/pci: Rename VFIODevice into VFIOPCIDevice
|
|
|
5d360b |
|
|
|
5d360b |
RH-Author: Alex Williamson <alex.williamson@redhat.com>
|
|
|
5d360b |
Message-id: <20170929214412.16765.59126.stgit@gimli.home>
|
|
|
5d360b |
Patchwork-id: 76760
|
|
|
5d360b |
O-Subject: [RHEL-7.5 qemu-kvm PATCH 02/16] hw/vfio/pci: Rename VFIODevice into VFIOPCIDevice
|
|
|
5d360b |
Bugzilla: 1494181
|
|
|
5d360b |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
5d360b |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
5d360b |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
5d360b |
|
|
|
5d360b |
From: Eric Auger <eric.auger@linaro.org>
|
|
|
5d360b |
|
|
|
5d360b |
Upstream: 9ee27d7381c2d540ee976c7cbae941c66bb66e70
|
|
|
5d360b |
RHEL: Request notifier didn't exist upstream yet, included in change.
|
|
|
5d360b |
|
|
|
5d360b |
This prepares for the introduction of VFIOPlatformDevice
|
|
|
5d360b |
|
|
|
5d360b |
Signed-off-by: Eric Auger <eric.auger@linaro.org>
|
|
|
5d360b |
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
|
|
|
5d360b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
5d360b |
---
|
|
|
5d360b |
hw/misc/vfio.c | 209 +++++++++++++++++++++++++++++----------------------------
|
|
|
5d360b |
1 file changed, 105 insertions(+), 104 deletions(-)
|
|
|
5d360b |
|
|
|
5d360b |
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
|
|
|
5d360b |
index 363c646..a1ca883 100644
|
|
|
5d360b |
--- a/hw/misc/vfio.c
|
|
|
5d360b |
+++ b/hw/misc/vfio.c
|
|
|
5d360b |
@@ -55,11 +55,11 @@
|
|
|
5d360b |
#define VFIO_ALLOW_KVM_MSI 1
|
|
|
5d360b |
#define VFIO_ALLOW_KVM_MSIX 1
|
|
|
5d360b |
|
|
|
5d360b |
-struct VFIODevice;
|
|
|
5d360b |
+struct VFIOPCIDevice;
|
|
|
5d360b |
|
|
|
5d360b |
typedef struct VFIOQuirk {
|
|
|
5d360b |
MemoryRegion mem;
|
|
|
5d360b |
- struct VFIODevice *vdev;
|
|
|
5d360b |
+ struct VFIOPCIDevice *vdev;
|
|
|
5d360b |
QLIST_ENTRY(VFIOQuirk) next;
|
|
|
5d360b |
struct {
|
|
|
5d360b |
uint32_t base_offset:TARGET_PAGE_BITS;
|
|
|
5d360b |
@@ -130,7 +130,7 @@ typedef struct VFIOMSIVector {
|
|
|
5d360b |
*/
|
|
|
5d360b |
EventNotifier interrupt;
|
|
|
5d360b |
EventNotifier kvm_interrupt;
|
|
|
5d360b |
- struct VFIODevice *vdev; /* back pointer to device */
|
|
|
5d360b |
+ struct VFIOPCIDevice *vdev; /* back pointer to device */
|
|
|
5d360b |
int virq;
|
|
|
5d360b |
bool use;
|
|
|
5d360b |
} VFIOMSIVector;
|
|
|
5d360b |
@@ -174,7 +174,7 @@ typedef struct VFIOMSIXInfo {
|
|
|
5d360b |
void *mmap;
|
|
|
5d360b |
} VFIOMSIXInfo;
|
|
|
5d360b |
|
|
|
5d360b |
-typedef struct VFIODevice {
|
|
|
5d360b |
+typedef struct VFIOPCIDevice {
|
|
|
5d360b |
PCIDevice pdev;
|
|
|
5d360b |
int fd;
|
|
|
5d360b |
VFIOINTx intx;
|
|
|
5d360b |
@@ -192,7 +192,7 @@ typedef struct VFIODevice {
|
|
|
5d360b |
VFIOBAR bars[PCI_NUM_REGIONS - 1]; /* No ROM */
|
|
|
5d360b |
VFIOVGA vga; /* 0xa0000, 0x3b0, 0x3c0 */
|
|
|
5d360b |
PCIHostDeviceAddress host;
|
|
|
5d360b |
- QLIST_ENTRY(VFIODevice) next;
|
|
|
5d360b |
+ QLIST_ENTRY(VFIOPCIDevice) next;
|
|
|
5d360b |
struct VFIOGroup *group;
|
|
|
5d360b |
EventNotifier err_notifier;
|
|
|
5d360b |
EventNotifier req_notifier;
|
|
|
5d360b |
@@ -211,13 +211,13 @@ typedef struct VFIODevice {
|
|
|
5d360b |
bool has_pm_reset;
|
|
|
5d360b |
bool needs_reset;
|
|
|
5d360b |
bool rom_read_failed;
|
|
|
5d360b |
-} VFIODevice;
|
|
|
5d360b |
+} VFIOPCIDevice;
|
|
|
5d360b |
|
|
|
5d360b |
typedef struct VFIOGroup {
|
|
|
5d360b |
int fd;
|
|
|
5d360b |
int groupid;
|
|
|
5d360b |
VFIOContainer *container;
|
|
|
5d360b |
- QLIST_HEAD(, VFIODevice) device_list;
|
|
|
5d360b |
+ QLIST_HEAD(, VFIOPCIDevice) device_list;
|
|
|
5d360b |
QLIST_ENTRY(VFIOGroup) next;
|
|
|
5d360b |
QLIST_ENTRY(VFIOGroup) container_next;
|
|
|
5d360b |
} VFIOGroup;
|
|
|
5d360b |
@@ -263,16 +263,16 @@ static QLIST_HEAD(, VFIOGroup)
|
|
|
5d360b |
*/
|
|
|
5d360b |
static int vfio_kvm_device_fd = -1;
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_disable_interrupts(VFIODevice *vdev);
|
|
|
5d360b |
+static void vfio_disable_interrupts(VFIOPCIDevice *vdev);
|
|
|
5d360b |
static uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len);
|
|
|
5d360b |
static void vfio_pci_write_config(PCIDevice *pdev, uint32_t addr,
|
|
|
5d360b |
uint32_t val, int len);
|
|
|
5d360b |
-static void vfio_mmap_set_enabled(VFIODevice *vdev, bool enabled);
|
|
|
5d360b |
+static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled);
|
|
|
5d360b |
|
|
|
5d360b |
/*
|
|
|
5d360b |
* Common VFIO interrupt disable
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_disable_irqindex(VFIODevice *vdev, int index)
|
|
|
5d360b |
+static void vfio_disable_irqindex(VFIOPCIDevice *vdev, int index)
|
|
|
5d360b |
{
|
|
|
5d360b |
struct vfio_irq_set irq_set = {
|
|
|
5d360b |
.argsz = sizeof(irq_set),
|
|
|
5d360b |
@@ -288,7 +288,7 @@ static void vfio_disable_irqindex(VFIODevice *vdev, int index)
|
|
|
5d360b |
/*
|
|
|
5d360b |
* INTx
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_unmask_intx(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_unmask_intx(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
struct vfio_irq_set irq_set = {
|
|
|
5d360b |
.argsz = sizeof(irq_set),
|
|
|
5d360b |
@@ -302,7 +302,7 @@ static void vfio_unmask_intx(VFIODevice *vdev)
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
#ifdef CONFIG_KVM /* Unused outside of CONFIG_KVM code */
|
|
|
5d360b |
-static void vfio_mask_intx(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_mask_intx(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
struct vfio_irq_set irq_set = {
|
|
|
5d360b |
.argsz = sizeof(irq_set),
|
|
|
5d360b |
@@ -333,7 +333,7 @@ static void vfio_mask_intx(VFIODevice *vdev)
|
|
|
5d360b |
*/
|
|
|
5d360b |
static void vfio_intx_mmap_enable(void *opaque)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = opaque;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = opaque;
|
|
|
5d360b |
|
|
|
5d360b |
if (vdev->intx.pending) {
|
|
|
5d360b |
qemu_mod_timer(vdev->intx.mmap_timer,
|
|
|
5d360b |
@@ -346,7 +346,7 @@ static void vfio_intx_mmap_enable(void *opaque)
|
|
|
5d360b |
|
|
|
5d360b |
static void vfio_intx_interrupt(void *opaque)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = opaque;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = opaque;
|
|
|
5d360b |
|
|
|
5d360b |
if (!event_notifier_test_and_clear(&vdev->intx.interrupt)) {
|
|
|
5d360b |
return;
|
|
|
5d360b |
@@ -365,7 +365,7 @@ static void vfio_intx_interrupt(void *opaque)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_eoi(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_eoi(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
if (!vdev->intx.pending) {
|
|
|
5d360b |
return;
|
|
|
5d360b |
@@ -379,7 +379,7 @@ static void vfio_eoi(VFIODevice *vdev)
|
|
|
5d360b |
vfio_unmask_intx(vdev);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_enable_intx_kvm(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_enable_intx_kvm(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
#ifdef CONFIG_KVM
|
|
|
5d360b |
struct kvm_irqfd irqfd = {
|
|
|
5d360b |
@@ -458,7 +458,7 @@ fail:
|
|
|
5d360b |
#endif
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_disable_intx_kvm(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_disable_intx_kvm(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
#ifdef CONFIG_KVM
|
|
|
5d360b |
struct kvm_irqfd irqfd = {
|
|
|
5d360b |
@@ -503,7 +503,7 @@ static void vfio_disable_intx_kvm(VFIODevice *vdev)
|
|
|
5d360b |
|
|
|
5d360b |
static void vfio_update_irq(PCIDevice *pdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
|
5d360b |
PCIINTxRoute route;
|
|
|
5d360b |
|
|
|
5d360b |
if (vdev->interrupt != VFIO_INT_INTx) {
|
|
|
5d360b |
@@ -534,7 +534,7 @@ static void vfio_update_irq(PCIDevice *pdev)
|
|
|
5d360b |
vfio_eoi(vdev);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_enable_intx(VFIODevice *vdev)
|
|
|
5d360b |
+static int vfio_enable_intx(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
uint8_t pin = vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1);
|
|
|
5d360b |
int ret, argsz;
|
|
|
5d360b |
@@ -599,7 +599,7 @@ static int vfio_enable_intx(VFIODevice *vdev)
|
|
|
5d360b |
return 0;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_disable_intx(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_disable_intx(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int fd;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -626,7 +626,7 @@ static void vfio_disable_intx(VFIODevice *vdev)
|
|
|
5d360b |
static void vfio_msi_interrupt(void *opaque)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOMSIVector *vector = opaque;
|
|
|
5d360b |
- VFIODevice *vdev = vector->vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = vector->vdev;
|
|
|
5d360b |
int nr = vector - vdev->msi_vectors;
|
|
|
5d360b |
|
|
|
5d360b |
if (!event_notifier_test_and_clear(&vector->interrupt)) {
|
|
|
5d360b |
@@ -658,7 +658,7 @@ static void vfio_msi_interrupt(void *opaque)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_enable_vectors(VFIODevice *vdev, bool msix)
|
|
|
5d360b |
+static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix)
|
|
|
5d360b |
{
|
|
|
5d360b |
struct vfio_irq_set *irq_set;
|
|
|
5d360b |
int ret = 0, i, argsz;
|
|
|
5d360b |
@@ -749,7 +749,7 @@ static void vfio_update_kvm_msi_virq(VFIOMSIVector *vector, MSIMessage msg)
|
|
|
5d360b |
static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
|
|
|
5d360b |
MSIMessage *msg, IOHandler *handler)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
|
5d360b |
VFIOMSIVector *vector;
|
|
|
5d360b |
int ret;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -838,7 +838,7 @@ static int vfio_msix_vector_use(PCIDevice *pdev,
|
|
|
5d360b |
|
|
|
5d360b |
static void vfio_msix_vector_release(PCIDevice *pdev, unsigned int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
|
5d360b |
VFIOMSIVector *vector = &vdev->msi_vectors[nr];
|
|
|
5d360b |
|
|
|
5d360b |
DPRINTF("%s(%04x:%02x:%02x.%x) vector %d released\n", __func__,
|
|
|
5d360b |
@@ -877,7 +877,7 @@ static void vfio_msix_vector_release(PCIDevice *pdev, unsigned int nr)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_enable_msix(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_enable_msix(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
vfio_disable_interrupts(vdev);
|
|
|
5d360b |
|
|
|
5d360b |
@@ -910,7 +910,7 @@ static void vfio_enable_msix(VFIODevice *vdev)
|
|
|
5d360b |
vdev->host.bus, vdev->host.slot, vdev->host.function);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_enable_msi(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_enable_msi(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int ret, i;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -988,7 +988,7 @@ retry:
|
|
|
5d360b |
vdev->host.function, vdev->nr_vectors);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_disable_msi_common(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_disable_msi_common(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int i;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1012,7 +1012,7 @@ static void vfio_disable_msi_common(VFIODevice *vdev)
|
|
|
5d360b |
vfio_enable_intx(vdev);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_disable_msix(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_disable_msix(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int i;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1039,7 +1039,7 @@ static void vfio_disable_msix(VFIODevice *vdev)
|
|
|
5d360b |
vdev->host.bus, vdev->host.slot, vdev->host.function);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_disable_msi(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_disable_msi(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
vfio_disable_irqindex(vdev, VFIO_PCI_MSI_IRQ_INDEX);
|
|
|
5d360b |
vfio_disable_msi_common(vdev);
|
|
|
5d360b |
@@ -1048,7 +1048,7 @@ static void vfio_disable_msi(VFIODevice *vdev)
|
|
|
5d360b |
vdev->host.bus, vdev->host.slot, vdev->host.function);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_update_msi(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_update_msi(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int i;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1101,7 +1101,7 @@ static void vfio_bar_write(void *opaque, hwaddr addr,
|
|
|
5d360b |
|
|
|
5d360b |
#ifdef DEBUG_VFIO
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = container_of(bar, VFIODevice, bars[bar->nr]);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = container_of(bar, VFIOPCIDevice, bars[bar->nr]);
|
|
|
5d360b |
|
|
|
5d360b |
DPRINTF("%s(%04x:%02x:%02x.%x:BAR%d+0x%"HWADDR_PRIx", 0x%"PRIx64
|
|
|
5d360b |
", %d)\n", __func__, vdev->host.domain, vdev->host.bus,
|
|
|
5d360b |
@@ -1118,7 +1118,7 @@ static void vfio_bar_write(void *opaque, hwaddr addr,
|
|
|
5d360b |
* which access will service the interrupt, so we're potentially
|
|
|
5d360b |
* getting quite a few host interrupts per guest interrupt.
|
|
|
5d360b |
*/
|
|
|
5d360b |
- vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
|
|
|
5d360b |
+ vfio_eoi(container_of(bar, VFIOPCIDevice, bars[bar->nr]));
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
static uint64_t vfio_bar_read(void *opaque,
|
|
|
5d360b |
@@ -1156,7 +1156,7 @@ static uint64_t vfio_bar_read(void *opaque,
|
|
|
5d360b |
|
|
|
5d360b |
#ifdef DEBUG_VFIO
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = container_of(bar, VFIODevice, bars[bar->nr]);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = container_of(bar, VFIOPCIDevice, bars[bar->nr]);
|
|
|
5d360b |
|
|
|
5d360b |
DPRINTF("%s(%04x:%02x:%02x.%x:BAR%d+0x%"HWADDR_PRIx
|
|
|
5d360b |
", %d) = 0x%"PRIx64"\n", __func__, vdev->host.domain,
|
|
|
5d360b |
@@ -1166,7 +1166,7 @@ static uint64_t vfio_bar_read(void *opaque,
|
|
|
5d360b |
#endif
|
|
|
5d360b |
|
|
|
5d360b |
/* Same as write above */
|
|
|
5d360b |
- vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
|
|
|
5d360b |
+ vfio_eoi(container_of(bar, VFIOPCIDevice, bars[bar->nr]));
|
|
|
5d360b |
|
|
|
5d360b |
return data;
|
|
|
5d360b |
}
|
|
|
5d360b |
@@ -1177,7 +1177,7 @@ static const MemoryRegionOps vfio_bar_ops = {
|
|
|
5d360b |
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
5d360b |
};
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_pci_load_rom(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_pci_load_rom(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
struct vfio_region_info reg_info = {
|
|
|
5d360b |
.argsz = sizeof(reg_info),
|
|
|
5d360b |
@@ -1235,7 +1235,7 @@ static void vfio_pci_load_rom(VFIODevice *vdev)
|
|
|
5d360b |
|
|
|
5d360b |
static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = opaque;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = opaque;
|
|
|
5d360b |
uint64_t val = ((uint64_t)1 << (size * 8)) - 1;
|
|
|
5d360b |
|
|
|
5d360b |
/* Load the ROM lazily when the guest tries to read it */
|
|
|
5d360b |
@@ -1264,7 +1264,7 @@ static const MemoryRegionOps vfio_rom_ops = {
|
|
|
5d360b |
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
5d360b |
};
|
|
|
5d360b |
|
|
|
5d360b |
-static bool vfio_blacklist_opt_rom(VFIODevice *vdev)
|
|
|
5d360b |
+static bool vfio_blacklist_opt_rom(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
uint16_t vendor_id, device_id;
|
|
|
5d360b |
@@ -1284,7 +1284,7 @@ static bool vfio_blacklist_opt_rom(VFIODevice *vdev)
|
|
|
5d360b |
return false;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_pci_size_rom(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK);
|
|
|
5d360b |
off_t offset = vdev->config_offset + PCI_ROM_ADDRESS;
|
|
|
5d360b |
@@ -1463,7 +1463,7 @@ static uint64_t vfio_generic_window_quirk_read(void *opaque,
|
|
|
5d360b |
hwaddr addr, unsigned size)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOQuirk *quirk = opaque;
|
|
|
5d360b |
- VFIODevice *vdev = quirk->vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = quirk->vdev;
|
|
|
5d360b |
uint64_t data;
|
|
|
5d360b |
|
|
|
5d360b |
if (vfio_flags_enabled(quirk->data.flags, quirk->data.read_flags) &&
|
|
|
5d360b |
@@ -1496,7 +1496,7 @@ static void vfio_generic_window_quirk_write(void *opaque, hwaddr addr,
|
|
|
5d360b |
uint64_t data, unsigned size)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOQuirk *quirk = opaque;
|
|
|
5d360b |
- VFIODevice *vdev = quirk->vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = quirk->vdev;
|
|
|
5d360b |
|
|
|
5d360b |
if (ranges_overlap(addr, size,
|
|
|
5d360b |
quirk->data.address_offset, quirk->data.address_size)) {
|
|
|
5d360b |
@@ -1550,7 +1550,7 @@ static uint64_t vfio_generic_quirk_read(void *opaque,
|
|
|
5d360b |
hwaddr addr, unsigned size)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOQuirk *quirk = opaque;
|
|
|
5d360b |
- VFIODevice *vdev = quirk->vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = quirk->vdev;
|
|
|
5d360b |
hwaddr base = quirk->data.address_match & TARGET_PAGE_MASK;
|
|
|
5d360b |
hwaddr offset = quirk->data.address_match & ~TARGET_PAGE_MASK;
|
|
|
5d360b |
uint64_t data;
|
|
|
5d360b |
@@ -1580,7 +1580,7 @@ static void vfio_generic_quirk_write(void *opaque, hwaddr addr,
|
|
|
5d360b |
uint64_t data, unsigned size)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOQuirk *quirk = opaque;
|
|
|
5d360b |
- VFIODevice *vdev = quirk->vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = quirk->vdev;
|
|
|
5d360b |
hwaddr base = quirk->data.address_match & TARGET_PAGE_MASK;
|
|
|
5d360b |
hwaddr offset = quirk->data.address_match & ~TARGET_PAGE_MASK;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1625,7 +1625,7 @@ static uint64_t vfio_ati_3c3_quirk_read(void *opaque,
|
|
|
5d360b |
hwaddr addr, unsigned size)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOQuirk *quirk = opaque;
|
|
|
5d360b |
- VFIODevice *vdev = quirk->vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = quirk->vdev;
|
|
|
5d360b |
uint64_t data = vfio_pci_read_config(&vdev->pdev,
|
|
|
5d360b |
PCI_BASE_ADDRESS_0 + (4 * 4) + 1,
|
|
|
5d360b |
size);
|
|
|
5d360b |
@@ -1639,7 +1639,7 @@ static const MemoryRegionOps vfio_ati_3c3_quirk = {
|
|
|
5d360b |
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
5d360b |
};
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_vga_probe_ati_3c3_quirk(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
VFIOQuirk *quirk;
|
|
|
5d360b |
@@ -1682,7 +1682,7 @@ static void vfio_vga_probe_ati_3c3_quirk(VFIODevice *vdev)
|
|
|
5d360b |
* that only read-only access is provided, but we drop writes when the window
|
|
|
5d360b |
* is enabled to config space nonetheless.
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_probe_ati_bar4_window_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_probe_ati_bar4_window_quirk(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
VFIOQuirk *quirk;
|
|
|
5d360b |
@@ -1718,7 +1718,7 @@ static void vfio_probe_ati_bar4_window_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
/*
|
|
|
5d360b |
* Trap the BAR2 MMIO window to config space as well.
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_probe_ati_bar2_4000_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_probe_ati_bar2_4000_quirk(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
VFIOQuirk *quirk;
|
|
|
5d360b |
@@ -1786,7 +1786,7 @@ static uint64_t vfio_nvidia_3d0_quirk_read(void *opaque,
|
|
|
5d360b |
hwaddr addr, unsigned size)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOQuirk *quirk = opaque;
|
|
|
5d360b |
- VFIODevice *vdev = quirk->vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = quirk->vdev;
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
uint64_t data = vfio_vga_read(&vdev->vga.region[QEMU_PCI_VGA_IO_HI],
|
|
|
5d360b |
addr + quirk->data.base_offset, size);
|
|
|
5d360b |
@@ -1805,7 +1805,7 @@ static void vfio_nvidia_3d0_quirk_write(void *opaque, hwaddr addr,
|
|
|
5d360b |
uint64_t data, unsigned size)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOQuirk *quirk = opaque;
|
|
|
5d360b |
- VFIODevice *vdev = quirk->vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = quirk->vdev;
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
|
|
|
5d360b |
switch (quirk->data.flags) {
|
|
|
5d360b |
@@ -1852,7 +1852,7 @@ static const MemoryRegionOps vfio_nvidia_3d0_quirk = {
|
|
|
5d360b |
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
5d360b |
};
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_vga_probe_nvidia_3d0_quirk(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_vga_probe_nvidia_3d0_quirk(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
VFIOQuirk *quirk;
|
|
|
5d360b |
@@ -1944,7 +1944,7 @@ static const MemoryRegionOps vfio_nvidia_bar5_window_quirk = {
|
|
|
5d360b |
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
5d360b |
};
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_probe_nvidia_bar5_window_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_probe_nvidia_bar5_window_quirk(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
VFIOQuirk *quirk;
|
|
|
5d360b |
@@ -1984,7 +1984,7 @@ static void vfio_probe_nvidia_bar5_window_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
*
|
|
|
5d360b |
* Here's offset 0x88000...
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_probe_nvidia_bar0_88000_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_probe_nvidia_bar0_88000_quirk(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
VFIOQuirk *quirk;
|
|
|
5d360b |
@@ -2018,7 +2018,7 @@ static void vfio_probe_nvidia_bar0_88000_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
/*
|
|
|
5d360b |
* And here's the same for BAR0 offset 0x1800...
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_probe_nvidia_bar0_1800_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_probe_nvidia_bar0_1800_quirk(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
VFIOQuirk *quirk;
|
|
|
5d360b |
@@ -2062,13 +2062,13 @@ static void vfio_probe_nvidia_bar0_1800_quirk(VFIODevice *vdev, int nr)
|
|
|
5d360b |
/*
|
|
|
5d360b |
* Common quirk probe entry points.
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_vga_quirk_setup(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_vga_quirk_setup(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
vfio_vga_probe_ati_3c3_quirk(vdev);
|
|
|
5d360b |
vfio_vga_probe_nvidia_3d0_quirk(vdev);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_vga_quirk_teardown(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_vga_quirk_teardown(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int i;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2083,7 +2083,7 @@ static void vfio_vga_quirk_teardown(VFIODevice *vdev)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_bar_quirk_setup(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
vfio_probe_ati_bar4_window_quirk(vdev, nr);
|
|
|
5d360b |
vfio_probe_ati_bar2_4000_quirk(vdev, nr);
|
|
|
5d360b |
@@ -2092,7 +2092,7 @@ static void vfio_bar_quirk_setup(VFIODevice *vdev, int nr)
|
|
|
5d360b |
vfio_probe_nvidia_bar0_1800_quirk(vdev, nr);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_bar_quirk_teardown(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_bar_quirk_teardown(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOBAR *bar = &vdev->bars[nr];
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2110,7 +2110,7 @@ static void vfio_bar_quirk_teardown(VFIODevice *vdev, int nr)
|
|
|
5d360b |
*/
|
|
|
5d360b |
static uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
|
5d360b |
uint32_t emu_bits = 0, emu_val = 0, phys_val = 0, val;
|
|
|
5d360b |
|
|
|
5d360b |
memcpy(&emu_bits, vdev->emulated_config_bits + addr, len);
|
|
|
5d360b |
@@ -2145,7 +2145,7 @@ static uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len)
|
|
|
5d360b |
static void vfio_pci_write_config(PCIDevice *pdev, uint32_t addr,
|
|
|
5d360b |
uint32_t val, int len)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
|
5d360b |
uint32_t val_le = cpu_to_le32(val);
|
|
|
5d360b |
|
|
|
5d360b |
DPRINTF("%s(%04x:%02x:%02x.%x, @0x%x, 0x%x, len=0x%x)\n", __func__,
|
|
|
5d360b |
@@ -2365,7 +2365,7 @@ static void vfio_listener_release(VFIOContainer *container)
|
|
|
5d360b |
/*
|
|
|
5d360b |
* Interrupt setup
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_disable_interrupts(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_disable_interrupts(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
/*
|
|
|
5d360b |
* More complicated than it looks. Disabling MSI/X transitions the
|
|
|
5d360b |
@@ -2383,7 +2383,7 @@ static void vfio_disable_interrupts(VFIODevice *vdev)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_setup_msi(VFIODevice *vdev, int pos)
|
|
|
5d360b |
+static int vfio_setup_msi(VFIOPCIDevice *vdev, int pos)
|
|
|
5d360b |
{
|
|
|
5d360b |
uint16_t ctrl;
|
|
|
5d360b |
bool msi_64bit, msi_maskbit;
|
|
|
5d360b |
@@ -2423,7 +2423,7 @@ static int vfio_setup_msi(VFIODevice *vdev, int pos)
|
|
|
5d360b |
* need to first look for where the MSI-X table lives. So we
|
|
|
5d360b |
* unfortunately split MSI-X setup across two functions.
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static int vfio_early_setup_msix(VFIODevice *vdev)
|
|
|
5d360b |
+static int vfio_early_setup_msix(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
uint8_t pos;
|
|
|
5d360b |
uint16_t ctrl;
|
|
|
5d360b |
@@ -2496,7 +2496,7 @@ static int vfio_early_setup_msix(VFIODevice *vdev)
|
|
|
5d360b |
return 0;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_setup_msix(VFIODevice *vdev, int pos)
|
|
|
5d360b |
+static int vfio_setup_msix(VFIOPCIDevice *vdev, int pos)
|
|
|
5d360b |
{
|
|
|
5d360b |
int ret;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2516,7 +2516,7 @@ static int vfio_setup_msix(VFIODevice *vdev, int pos)
|
|
|
5d360b |
return 0;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_teardown_msi(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_teardown_msi(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
msi_uninit(&vdev->pdev);
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2529,7 +2529,7 @@ static void vfio_teardown_msi(VFIODevice *vdev)
|
|
|
5d360b |
/*
|
|
|
5d360b |
* Resource setup
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_mmap_set_enabled(VFIODevice *vdev, bool enabled)
|
|
|
5d360b |
+static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled)
|
|
|
5d360b |
{
|
|
|
5d360b |
int i;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2547,7 +2547,7 @@ static void vfio_mmap_set_enabled(VFIODevice *vdev, bool enabled)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_unmap_bar(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_unmap_bar(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOBAR *bar = &vdev->bars[nr];
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2570,7 +2570,7 @@ static void vfio_unmap_bar(VFIODevice *vdev, int nr)
|
|
|
5d360b |
memory_region_destroy(&bar->mem);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_mmap_bar(VFIODevice *vdev, VFIOBAR *bar,
|
|
|
5d360b |
+static int vfio_mmap_bar(VFIOPCIDevice *vdev, VFIOBAR *bar,
|
|
|
5d360b |
MemoryRegion *mem, MemoryRegion *submem,
|
|
|
5d360b |
void **map, size_t size, off_t offset,
|
|
|
5d360b |
const char *name)
|
|
|
5d360b |
@@ -2609,7 +2609,7 @@ empty_region:
|
|
|
5d360b |
return ret;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_map_bar(VFIODevice *vdev, int nr)
|
|
|
5d360b |
+static void vfio_map_bar(VFIOPCIDevice *vdev, int nr)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOBAR *bar = &vdev->bars[nr];
|
|
|
5d360b |
uint64_t size = bar->size;
|
|
|
5d360b |
@@ -2678,7 +2678,7 @@ static void vfio_map_bar(VFIODevice *vdev, int nr)
|
|
|
5d360b |
vfio_bar_quirk_setup(vdev, nr);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_map_bars(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_map_bars(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int i;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2710,7 +2710,7 @@ static void vfio_map_bars(VFIODevice *vdev)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_unmap_bars(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_unmap_bars(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int i;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2749,7 +2749,7 @@ static void vfio_set_word_bits(uint8_t *buf, uint16_t val, uint16_t mask)
|
|
|
5d360b |
pci_set_word(buf, (pci_get_word(buf) & ~mask) | val);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_add_emulated_word(VFIODevice *vdev, int pos,
|
|
|
5d360b |
+static void vfio_add_emulated_word(VFIOPCIDevice *vdev, int pos,
|
|
|
5d360b |
uint16_t val, uint16_t mask)
|
|
|
5d360b |
{
|
|
|
5d360b |
vfio_set_word_bits(vdev->pdev.config + pos, val, mask);
|
|
|
5d360b |
@@ -2762,7 +2762,7 @@ static void vfio_set_long_bits(uint8_t *buf, uint32_t val, uint32_t mask)
|
|
|
5d360b |
pci_set_long(buf, (pci_get_long(buf) & ~mask) | val);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_add_emulated_long(VFIODevice *vdev, int pos,
|
|
|
5d360b |
+static void vfio_add_emulated_long(VFIOPCIDevice *vdev, int pos,
|
|
|
5d360b |
uint32_t val, uint32_t mask)
|
|
|
5d360b |
{
|
|
|
5d360b |
vfio_set_long_bits(vdev->pdev.config + pos, val, mask);
|
|
|
5d360b |
@@ -2770,7 +2770,7 @@ static void vfio_add_emulated_long(VFIODevice *vdev, int pos,
|
|
|
5d360b |
vfio_set_long_bits(vdev->emulated_config_bits + pos, mask, mask);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_setup_pcie_cap(VFIODevice *vdev, int pos, uint8_t size)
|
|
|
5d360b |
+static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size)
|
|
|
5d360b |
{
|
|
|
5d360b |
uint16_t flags;
|
|
|
5d360b |
uint8_t type;
|
|
|
5d360b |
@@ -2862,7 +2862,7 @@ static int vfio_setup_pcie_cap(VFIODevice *vdev, int pos, uint8_t size)
|
|
|
5d360b |
return pos;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_check_pcie_flr(VFIODevice *vdev, uint8_t pos)
|
|
|
5d360b |
+static void vfio_check_pcie_flr(VFIOPCIDevice *vdev, uint8_t pos)
|
|
|
5d360b |
{
|
|
|
5d360b |
uint32_t cap = pci_get_long(vdev->pdev.config + pos + PCI_EXP_DEVCAP);
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2874,7 +2874,7 @@ static void vfio_check_pcie_flr(VFIODevice *vdev, uint8_t pos)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_check_pm_reset(VFIODevice *vdev, uint8_t pos)
|
|
|
5d360b |
+static void vfio_check_pm_reset(VFIOPCIDevice *vdev, uint8_t pos)
|
|
|
5d360b |
{
|
|
|
5d360b |
uint16_t csr = pci_get_word(vdev->pdev.config + pos + PCI_PM_CTRL);
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2886,7 +2886,7 @@ static void vfio_check_pm_reset(VFIODevice *vdev, uint8_t pos)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_check_af_flr(VFIODevice *vdev, uint8_t pos)
|
|
|
5d360b |
+static void vfio_check_af_flr(VFIOPCIDevice *vdev, uint8_t pos)
|
|
|
5d360b |
{
|
|
|
5d360b |
uint8_t cap = pci_get_byte(vdev->pdev.config + pos + PCI_AF_CAP);
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2898,7 +2898,7 @@ static void vfio_check_af_flr(VFIODevice *vdev, uint8_t pos)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_add_std_cap(VFIODevice *vdev, uint8_t pos)
|
|
|
5d360b |
+static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
uint8_t cap_id, next, size;
|
|
|
5d360b |
@@ -2973,7 +2973,7 @@ static int vfio_add_std_cap(VFIODevice *vdev, uint8_t pos)
|
|
|
5d360b |
return 0;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_add_capabilities(VFIODevice *vdev)
|
|
|
5d360b |
+static int vfio_add_capabilities(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
|
|
|
5d360b |
@@ -2985,7 +2985,7 @@ static int vfio_add_capabilities(VFIODevice *vdev)
|
|
|
5d360b |
return vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST]);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_pci_pre_reset(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_pci_pre_reset(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = &vdev->pdev;
|
|
|
5d360b |
uint16_t cmd;
|
|
|
5d360b |
@@ -3022,7 +3022,7 @@ static void vfio_pci_pre_reset(VFIODevice *vdev)
|
|
|
5d360b |
vfio_pci_write_config(pdev, PCI_COMMAND, cmd, 2);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_pci_post_reset(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_pci_post_reset(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
vfio_enable_intx(vdev);
|
|
|
5d360b |
}
|
|
|
5d360b |
@@ -3034,7 +3034,7 @@ static bool vfio_pci_host_match(PCIHostDeviceAddress *host1,
|
|
|
5d360b |
host1->slot == host2->slot && host1->function == host2->function);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_pci_hot_reset(VFIODevice *vdev, bool single)
|
|
|
5d360b |
+static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOGroup *group;
|
|
|
5d360b |
struct vfio_pci_hot_reset_info *info;
|
|
|
5d360b |
@@ -3084,7 +3084,7 @@ static int vfio_pci_hot_reset(VFIODevice *vdev, bool single)
|
|
|
5d360b |
/* Verify that we have all the groups required */
|
|
|
5d360b |
for (i = 0; i < info->count; i++) {
|
|
|
5d360b |
PCIHostDeviceAddress host;
|
|
|
5d360b |
- VFIODevice *tmp;
|
|
|
5d360b |
+ VFIOPCIDevice *tmp;
|
|
|
5d360b |
|
|
|
5d360b |
host.domain = devices[i].segment;
|
|
|
5d360b |
host.bus = devices[i].bus;
|
|
|
5d360b |
@@ -3176,7 +3176,7 @@ out:
|
|
|
5d360b |
/* Re-enable INTx on affected devices */
|
|
|
5d360b |
for (i = 0; i < info->count; i++) {
|
|
|
5d360b |
PCIHostDeviceAddress host;
|
|
|
5d360b |
- VFIODevice *tmp;
|
|
|
5d360b |
+ VFIOPCIDevice *tmp;
|
|
|
5d360b |
|
|
|
5d360b |
host.domain = devices[i].segment;
|
|
|
5d360b |
host.bus = devices[i].bus;
|
|
|
5d360b |
@@ -3226,12 +3226,12 @@ out_single:
|
|
|
5d360b |
* _one() will only do a hot reset for the one in-use devices case, calling
|
|
|
5d360b |
* _multi() will do nothing if a _one() would have been sufficient.
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static int vfio_pci_hot_reset_one(VFIODevice *vdev)
|
|
|
5d360b |
+static int vfio_pci_hot_reset_one(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
return vfio_pci_hot_reset(vdev, true);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_pci_hot_reset_multi(VFIODevice *vdev)
|
|
|
5d360b |
+static int vfio_pci_hot_reset_multi(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
return vfio_pci_hot_reset(vdev, false);
|
|
|
5d360b |
}
|
|
|
5d360b |
@@ -3239,7 +3239,7 @@ static int vfio_pci_hot_reset_multi(VFIODevice *vdev)
|
|
|
5d360b |
static void vfio_pci_reset_handler(void *opaque)
|
|
|
5d360b |
{
|
|
|
5d360b |
VFIOGroup *group;
|
|
|
5d360b |
- VFIODevice *vdev;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev;
|
|
|
5d360b |
|
|
|
5d360b |
QLIST_FOREACH(group, &group_list, next) {
|
|
|
5d360b |
QLIST_FOREACH(vdev, &group->device_list, next) {
|
|
|
5d360b |
@@ -3499,7 +3499,8 @@ static void vfio_put_group(VFIOGroup *group)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev)
|
|
|
5d360b |
+static int vfio_get_device(VFIOGroup *group, const char *name,
|
|
|
5d360b |
+ VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) };
|
|
|
5d360b |
struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
|
|
|
5d360b |
@@ -3654,7 +3655,7 @@ error:
|
|
|
5d360b |
return ret;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_put_device(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_put_device(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
QLIST_REMOVE(vdev, next);
|
|
|
5d360b |
vdev->group = NULL;
|
|
|
5d360b |
@@ -3668,7 +3669,7 @@ static void vfio_put_device(VFIODevice *vdev)
|
|
|
5d360b |
|
|
|
5d360b |
static void vfio_err_notifier_handler(void *opaque)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = opaque;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = opaque;
|
|
|
5d360b |
|
|
|
5d360b |
if (!event_notifier_test_and_clear(&vdev->err_notifier)) {
|
|
|
5d360b |
return;
|
|
|
5d360b |
@@ -3697,7 +3698,7 @@ static void vfio_err_notifier_handler(void *opaque)
|
|
|
5d360b |
* and continue after disabling error recovery support for the
|
|
|
5d360b |
* device.
|
|
|
5d360b |
*/
|
|
|
5d360b |
-static void vfio_register_err_notifier(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_register_err_notifier(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int ret;
|
|
|
5d360b |
int argsz;
|
|
|
5d360b |
@@ -3738,7 +3739,7 @@ static void vfio_register_err_notifier(VFIODevice *vdev)
|
|
|
5d360b |
g_free(irq_set);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_unregister_err_notifier(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_unregister_err_notifier(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int argsz;
|
|
|
5d360b |
struct vfio_irq_set *irq_set;
|
|
|
5d360b |
@@ -3773,7 +3774,7 @@ static void vfio_unregister_err_notifier(VFIODevice *vdev)
|
|
|
5d360b |
|
|
|
5d360b |
static void vfio_req_notifier_handler(void *opaque)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = opaque;
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = opaque;
|
|
|
5d360b |
|
|
|
5d360b |
if (!event_notifier_test_and_clear(&vdev->req_notifier)) {
|
|
|
5d360b |
return;
|
|
|
5d360b |
@@ -3782,7 +3783,7 @@ static void vfio_req_notifier_handler(void *opaque)
|
|
|
5d360b |
qdev_unplug(&vdev->pdev.qdev, NULL);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_register_req_notifier(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_register_req_notifier(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info),
|
|
|
5d360b |
.index = VFIO_PCI_REQ_IRQ_INDEX };
|
|
|
5d360b |
@@ -3829,7 +3830,7 @@ static void vfio_register_req_notifier(VFIODevice *vdev)
|
|
|
5d360b |
g_free(irq_set);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
-static void vfio_unregister_req_notifier(VFIODevice *vdev)
|
|
|
5d360b |
+static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
int argsz;
|
|
|
5d360b |
struct vfio_irq_set *irq_set;
|
|
|
5d360b |
@@ -3864,7 +3865,7 @@ static void vfio_unregister_req_notifier(VFIODevice *vdev)
|
|
|
5d360b |
|
|
|
5d360b |
static int vfio_initfn(PCIDevice *pdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *pvdev, *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
|
|
|
5d360b |
+ VFIOPCIDevice *pvdev, *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
|
5d360b |
VFIOGroup *group;
|
|
|
5d360b |
char path[PATH_MAX], iommu_group_path[PATH_MAX], *group_name;
|
|
|
5d360b |
ssize_t len;
|
|
|
5d360b |
@@ -4031,7 +4032,7 @@ out_put:
|
|
|
5d360b |
|
|
|
5d360b |
static void vfio_exitfn(PCIDevice *pdev)
|
|
|
5d360b |
{
|
|
|
5d360b |
- VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
|
5d360b |
VFIOGroup *group = vdev->group;
|
|
|
5d360b |
|
|
|
5d360b |
vfio_unregister_req_notifier(vdev);
|
|
|
5d360b |
@@ -4052,7 +4053,7 @@ static void vfio_exitfn(PCIDevice *pdev)
|
|
|
5d360b |
static void vfio_pci_reset(DeviceState *dev)
|
|
|
5d360b |
{
|
|
|
5d360b |
PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);
|
|
|
5d360b |
- VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
|
|
|
5d360b |
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
|
|
|
5d360b |
|
|
|
5d360b |
DPRINTF("%s(%04x:%02x:%02x.%x)\n", __func__, vdev->host.domain,
|
|
|
5d360b |
vdev->host.bus, vdev->host.slot, vdev->host.function);
|
|
|
5d360b |
@@ -4084,18 +4085,18 @@ post_reset:
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
static Property vfio_pci_dev_properties[] = {
|
|
|
5d360b |
- DEFINE_PROP_PCI_HOST_DEVADDR("host", VFIODevice, host),
|
|
|
5d360b |
- DEFINE_PROP_UINT32("x-intx-mmap-timeout-ms", VFIODevice,
|
|
|
5d360b |
+ DEFINE_PROP_PCI_HOST_DEVADDR("host", VFIOPCIDevice, host),
|
|
|
5d360b |
+ DEFINE_PROP_UINT32("x-intx-mmap-timeout-ms", VFIOPCIDevice,
|
|
|
5d360b |
intx.mmap_timeout, 1100),
|
|
|
5d360b |
- DEFINE_PROP_BIT("x-vga", VFIODevice, features,
|
|
|
5d360b |
+ DEFINE_PROP_BIT("x-vga", VFIOPCIDevice, features,
|
|
|
5d360b |
VFIO_FEATURE_ENABLE_VGA_BIT, false),
|
|
|
5d360b |
- DEFINE_PROP_BIT("x-req", VFIODevice, features,
|
|
|
5d360b |
+ DEFINE_PROP_BIT("x-req", VFIOPCIDevice, features,
|
|
|
5d360b |
VFIO_FEATURE_ENABLE_REQ_BIT, true),
|
|
|
5d360b |
- DEFINE_PROP_INT32("bootindex", VFIODevice, bootindex, -1),
|
|
|
5d360b |
+ DEFINE_PROP_INT32("bootindex", VFIOPCIDevice, bootindex, -1),
|
|
|
5d360b |
/*
|
|
|
5d360b |
* TODO - support passed fds... is this necessary?
|
|
|
5d360b |
- * DEFINE_PROP_STRING("vfiofd", VFIODevice, vfiofd_name),
|
|
|
5d360b |
- * DEFINE_PROP_STRING("vfiogroupfd, VFIODevice, vfiogroupfd_name),
|
|
|
5d360b |
+ * DEFINE_PROP_STRING("vfiofd", VFIOPCIDevice, vfiofd_name),
|
|
|
5d360b |
+ * DEFINE_PROP_STRING("vfiogroupfd, VFIOPCIDevice, vfiogroupfd_name),
|
|
|
5d360b |
*/
|
|
|
5d360b |
DEFINE_PROP_END_OF_LIST(),
|
|
|
5d360b |
};
|
|
|
5d360b |
@@ -4125,7 +4126,7 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, void *data)
|
|
|
5d360b |
static const TypeInfo vfio_pci_dev_info = {
|
|
|
5d360b |
.name = "vfio-pci",
|
|
|
5d360b |
.parent = TYPE_PCI_DEVICE,
|
|
|
5d360b |
- .instance_size = sizeof(VFIODevice),
|
|
|
5d360b |
+ .instance_size = sizeof(VFIOPCIDevice),
|
|
|
5d360b |
.class_init = vfio_pci_dev_class_init,
|
|
|
5d360b |
};
|
|
|
5d360b |
|
|
|
5d360b |
--
|
|
|
5d360b |
1.8.3.1
|
|
|
5d360b |
|