[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 12/19] vfio-user: probe remote device's BARs
From: |
Elena Ufimtseva |
Subject: |
[PATCH RFC 12/19] vfio-user: probe remote device's BARs |
Date: |
Sun, 18 Jul 2021 23:27:51 -0700 |
From: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
---
hw/vfio/pci.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 054e673552..a8d2e59470 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1619,11 +1619,17 @@ static void vfio_bar_prepare(VFIOPCIDevice *vdev, int
nr)
}
/* Determine what type of BAR this is for registration */
- ret = pread(vdev->vbasedev.fd, &pci_bar, sizeof(pci_bar),
- vdev->config_offset + PCI_BASE_ADDRESS_0 + (4 * nr));
- if (ret != sizeof(pci_bar)) {
- error_report("vfio: Failed to read BAR %d (%m)", nr);
- return;
+ if (vdev->vbasedev.proxy != NULL) {
+ /* during setup, config space was initialized from remote */
+ memcpy(&pci_bar, vdev->pdev.config + PCI_BASE_ADDRESS_0 + (4 * nr),
+ sizeof(pci_bar));
+ } else {
+ ret = pread(vdev->vbasedev.fd, &pci_bar, sizeof(pci_bar),
+ vdev->config_offset + PCI_BASE_ADDRESS_0 + (4 * nr));
+ if (ret != sizeof(pci_bar)) {
+ error_report("vfio: Failed to read BAR %d (%m)", nr);
+ return;
+ }
}
pci_bar = le32_to_cpu(pci_bar);
@@ -3442,6 +3448,22 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error
**errp)
/* QEMU can also add or extend BARs */
memset(vdev->emulated_config_bits + PCI_BASE_ADDRESS_0, 0xff, 6 * 4);
+ /*
+ * Local QEMU overrides aren't allowed
+ * They must be done in the device process
+ */
+ if (pdev->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) {
+ error_setg(errp, "Multi-function must be specified by device process");
+ goto error;
+ }
+ if (pdev->romfile) {
+ error_setg(errp, "Romfile must be specified by device process");
+ goto error;
+ }
+
+ vfio_bars_prepare(vdev);
+
+
return;
error:
--
2.25.1
- [PATCH RFC 03/19] vfio-user: define VFIO Proxy and communication functions, (continued)
- [PATCH RFC 03/19] vfio-user: define VFIO Proxy and communication functions, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 08/19] vfio-user: VFIO container setup & teardown, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 02/19] vfio-user: add VFIO base abstract class, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 10/19] vfio-user: device region read/write, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 01/19] vfio-user: introduce vfio-user protocol specification, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 11/19] vfio-user: get region and DMA map/unmap operations, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 14/19] vfio_user: setup MSI/X interrupts and PCI config operations, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 06/19] vfio-user: negotiate protocol with remote server, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 05/19] vfio-user: connect vfio proxy to remote server, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 09/19] vfio-user: get device info and get irq info, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 12/19] vfio-user: probe remote device's BARs,
Elena Ufimtseva <=
- [PATCH RFC 15/19] vfio-user: vfio user device realize, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 13/19] vfio-user: respond to remote DMA read/write requests, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 18/19] vfio-user: migration support, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 17/19] vfio-user: probe remote device ROM BAR, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 19/19] vfio-user: add migration cli options and version negotiation, Elena Ufimtseva, 2021/07/19
- [PATCH RFC 16/19] vfio-user: pci reset, Elena Ufimtseva, 2021/07/19
- [PATCH RFC server 00/11] vfio-user server in QEMU, Jagannathan Raman, 2021/07/19