[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 17/19] vfio-user: probe remote device ROM BAR
From: |
Elena Ufimtseva |
Subject: |
[PATCH RFC 17/19] vfio-user: probe remote device ROM BAR |
Date: |
Sun, 18 Jul 2021 23:27:56 -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 | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index a6c28dac03..bed8eaa4c2 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -816,8 +816,14 @@ static void vfio_pci_load_rom(VFIOPCIDevice *vdev)
memset(vdev->rom, 0xff, size);
while (size) {
- bytes = pread(vdev->vbasedev.fd, vdev->rom + off,
- size, vdev->rom_offset + off);
+ if (vdev->vbasedev.proxy != NULL) {
+ bytes = vfio_user_region_read(&vdev->vbasedev,
+ VFIO_PCI_ROM_REGION_INDEX,
+ off, size, vdev->rom + off);
+ } else {
+ bytes = pread(vdev->vbasedev.fd, vdev->rom + off,
+ size, vdev->rom_offset + off);
+ }
if (bytes == 0) {
break;
} else if (bytes > 0) {
@@ -936,12 +942,28 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
* Use the same size ROM BAR as the physical device. The contents
* will get filled in later when the guest tries to read it.
*/
- if (pread(fd, &orig, 4, offset) != 4 ||
- pwrite(fd, &size, 4, offset) != 4 ||
- pread(fd, &size, 4, offset) != 4 ||
- pwrite(fd, &orig, 4, offset) != 4) {
- error_report("%s(%s) failed: %m", __func__, vdev->vbasedev.name);
- return;
+ if (vdev->vbasedev.proxy != NULL) {
+ if (vfio_user_region_read(&vdev->vbasedev,
VFIO_PCI_CONFIG_REGION_INDEX,
+ PCI_ROM_ADDRESS, 4, &orig) != 4 ||
+ vfio_user_region_write(&vdev->vbasedev,
+ VFIO_PCI_CONFIG_REGION_INDEX,
+ PCI_ROM_ADDRESS, 4, &size) != 4 ||
+ vfio_user_region_read(&vdev->vbasedev,
VFIO_PCI_CONFIG_REGION_INDEX,
+ PCI_ROM_ADDRESS, 4, &size) != 4 ||
+ vfio_user_region_write(&vdev->vbasedev,
+ VFIO_PCI_CONFIG_REGION_INDEX,
+ PCI_ROM_ADDRESS, 4, &orig) != 4) {
+ error_report("%s(%s) failed: %m", __func__, vdev->vbasedev.name);
+ return;
+ }
+ } else {
+ if (pread(fd, &orig, 4, offset) != 4 ||
+ pwrite(fd, &size, 4, offset) != 4 ||
+ pread(fd, &size, 4, offset) != 4 ||
+ pwrite(fd, &orig, 4, offset) != 4) {
+ error_report("%s(%s) failed: %m", __func__, vdev->vbasedev.name);
+ return;
+ }
}
size = ~(le32_to_cpu(size) & PCI_ROM_ADDRESS_MASK) + 1;
--
2.25.1
- [PATCH RFC 06/19] vfio-user: negotiate protocol with remote server, (continued)
- [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 <=
- [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
- [PATCH RFC server 07/11] vfio-user: handle DMA mappings, Jagannathan Raman, 2021/07/19
- [PATCH RFC server 08/11] vfio-user: handle PCI BAR accesses, Jagannathan Raman, 2021/07/19
- [PATCH RFC server 10/11] vfio-user: register handlers to facilitate migration, Jagannathan Raman, 2021/07/19
- [PATCH RFC server 09/11] vfio-user: handle device interrupts, Jagannathan Raman, 2021/07/19
- [PATCH RFC server 11/11] vfio-user: acceptance test, Jagannathan Raman, 2021/07/19