622740aad9
hw/vfio-user: fix use of uninitialized variable
...
Coverity reported:
CID 1611805: Uninitialized variables
in vfio_user_dma_map(). This can occur in the happy path when
->async_ops was not set; as this doesn't typically happen, it wasn't
caught during testing.
Align both map and unmap implementations to initialize ret the same way
to resolve this.
Resolves: Coverity CID 1611805
Fixes: 18e899e6 ("vfio-user: implement VFIO_USER_DMA_MAP/UNMAP")
Reported-by: Cédric Le Goater <clg@redhat.com >
Signed-off-by: John Levon <john.levon@nutanix.com >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com >
Link: https://lore.kernel.org/qemu-devel/20250715115954.515819-5-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-07-15 17:11:12 +02:00
ea6788440d
hw/vfio-user: wait for proxy close correctly
...
Coverity reported:
CID 1611806: Concurrent data access violations (BAD_CHECK_OF_WAIT_COND)
A wait is performed without a loop. If there is a spurious wakeup, the
condition may not be satisfied.
Fix this by checking ->state for VFIO_PROXY_CLOSED in a loop.
Also rename the callback for clarity.
Signed-off-by: John Levon <john.levon@nutanix.com >
Reviewed-by: Mark Cave-Ayland <markcaveayland@nutanix.com >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250715115954.515819-4-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-07-15 17:11:12 +02:00
f7c5dff26e
vfio-user: do not register vfio-user container with cpr
...
As the full cpr implementation is yet to be merged upstream, do not register
the vfio-user container with cpr. Full vfio-user support for cpr can be
merged later as a follow-up series.
Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Message-ID: <20250702120043.267634-1-mark.caveayland@nutanix.com >
[ clg: Removed now useless "hw/vfio/vfio-cpr.h" include ]
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-07-03 13:42:28 +02:00
1a0c32a9da
vfio-user: add coalesced posted writes
...
Add new message to send multiple writes to server in a single message.
Prevents the outgoing queue from overflowing when a long latency
operation is followed by a series of posted writes.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-18-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
98a906d9e5
vfio-user: support posted writes
...
Support an asynchronous send of a vfio-user socket message (no wait for
a reply) when the write is posted. This is only safe when no regions are
mappable by the VM. Add an option to explicitly disable this as well.
Signed-off-by: John Levon <john.levon@nutanix.com >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-17-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
3358d926ad
vfio-user: add 'x-msg-timeout' option
...
By default, the vfio-user subsystem will wait 5 seconds for a message
reply from the server. Add an option to allow this to be configurable.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-16-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
c6ac52a4d8
vfio-user: implement VFIO_USER_DMA_READ/WRITE
...
Unlike most other messages, this is a server->client message, for when a
server wants to do "DMA"; this is slow, so normally the server has
memory directly mapped instead.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-15-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
18e899e63d
vfio-user: implement VFIO_USER_DMA_MAP/UNMAP
...
When the vfio-user container gets mapping updates, share them with the
vfio-user by sending a message; this can include the region fd, allowing
the server to directly mmap() the region as needed.
For performance, we only wait for the message responses when we're doing
with a series of updates via the listener_commit() callback.
Originally-by: John Johnson <john.g.johnson@oracle.com >
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com >
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com >
Signed-off-by: John Levon <john.levon@nutanix.com >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-14-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
0192323581
vfio-user: implement VFIO_USER_DEVICE_RESET
...
Hook this call up to the legacy reset handler for vfio-user-pci.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-13-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
52ce9c35f8
vfio-user: set up container access to the proxy
...
The user container will shortly need access to the underlying vfio-user
proxy; set this up.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-12-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
777e45c7b9
vfio-user: forward MSI-X PBA BAR accesses to server
...
For vfio-user, the server holds the pending IRQ state; set up an I/O
region for the MSI-X PBA so we can ask the server for this state on a
PBA read.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-11-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
ca1add1696
vfio-user: implement VFIO_USER_DEVICE_GET/SET_IRQ*
...
IRQ setup uses the same semantics as the traditional vfio path, but we
need to share the corresponding file descriptors with the server as
necessary.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-10-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
692e0ec50c
vfio-user: set up PCI in vfio_user_pci_realize()
...
Re-use PCI setup functions from hw/vfio/pci.c to realize the vfio-user
PCI device.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-9-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
1ed50fcb6a
vfio-user: implement VFIO_USER_REGION_READ/WRITE
...
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-8-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
667866d666
vfio-user: implement VFIO_USER_DEVICE_GET_REGION_INFO
...
Add support for getting region info for vfio-user. As vfio-user has one
fd per region, enable ->use_region_fds.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-7-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
3bdb738b73
vfio-user: implement VFIO_USER_DEVICE_GET_INFO
...
Add support for getting basic device information.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-6-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
36227628d8
vfio-user: implement message send infrastructure
...
Add plumbing for sending vfio-user messages on the control socket.
Add initial version negotation on connection.
Originally-by: John Johnson <john.g.johnson@oracle.com >
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com >
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com >
Signed-off-by: John Levon <john.levon@nutanix.com >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-5-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
0b3d881a06
vfio-user: implement message receive infrastructure
...
Add the basic implementation for receiving vfio-user messages from the
control socket.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-4-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
438d863f1f
vfio-user: connect vfio proxy to remote server
...
Introduce the vfio-user "proxy": this is the client code responsible for
sending and receiving vfio-user messages across the control socket.
The new files hw/vfio-user/proxy.[ch] contain some basic plumbing for
managing the proxy; initialize the proxy during realization of the
VFIOUserPCIDevice instance.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-3-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00
9fca2b7d70
vfio-user: add vfio-user class and container
...
Introduce basic plumbing for vfio-user with CONFIG_VFIO_USER.
We introduce VFIOUserContainer in hw/vfio-user/container.c, which is a
container type for the "IOMMU" type "vfio-iommu-user", and share some
common container code from hw/vfio/container.c.
Add hw/vfio-user/pci.c for instantiating VFIOUserPCIDevice objects,
sharing some common code from hw/vfio/pci.c.
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 >
Reviewed-by: Cédric Le Goater <clg@redhat.com >
Link: https://lore.kernel.org/qemu-devel/20250625193012.2316242-2-john.levon@nutanix.com
Signed-off-by: Cédric Le Goater <clg@redhat.com >
2025-06-26 08:55:38 +02:00