[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 22/26] vfio-user: no-mmap DMA support
From: |
John Levon |
Subject: |
[PATCH 22/26] vfio-user: no-mmap DMA support |
Date: |
Wed, 8 Jan 2025 11:50:28 +0000 |
From: Jagannathan Raman <jag.raman@oracle.com>
Force remote process to use DMA r/w messages instead
of directly mapping guest memory.
Originally-by: John Johnson <john.g.johnson@oracle.com>
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Signed-off-by: John Levon <john.levon@nutanix.com>
---
hw/vfio/user-container.c | 2 +-
hw/vfio/user-pci.c | 5 +++++
hw/vfio/user.h | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/user-container.c b/hw/vfio/user-container.c
index 77ffec9561..89bd1850ef 100644
--- a/hw/vfio/user-container.c
+++ b/hw/vfio/user-container.c
@@ -102,7 +102,7 @@ static int vfio_user_dma_map(const VFIOContainerBase
*bcontainer, hwaddr iova,
* vaddr enters as a QEMU process address; make it either a file offset
* for mapped areas or leave as 0.
*/
- if (fd != -1) {
+ if (fd != -1 && !(container->proxy->flags & VFIO_PROXY_NO_MMAP)) {
msgp->offset = qemu_ram_block_host_offset(mrp->ram_block, vaddr);
}
diff --git a/hw/vfio/user-pci.c b/hw/vfio/user-pci.c
index 53d230fdd3..b1125f7403 100644
--- a/hw/vfio/user-pci.c
+++ b/hw/vfio/user-pci.c
@@ -39,6 +39,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VFIOUserPCIDevice, VFIO_USER_PCI)
struct VFIOUserPCIDevice {
VFIOPCIDevice device;
char *sock_name;
+ bool no_direct_dma; /* disable shared mem for DMA */
bool send_queued; /* all sends are queued */
bool no_post; /* all regions write are sync */
};
@@ -157,6 +158,9 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error
**errp)
vbasedev->proxy = proxy;
vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev);
+ if (udev->no_direct_dma) {
+ proxy->flags |= VFIO_PROXY_NO_MMAP;
+ }
if (udev->send_queued) {
proxy->flags |= VFIO_PROXY_FORCE_QUEUED;
}
@@ -281,6 +285,7 @@ static void vfio_user_instance_finalize(Object *obj)
static const Property vfio_user_pci_dev_properties[] = {
DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name),
+ DEFINE_PROP_BOOL("no-direct-dma", VFIOUserPCIDevice, no_direct_dma, false),
DEFINE_PROP_BOOL("x-send-queued", VFIOUserPCIDevice, send_queued, false),
DEFINE_PROP_BOOL("x-no-posted-writes", VFIOUserPCIDevice, no_post, false),
};
diff --git a/hw/vfio/user.h b/hw/vfio/user.h
index 31d2c5abd9..fe24a881f2 100644
--- a/hw/vfio/user.h
+++ b/hw/vfio/user.h
@@ -94,6 +94,7 @@ typedef struct VFIOUserProxy {
/* VFIOProxy flags */
#define VFIO_PROXY_CLIENT 0x1
+#define VFIO_PROXY_NO_MMAP 0x2
#define VFIO_PROXY_FORCE_QUEUED 0x4
#define VFIO_PROXY_NO_POST 0x8
--
2.34.1
- [PATCH 05/26] vfio: add vfio_prepare_device(), (continued)
- [PATCH 05/26] vfio: add vfio_prepare_device(), John Levon, 2025/01/08
- [PATCH 09/26] vfio-user: introduce vfio-user protocol specification, John Levon, 2025/01/08
- [PATCH 11/26] vfio-user: connect vfio proxy to remote server, John Levon, 2025/01/08
- [PATCH 14/26] vfio-user: get device info, John Levon, 2025/01/08
- [PATCH 12/26] vfio-user: define socket receive functions, John Levon, 2025/01/08
- [PATCH 07/26] vfio: add VFIO base abstract class, John Levon, 2025/01/08
- [PATCH 13/26] vfio-user: define socket send functions, John Levon, 2025/01/08
- [PATCH 17/26] vfio-user: pci_user_realize PCI setup, John Levon, 2025/01/08
- [PATCH 15/26] vfio-user: get region info, John Levon, 2025/01/08
- [PATCH 20/26] vfio-user: proxy container connect/disconnect, John Levon, 2025/01/08
- [PATCH 22/26] vfio-user: no-mmap DMA support,
John Levon <=
- [PATCH 19/26] vfio-user: forward msix BAR accesses to server, John Levon, 2025/01/08
- [PATCH 06/26] vfio: add region cache, John Levon, 2025/01/08
- [PATCH 01/26] vfio/container: pass MemoryRegion to DMA operations, John Levon, 2025/01/08
- [PATCH 24/26] vfio-user: pci reset, John Levon, 2025/01/08
- [PATCH 03/26] vfio/container: support VFIO_DMA_UNMAP_FLAG_ALL, John Levon, 2025/01/08
- [PATCH 16/26] vfio-user: region read/write, John Levon, 2025/01/08
- [PATCH 18/26] vfio-user: get and set IRQs, John Levon, 2025/01/08
- [PATCH 23/26] vfio-user: dma read/write operations, John Levon, 2025/01/08
- [PATCH 21/26] vfio-user: dma map/unmap operations, John Levon, 2025/01/08
- [PATCH 25/26] vfio-user: add 'x-msg-timeout' option that specifies msg wait times, John Levon, 2025/01/08