[PATCH 5/7] vdpa: Make SVQ vring unmapping return void

2022-08-19 Thread Eugenio Pérez
Nothing actually reads the return value, but an error in cleaning some entries could cause device stop to abort, making a restart impossible. Better ignore explicitely the return value. Reported-by: Lei Yang Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ") Signed-off-b

[PATCH 2/7] vdpa: do not save failed dma maps in SVQ iova tree

2022-08-19 Thread Eugenio Pérez
If a map fails for whatever reason, it must not be saved in the tree. Otherwise, qemu will try to unmap it in cleanup, leaving to more errors. Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ") Reported-by: Lei Yang Signed-off-by: Eugenio Pérez Acked-by: Jason Wang ---

[PATCH 7/7] vdpa: Use ring hwaddr at vhost_vdpa_svq_unmap_ring

2022-08-19 Thread Eugenio Pérez
Reduce code duplication. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 07d00f5284..45d6e86b45 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio

[PATCH 0/7] vDPA shadow virtqueue iova tree fixes.

2022-08-19 Thread Eugenio Pérez
like memory mapping / unmapping. First two patches are already in the list at [1]. Last one is not a fix by itself but a straightforward merge of the same code. [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-08/msg00773.html Eugenio Pérez (7): vdpa: Skip the maps not in the iova tree

[RFC 8/8] vdpa: Conditionally expose _F_LOG in vhost_net devices

2022-08-10 Thread Eugenio Pérez
device needs to expose certains features. Expose _F_LOG only if all of these are met. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 4c6947feb8..73c27cd315 100644

[RFC 6/8] vdpa: Negotiate _F_SUSPEND feature

2022-08-10 Thread Eugenio Pérez
This is needed for qemu to know it can suspend the device to retrieve its status and enable SVQ with it, so all the process is transparent to the guest. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost

[RFC 1/8] [NOTMERGE] Update linux headers

2022-08-10 Thread Eugenio Pérez
Add _F_SUSPEND and suspend ioctl. TODO: This is still not merged in Linux upstream, so it may change. --- include/standard-headers/linux/vhost_types.h | 3 +++ linux-headers/linux/vhost.h | 3 +++ 2 files changed, 6 insertions(+) diff --git

[RFC 3/8] vhost: expose memory listener priority

2022-08-10 Thread Eugenio Pérez
to net/vhost-vdpa one. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost.h | 2 ++ hw/virtio/vhost.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a346f23d13..ccd6cc5549 100644 --- a/include/hw/virtio

[RFC 7/8] vdpa: Add feature_log member to vhost_vdpa

2022-08-10 Thread Eugenio Pérez
This way device's vhost_vdpa can make the choice about exposing or not the _F_LOG feature. At the moment is always false. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git

[RFC 2/8] vdpa: Extract get_backend_features from vhost_vdpa_get_as_num

2022-08-10 Thread Eugenio Pérez
The series reuses it to check for SUSPEND feature bit. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 11241ebac4..85b10799bd 100644 --- a/net/vhost-vdpa.c +++ b/net

[RFC 0/8] Dinamycally switch to vhost shadow virtqueues at vdpa net migration

2022-08-10 Thread Eugenio Pérez
. Comments are welcome. [1] https://lkml.org/lkml/2022/8/10/732 [2] https://lists.nongnu.org/archive/html/qemu-devel/2022-08/msg01047.html Eugenio Pérez (8): [NOTMERGE] Update linux headers vdpa: Extract get_backend_features from vhost_vdpa_get_as_num vhost: expose memory listener priority

[RFC 4/8] vdpa: Add log_enabled to VhostVDPAState

2022-08-10 Thread Eugenio Pérez
ost vdpa device, enabling the shadow virtqueue unconditionally. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 85b10799bd..a035c89c34 100644 --- a/net/vhost-vdpa.c +++ b/

[RFC 5/8] vdpa: Add vdpa memory listener

2022-08-10 Thread Eugenio Pérez
This enable net/vdpa to restart the full device when a migration is started or stopped. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 87 1 file changed, 87 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a035c89c34

[PATCH v8 12/12] vdpa: Delete CVQ migration blocker

2022-08-09 Thread Eugenio Pérez
We can restore the device state in the destination via CVQ now. Remove the migration blocker. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- include/hw/virtio/vhost-vdpa.h | 1 - hw/virtio/vhost-vdpa.c | 14 -- net/vhost-vdpa.c | 2 -- 3 files changed

[PATCH v8 08/12] vdpa: Move command buffers map to start of net device

2022-08-09 Thread Eugenio Pérez
As this series will reuse them to restore the device state at the end of a migration (or a device start), let's allocate only once at the device start so we don't duplicate their map and unmap. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 123

[PATCH v8 07/12] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo

2022-08-09 Thread Eugenio Pérez
Next patches will add a new info callback to restore NIC status through CVQ. Since only the CVQ vhost device is needed, create it with a new NetClientInfo. Signed-off-by: Eugenio Pérez --- v5: Create a new NetClientInfo instead of reusing the dataplane one. --- net/vhost-vdpa.c | 12

[PATCH v8 05/12] vhost_net: Add NetClientInfo prepare callback

2022-08-09 Thread Eugenio Pérez
This is used by the backend to perform actions before the device is started. In particular, vdpa net use it to map CVQ buffers to the device, so it can send control commands using them. Signed-off-by: Eugenio Pérez --- v8: Rename NetClientInfo prepare callback to start, so it aligns

[PATCH v8 02/12] vhost: use SVQ element ndescs instead of opaque data for desc validation

2022-08-09 Thread Eugenio Pérez
Since we're going to allow SVQ to add elements without the guest's knowledge and without its own VirtQueueElement, it's easier to check if an element is a valid head checking a different thing than the VirtQueueElement. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- hw/virtio/vhost

[PATCH v8 11/12] vdpa: Add virtio-net mac address via CVQ at start

2022-08-09 Thread Eugenio Pérez
This is needed so the destination vdpa device see the same state a the guest set in the source. Signed-off-by: Eugenio Pérez --- v8: * Delete unneeded copy from device's in buffer. v6: * Map and unmap command buffers at the start and end of device usage. v5: * Rename s/start/load/ * Use

[PATCH v8 09/12] vdpa: extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail

2022-08-09 Thread Eugenio Pérez
So we can reuse it to inject state messages. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang -- v7: * Remove double free error v6: * Do not assume in buffer sent to the device is sizeof(virtio_net_ctrl_ack) v5: * Do not use an artificial !NULL VirtQueueElement * Use only out size instead

[PATCH v8 04/12] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush

2022-08-09 Thread Eugenio Pérez
-by: Eugenio Pérez Acked-by: Jason Wang --- v6: Change less from the previous function --- hw/virtio/vhost-shadow-virtqueue.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index 1b49bf54f2..f863b08627

[PATCH v8 10/12] vhost_net: add NetClientState->load() callback

2022-08-09 Thread Eugenio Pérez
It allows per-net client operations right after device's successful start. In particular, to load the device status. Vhost-vdpa net will use it to add the CVQ buffers to restore the device status. Signed-off-by: Eugenio Pérez --- v5: Rename start / load, naming it more specifically

[PATCH v8 03/12] vhost: Delete useless read memory barrier

2022-08-09 Thread Eugenio Pérez
As discussed in previous series [1], this memory barrier is useless with the atomic read of used idx at vhost_svq_more_used. Deleting it. [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-07/msg02616.html Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- hw/virtio/vhost-shadow

[PATCH v8 01/12] vhost: stop transfer elem ownership in vhost_handle_guest_kick

2022-08-09 Thread Eugenio Pérez
It was easier to allow vhost_svq_add to handle the memory. Now that we will allow qemu to add elements to a SVQ without the guest's knowledge, it's better to handle it in the caller. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- hw/virtio/vhost-shadow-virtqueue.c | 10 -- 1

[PATCH v8 06/12] vhost_net: Add NetClientInfo stop callback

2022-08-09 Thread Eugenio Pérez
Used by the backend to perform actions after the device is stopped. In particular, vdpa net use it to unmap CVQ buffers to the device, cleaning the actions performend in prepare(). Signed-off-by: Eugenio Pérez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 3 +++ 2 files changed, 5

[PATCH v8 00/12] NIC vhost-vdpa state restore via Shadow CVQ

2022-08-09 Thread Eugenio Pérez
mode v1 from RFC: - Do not reorder DRIVER_OK & enable patches. - Delete leftovers Eugenio Pérez (12): vhost: stop transfer elem ownership in vhost_handle_guest_kick vhost: use SVQ element ndescs instead of opaque data for desc validation vhost: Delete useless read memory barrier v

[PATCH v4 6/6] vdpa: Always start CVQ in SVQ mode

2022-08-05 Thread Eugenio Pérez
Isolate control virtqueue in its own group, allowing to intercept control commands but letting dataplane run totally passthrough to the guest. Signed-off-by: Eugenio Pérez --- v4: * Squash vhost_vdpa_cvq_group_is_independent. * Rebased on last CVQ start series, that allocated CVQ cmd bufs

[PATCH v4 4/6] vdpa: Add asid parameter to vhost_vdpa_dma_map/unmap

2022-08-05 Thread Eugenio Pérez
-off-by: Eugenio Pérez --- v4: Add comment specifying behavior if device does not support _F_ASID v3: Deleted unneeded space --- include/hw/virtio/vhost-vdpa.h | 8 +--- hw/virtio/vhost-vdpa.c | 25 +++-- net/vhost-vdpa.c | 6 +++--- hw/virtio/trace

[PATCH v4 3/6] vdpa: Allocate SVQ unconditionally

2022-08-05 Thread Eugenio Pérez
SVQ may run or not in a device depending on runtime conditions (for example, if the device can move CVQ to its own group or not). Allocate the resources unconditionally, and decide later if to use them or not. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 33

[PATCH v4 1/6] linux-headers: Update kernel headers

2022-08-05 Thread Eugenio Pérez
Main reason is for new vhost_vdpa address space ioctls to be available. Update kernel headers until 9de1f9c8ca51 ("Merge tag 'irq-core-2022-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip"). Signed-off-by: Eugenio Pérez --- include/standard-headers/asm-x86/bootpa

[PATCH v4 5/6] vdpa: Store x-svq parameter in VhostVDPAState

2022-08-05 Thread Eugenio Pérez
with different conditions, making it possible to go from "not isolated group" to "isolated". Saving the cmdline parameter in an extra field so we never disable CVQ SVQ in case the device was started with cmdline. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 4 1 file c

[PATCH v4 2/6] vdpa: Use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop

2022-08-05 Thread Eugenio Pérez
This function used to trust in v->shadow_vqs != NULL to know if it must start svq or not. This is not going to be valid anymore, as qemu is going to allocate svq unconditionally (but it will only start them conditionally). Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 4 ++--

[PATCH v4 0/6] ASID support in vhost-vdpa net

2022-08-05 Thread Eugenio Pérez
rg/archive/html/qemu-devel/2022-08/msg00349.html Eugenio Pérez (6): linux-headers: Update kernel headers vdpa: Use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop vdpa: Allocate SVQ unconditionally vdpa: Add asid parameter to vhost_vdpa_dma_map/unmap vdpa: Stor

[PATCH v7 03/12] vhost: Delete useless read memory barrier

2022-08-04 Thread Eugenio Pérez
As discussed in previous series [1], this memory barrier is useless with the atomic read of used idx at vhost_svq_more_used. Deleting it. [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-07/msg02616.html Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 3 --- 1

[PATCH v7 09/12] vdpa: Extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail

2022-08-04 Thread Eugenio Pérez
So we can reuse it to inject state messages. Signed-off-by: Eugenio Pérez -- v7: * Remove double free error v6: * Do not assume in buffer sent to the device is sizeof(virtio_net_ctrl_ack) v5: * Do not use an artificial !NULL VirtQueueElement * Use only out size instead of iovec dev_buffers

[PATCH v7 12/12] vdpa: Delete CVQ migration blocker

2022-08-04 Thread Eugenio Pérez
We can restore the device state in the destination via CVQ now. Remove the migration blocker. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 1 - hw/virtio/vhost-vdpa.c | 14 -- net/vhost-vdpa.c | 2 -- 3 files changed, 17 deletions

[PATCH v7 06/12] vhost_net: Add NetClientInfo stop callback

2022-08-04 Thread Eugenio Pérez
Used by the backend to perform actions after the device is stopped. In particular, vdpa net use it to unmap CVQ buffers to the device, cleaning the actions performend in prepare(). Signed-off-by: Eugenio Pérez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 3 +++ 2 files changed, 5

[PATCH v7 11/12] vdpa: Add virtio-net mac address via CVQ at start

2022-08-04 Thread Eugenio Pérez
This is needed so the destination vdpa device see the same state a the guest set in the source. Signed-off-by: Eugenio Pérez --- v6: * Map and unmap command buffers at the start and end of device usage. v5: * Rename s/start/load/ * Use independent NetClientInfo to only add load callback on cvq

[PATCH v7 10/12] vhost_net: add NetClientState->load() callback

2022-08-04 Thread Eugenio Pérez
It allows per-net client operations right after device's successful start. In particular, to load the device status. Vhost-vdpa net will use it to add the CVQ buffers to restore the device status. Signed-off-by: Eugenio Pérez --- v5: Rename start / load, naming it more specifically

[PATCH v7 00/12] NIC vhost-vdpa state restore via Shadow CVQ

2022-08-04 Thread Eugenio Pérez
. v3: - Route vhost-vdpa start code through NetClientInfo callback. - Delete extra vhost_net_stop_one() call. v2: - Fix SIGSEGV dereferencing SVQ when not in svq mode v1 from RFC: - Do not reorder DRIVER_OK & enable patches. - Delete leftovers Eugenio Pérez (12): vhost: stop transfer

[PATCH v7 07/12] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo

2022-08-04 Thread Eugenio Pérez
Next patches will add a new info callback to restore NIC status through CVQ. Since only the CVQ vhost device is needed, create it with a new NetClientInfo. Signed-off-by: Eugenio Pérez --- v5: Create a new NetClientInfo instead of reusing the dataplane one. --- net/vhost-vdpa.c | 12

[PATCH v7 05/12] vhost_net: Add NetClientInfo prepare callback

2022-08-04 Thread Eugenio Pérez
This is used by the backend to perform actions before the device is started. In particular, vdpa net use it to map CVQ buffers to the device, so it can send control commands using them. Signed-off-by: Eugenio Pérez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 7 +++ 2 files changed

[PATCH v7 08/12] vdpa: Move command buffers map to start of net device

2022-08-04 Thread Eugenio Pérez
As this series will reuse them to restore the device state at the end of a migration (or a device start), let's allocate only once at the device start so we don't duplicate their map and unmap. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 123

[PATCH v6 11/12] vdpa: Add virtio-net mac address via CVQ at start

2022-08-04 Thread Eugenio Pérez
This is needed so the destination vdpa device see the same state a the guest set in the source. Signed-off-by: Eugenio Pérez --- v6: * Map and unmap command buffers at the start and end of device usage. v5: * Rename s/start/load/ * Use independent NetClientInfo to only add load callback on cvq

[PATCH v7 04/12] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush

2022-08-04 Thread Eugenio Pérez
-by: Eugenio Pérez --- v6: Change less from the previous function --- hw/virtio/vhost-shadow-virtqueue.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index 1b49bf54f2..f863b08627 100644 --- a/hw/virtio

[PATCH v7 01/12] vhost: stop transfer elem ownership in vhost_handle_guest_kick

2022-08-04 Thread Eugenio Pérez
It was easier to allow vhost_svq_add to handle the memory. Now that we will allow qemu to add elements to a SVQ without the guest's knowledge, it's better to handle it in the caller. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 10 -- 1 file changed, 4

[PATCH v6 09/12] vdpa: Extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail

2022-08-04 Thread Eugenio Pérez
So we can reuse it to inject state messages. Signed-off-by: Eugenio Pérez -- v6: * Do not assume in buffer sent to the device is sizeof(virtio_net_ctrl_ack) v5: * Do not use an artificial !NULL VirtQueueElement * Use only out size instead of iovec dev_buffers for these functions. --- net/vhost

[PATCH v7 02/12] vhost: use SVQ element ndescs instead of opaque data for desc validation

2022-08-04 Thread Eugenio Pérez
Since we're going to allow SVQ to add elements without the guest's knowledge and without its own VirtQueueElement, it's easier to check if an element is a valid head checking a different thing than the VirtQueueElement. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 3

[PATCH v6 07/12] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo

2022-08-04 Thread Eugenio Pérez
Next patches will add a new info callback to restore NIC status through CVQ. Since only the CVQ vhost device is needed, create it with a new NetClientInfo. Signed-off-by: Eugenio Pérez --- v5: Create a new NetClientInfo instead of reusing the dataplane one. --- net/vhost-vdpa.c | 12

[PATCH v6 10/12] vhost_net: add NetClientState->load() callback

2022-08-04 Thread Eugenio Pérez
It allows per-net client operations right after device's successful start. In particular, to load the device status. Vhost-vdpa net will use it to add the CVQ buffers to restore the device status. Signed-off-by: Eugenio Pérez --- v5: Rename start / load, naming it more specifically

[PATCH v6 04/12] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush

2022-08-04 Thread Eugenio Pérez
-by: Eugenio Pérez --- v6: Change less from the previous function --- hw/virtio/vhost-shadow-virtqueue.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index 1b49bf54f2..f863b08627 100644 --- a/hw/virtio

[PATCH v6 08/12] vdpa: Move command buffers map to start of net device

2022-08-04 Thread Eugenio Pérez
As this series will reuse them to restore the device state at the end of a migration (or a device start), let's allocate only once at the device start so we don't duplicate their map and unmap. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 123

[PATCH v6 06/12] vhost_net: Add NetClientInfo stop callback

2022-08-04 Thread Eugenio Pérez
Used by the backend to perform actions after the device is stopped. In particular, vdpa net use it to unmap CVQ buffers to the device, cleaning the actions performend in prepare(). Signed-off-by: Eugenio Pérez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 3 +++ 2 files changed, 5

[PATCH v6 03/12] vhost: Delete useless read memory barrier

2022-08-04 Thread Eugenio Pérez
As discussed in previous series [1], this memory barrier is useless with the atomic read of used idx at vhost_svq_more_used. Deleting it. [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-07/msg02616.html Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 3 --- 1

[PATCH v6 02/12] vhost: use SVQ element ndescs instead of opaque data for desc validation

2022-08-04 Thread Eugenio Pérez
Since we're going to allow SVQ to add elements without the guest's knowledge and without its own VirtQueueElement, it's easier to check if an element is a valid head checking a different thing than the VirtQueueElement. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 3

[PATCH v6 01/12] vhost: stop transfer elem ownership in vhost_handle_guest_kick

2022-08-04 Thread Eugenio Pérez
It was easier to allow vhost_svq_add to handle the memory. Now that we will allow qemu to add elements to a SVQ without the guest's knowledge, it's better to handle it in the caller. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 10 -- 1 file changed, 4

[PATCH v6 05/12] vhost_net: Add NetClientInfo prepare callback

2022-08-04 Thread Eugenio Pérez
This is used by the backend to perform actions before the device is started. In particular, vdpa net use it to map CVQ buffers to the device, so it can send control commands using them. Signed-off-by: Eugenio Pérez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 7 +++ 2 files changed

[PATCH v6 12/12] vdpa: Delete CVQ migration blocker

2022-08-04 Thread Eugenio Pérez
We can restore the device state in the destination via CVQ now. Remove the migration blocker. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 1 - hw/virtio/vhost-vdpa.c | 14 -- net/vhost-vdpa.c | 2 -- 3 files changed, 17 deletions

[PATCH v6 00/12] NIC vhost-vdpa state restore via Shadow CVQ

2022-08-04 Thread Eugenio Pérez
through NetClientInfo callback. - Delete extra vhost_net_stop_one() call. v2: - Fix SIGSEGV dereferencing SVQ when not in svq mode v1 from RFC: - Do not reorder DRIVER_OK & enable patches. - Delete leftovers Eugenio Pérez (12): vhost: stop transfer elem ownership in vhost_handle_guest_

[PATCH v2 2/2] vdpa: do not save failed dma maps in SVQ iova tree

2022-08-04 Thread Eugenio Pérez
If a map fails for whatever reason, it must not be saved in the tree. Otherwise, qemu will try to unmap it in cleanup, leaving to more errors. Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ") Reported-by: Lei Yang Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-v

[PATCH v2 0/2] vdpa: do not save failed dma maps in SVQ iova tree

2022-08-04 Thread Eugenio Pérez
If a map fails for whatever reason, it must not be saved in the tree. Otherwise, qemu will try to unmap it in cleanup, leaving to more errors. v2: Do not dereference failed maps Eugenio Pérez (2): vdpa: Skip the maps not in the iova tree vdpa: do not save failed dma maps in SVQ iova tree

[PATCH v2 1/2] vdpa: Skip the maps not in the iova tree

2022-08-04 Thread Eugenio Pérez
Next patch will skip the registering of dma maps that the vdpa device rejects in the iova tree. We need to consider that here or we cause a SIGSEGV accessing result. Reported-by: Lei Yang Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 4 1 file changed, 4 insertions(+) diff

[PATCH v3 4/7] vdpa: Add asid parameter to vhost_vdpa_dma_map/unmap

2022-08-03 Thread Eugenio Pérez
-off-by: Eugenio Pérez --- v3: Deleted unneeded space --- include/hw/virtio/vhost-vdpa.h | 8 +--- hw/virtio/vhost-vdpa.c | 25 +++-- net/vhost-vdpa.c | 6 +++--- hw/virtio/trace-events | 4 ++-- 4 files changed, 25 insertions(+), 18

[PATCH v3 1/7] linux-headers: Update kernel headers

2022-08-03 Thread Eugenio Pérez
Main reason is for new vhost_vdpa address space ioctls to be available. Update kernel headers until 9de1f9c8ca51 ("Merge tag 'irq-core-2022-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip"). Signed-off-by: Eugenio Pérez --- include/standard-headers/asm-x86/bootpa

[PATCH v3 2/7] vdpa: Use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop

2022-08-03 Thread Eugenio Pérez
This function used to trust in v->shadow_vqs != NULL to know if it must start svq or not. This is not going to be valid anymore, as qemu is going to allocate svq unconditionally (but it will only start them conditionally). Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 4 ++--

[PATCH v3 3/7] vdpa: Allocate SVQ unconditionally

2022-08-03 Thread Eugenio Pérez
SVQ may run or not in a device depending on runtime conditions (for example, if the device can move CVQ to its own group or not). Allocate the resources unconditionally, and decide later if to use them or not. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 33

[PATCH v3 5/7] vdpa: Store x-svq parameter in VhostVDPAState

2022-08-03 Thread Eugenio Pérez
with different conditions, making it possible to go from "not isolated group" to "isolated". Saving the cmdline parameter in an extra field so we never disable CVQ SVQ in case the device was started with cmdline. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 4 1 file c

[PATCH v3 0/7] ASID support in vhost-vdpa net

2022-08-03 Thread Eugenio Pérez
ot support CVQ - Add BIT_ULL missed checking device's backend feature for _F_ASID. [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-08/msg00349.html Eugenio Pérez (7): linux-headers: Update kernel headers vdpa: Use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop v

[PATCH v3 6/7] vhost_net: Add NetClientInfo prepare callback

2022-08-03 Thread Eugenio Pérez
This is used by the backend to perform actions before the device is started. In particular, vdpa will use it to isolate CVQ in its own ASID if possible, and start SVQ unconditionally only in CVQ. Signed-off-by: Eugenio Pérez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 4 2 files

[PATCH v3 7/7] vdpa: Always start CVQ in SVQ mode

2022-08-03 Thread Eugenio Pérez
Isolate control virtqueue in its own group, allowing to intercept control commands but letting dataplane run totally passthrough to the guest. Signed-off-by: Eugenio Pérez --- v3: * Make asid related queries print a warning instead of returning an error and stop the start of qemu. --- hw

[PATCH v5 06/10] vdpa: Make vhost_vdpa_net_cvq_map_elem accept any out sg

2022-08-02 Thread Eugenio Pérez
So its generic enough to accept any out sg buffer and we can inject NIC state messages. Signed-off-by: Eugenio Pérez --- v5: Accept out sg instead of dev_buffers[] --- net/vhost-vdpa.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost

[PATCH v5 05/10] vdpa: Extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail

2022-08-02 Thread Eugenio Pérez
So we can reuse it to inject state messages. Signed-off-by: Eugenio Pérez -- v5: * Do not use an artificial !NULL VirtQueueElement * Use only out size instead of iovec dev_buffers for these functions. --- net/vhost-vdpa.c | 73 1 file changed, 49

[PATCH v5 08/10] vdpa: add net_vhost_vdpa_cvq_info NetClientInfo

2022-08-02 Thread Eugenio Pérez
Next patches will add a new info callback to restore NIC status through CVQ. Since only the CVQ vhost device is needed, create it with a new NetClientInfo. Signed-off-by: Eugenio Pérez --- v5: Create a new NetClientInfo instead of reusing the dataplane one. --- net/vhost-vdpa.c | 12

[PATCH v5 03/10] vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush

2022-08-02 Thread Eugenio Pérez
-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index e6eebd0e8d..fdb550c31b 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw

[PATCH v5 10/10] vdpa: Delete CVQ migration blocker

2022-08-02 Thread Eugenio Pérez
We can restore the device state in the destination via CVQ now. Remove the migration blocker. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 1 - hw/virtio/vhost-vdpa.c | 14 -- net/vhost-vdpa.c | 2 -- 3 files changed, 17 deletions

[PATCH v5 07/10] vdpa: add NetClientState->load() callback

2022-08-02 Thread Eugenio Pérez
It allows per-net client operations right after device's successful start. In particular, to load the device status. Vhost-vdpa net will use it to add the CVQ buffers to restore the device status. Signed-off-by: Eugenio Pérez --- v5: Rename start / load, naming it more specifically

[PATCH v5 02/10] vhost: use SVQ element ndescs instead of opaque data for desc validation

2022-08-02 Thread Eugenio Pérez
Since we're going to allow SVQ to add elements without the guest's knowledge and without its own VirtQueueElement, it's easier to check if an element is a valid head checking a different thing than the VirtQueueElement. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 3

[PATCH v5 09/10] vdpa: Add virtio-net mac address via CVQ at start

2022-08-02 Thread Eugenio Pérez
This is needed so the destination vdpa device see the same state a the guest set in the source. Signed-off-by: Eugenio Pérez --- v5: * Rename s/start/load/ * Use independent NetClientInfo to only add load callback on cvq. --- net/vhost-vdpa.c | 50

[PATCH v5 04/10] vdpa: Get buffers from VhostVDPAState on vhost_vdpa_net_cvq_map_elem

2022-08-02 Thread Eugenio Pérez
There is no need to get them by parameter, since they're contained in VhostVDPAState. The only useful information was the written length in out. Simplify the function removing those. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 17 ++--- 1 file changed, 6 insertions(+), 11

[PATCH v5 01/10] vhost: stop transfer elem ownership in vhost_handle_guest_kick

2022-08-02 Thread Eugenio Pérez
It was easier to allow vhost_svq_add to handle the memory. Now that we will allow qemu to add elements to a SVQ without the guest's knowledge, it's better to handle it in the caller. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 10 -- 1 file changed, 4

[PATCH v5 00/10] NIC vhost-vdpa state restore via Shadow CVQ

2022-08-02 Thread Eugenio Pérez
DRIVER_OK & enable patches. - Delete leftovers Eugenio Pérez (10): vhost: stop transfer elem ownership in vhost_handle_guest_kick vhost: use SVQ element ndescs instead of opaque data for desc validation vhost: Do not depend on !NULL VirtQueueElement on vhost_svq_flush vdpa: Get buffers

[PATCH] vdpa: do not save failed dma maps in SVQ iova tree

2022-08-02 Thread Eugenio Pérez
If a map fails for whatever reason, it must not be saved in the tree. Otherwise, qemu will try to unmap it in cleanup, leaving to more errors. Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ") Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 20 +

[PATCH 1/2] vdpa: Fix file descriptor leak on get features error

2022-08-02 Thread Eugenio Pérez
Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 6abad276a6..303447a68e 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -566,7 +566,7 @@ int net_init_vhost_vdpa(const Netd

[PATCH 0/2] vdpa: Merge all net_init_vhost_vdpa error goto

2022-08-02 Thread Eugenio Pérez
Few steps allocate new resources, and all of the allocated can be checked to avoid trying to free an invalid one. This series includes an already posted patch [1], because it must be applied on top of that. [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-08/msg00089.html Eugenio Pérez

[PATCH 2/2] vdpa: Merge all net_init_vhost_vdpa error goto

2022-08-02 Thread Eugenio Pérez
Few steps allocate new resources, and all of the allocated can be checked to avoid trying to free an invalid one. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 303447a68e

[PATCH] vdpa: Fix file descriptor leak on get features error

2022-08-01 Thread Eugenio Pérez
Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 6abad276a6..303447a68e 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -566,7 +566,7 @@ int net_init_vhost_vdpa(const Netd

[PATCH v2 4/7] vdpa: Add asid parameter to vhost_vdpa_dma_map/unmap

2022-07-22 Thread Eugenio Pérez
-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 8 +--- hw/virtio/vhost-vdpa.c | 26 -- net/vhost-vdpa.c | 6 +++--- hw/virtio/trace-events | 4 ++-- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/hw

[PATCH v2 3/7] vdpa: Allocate SVQ unconditionally

2022-07-22 Thread Eugenio Pérez
SVQ may run or not in a device depending on runtime conditions (for example, if the device can move CVQ to its own group or not). Allocate the resources unconditionally, and decide later if to use them or not. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 33

[PATCH v2 7/7] vdpa: Always start CVQ in SVQ mode

2022-07-22 Thread Eugenio Pérez
Isolate control virtqueue in its own group, allowing to intercept control commands but letting dataplane run totally passthrough to the guest. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 3 +- net/vhost-vdpa.c | 158 +++-- 2 files

[PATCH v2 6/7] vhost_net: Add NetClientInfo prepare callback

2022-07-22 Thread Eugenio Pérez
This is used by the backend to perform actions before the device is started. In particular, vdpa will use it to isolate CVQ in its own ASID if possible, and start SVQ unconditionally only in CVQ. Signed-off-by: Eugenio Pérez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 4 2 files

[PATCH v2 1/7] linux-headers: Update kernel headers to v5.19-rc1

2022-07-22 Thread Eugenio Pérez
Main reason is for new vhost_vdpa address space ioctls to be available. Signed-off-by: Eugenio Pérez --- include/standard-headers/asm-x86/bootparam.h | 1 + include/standard-headers/drm/drm_fourcc.h| 69 include/standard-headers/linux/ethtool.h | 1 + include

[PATCH v2 5/7] vdpa: Store x-svq parameter in VhostVDPAState

2022-07-22 Thread Eugenio Pérez
with different conditions, making it possible to go from "not isolated group" to "isolated". Saving the cmdline parameter in an extra field so we never disable CVQ SVQ in case the device was started with cmdline. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 4 1 file c

[PATCH v2 0/7] ASID support in vhost-vdpa net

2022-07-22 Thread Eugenio Pérez
series [1], handle vhost_net backend through NetClientInfo callbacks instead of directly. - Fix not freeing SVQ properly when device does not support CVQ - Add BIT_ULL missed checking device's backend feature for _F_ASID. [1] https://lists.nongnu.org/archive/html/qemu-devel/2022-07/msg04009.htm

[PATCH v2 2/7] vdpa: Use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop

2022-07-22 Thread Eugenio Pérez
This function used to trust in v->shadow_vqs != NULL to know if it must start svq or not. This is not going to be valid anymore, as qemu is going to allocate svq unconditionally (but it will only start them conditionally). Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 4 ++--

[PATCH v4 7/7] vdpa: Delete CVQ migration blocker

2022-07-22 Thread Eugenio Pérez
We can restore the device state in the destination via CVQ now. Remove the migration blocker. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 1 - hw/virtio/vhost-vdpa.c | 14 -- net/vhost-vdpa.c | 2 -- 3 files changed, 17 deletions

[PATCH v4 4/7] vdpa: add NetClientState->start() callback

2022-07-22 Thread Eugenio Pérez
It allows per-net client operations right after device's successful start. Vhost-vdpa net will use it to add the CVQ buffers to restore the device status. Signed-off-by: Eugenio Pérez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 7 +++ 2 files changed, 9 insertions(+) diff --git

[PATCH v4 6/7] vdpa: Add virtio-net mac address via CVQ at start

2022-07-22 Thread Eugenio Pérez
This is needed so the destination vdpa device see the same state a the guest set in the source. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 61 1 file changed, 61 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index

[PATCH v4 2/7] vdpa: Extract vhost_vdpa_net_cvq_add from vhost_vdpa_net_handle_ctrl_avail

2022-07-22 Thread Eugenio Pérez
So we can reuse to inject state messages. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 74 ++-- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 6abad276a6..1b82ac2e07 100644 --- a/net

[PATCH v4 1/7] vhost: stop transfer elem ownership in vhost_handle_guest_kick

2022-07-22 Thread Eugenio Pérez
It was easier to allow vhost_svq_add to handle the memory. Now that we will allow qemu to add elements to a SVQ without the guest's knowledge, it's better to handle it in the caller. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 10 -- 1 file changed, 4

[PATCH v4 3/7] vdpa: Make vhost_vdpa_net_cvq_map_elem accept any out sg

2022-07-22 Thread Eugenio Pérez
So its generic enough to accept any out sg buffer and we can inject NIC state messages. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1b82ac2e07

<    1   2   3   4   5   6   7   8   9   10   >