Lift restriction about VDUSE net devices with CVQ
Subsystems (4)
Eugenio Pérez
maintainercover Lift restriction about VDUSE net devices with CVQ
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.
A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Eugenio Pérez (2):
virtio_net: timeout control virtqueue commands
vduse: lift restriction about net devices with CVQ
drivers/net/virtio_net.c | 10 ++++++++++ drivers/vdpa/vdpa_user/vduse_dev.c | 3 --- 2 files changed, 10 insertions(+), 3 deletions(-)
Signature · 1 line
2.51.0
Eugenio Pérez
maintainerRFC 1/2 virtio_net: timeout control virtqueue commands
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.
A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/virtio_net.c +10 -0
@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;
@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;while (!virtqueue_get_buf (vi->cvq, &tmp) && !virtqueue_is_broken (vi->cvq)) {cond_resched ();cpu_relax (); + +if (time_after (end_time, jiffies)) { +/* TODO Reset vq if possible? */ +virtio_break_device (vi->vdev); +break ; + } } unlock:
Signature · 1 line
2.51.0
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 29 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/virtio_net.c +1
-0@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;
drivers/net/virtio_net.c static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd · line 3621
Quoted 7 lines
drivers/net/virtio_net.c +3
-0@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;
The problem that 30 * HZ is probably long enough to trigger the warnings like hungtask?
Quoted 14 lines
drivers/net/virtio_net.c +6
-1while (!virtqueue_get_buf (vi->cvq, &tmp) && !virtqueue_is_broken (vi->cvq)) {cond_resched ();cpu_relax (); + +if (time_after (end_time, jiffies)) { +/* TODO Reset vq if possible? */ +virtio_break_device (vi->vdev); +break ; + } } unlock: --
Quoted 2 lines
2.51.0
Thansk
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 32 lines · Jason Wang
Quoted 30 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/virtio_net.c +1
-0@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd
Quoted 10 lines
drivers/net/virtio_net.c static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd · line 3621
Quoted 6 lines
drivers/net/virtio_net.c +3
-0/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;The problem that 30 * HZ is probably long enough to trigger the warnings like hungtask?
That's right. OTOH, the same behavior from the device already triggers the hungtask.
Maybe it is better to set it to 15*HZ?
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
In reply to Eugenio PérezQuoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Quoted 45 lines
A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/virtio_net.c +10
-0@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;while (!virtqueue_get_buf (vi->cvq, &tmp) && !virtqueue_is_broken (vi->cvq)) {cond_resched ();cpu_relax (); + +if (time_after (end_time, jiffies)) { +/* TODO Reset vq if possible? */ +virtio_break_device (vi->vdev); +break ; + } } unlock:Signature · 1 line
2.51.0
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.
Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Thanks,
Maxime
Quoted 47 lines
Quoted 46 lines
A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/virtio_net.c +10
-1@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;while (!virtqueue_get_buf (vi->cvq, &tmp) && !virtqueue_is_broken (vi->cvq)) {cond_resched ();cpu_relax (); + +if (time_after (end_time, jiffies)) { +/* TODO Reset vq if possible? */ +virtio_break_device (vi->vdev); +break ; + } } unlock: --2.51.0
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 19 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
Quoted 5 lines
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Thanks,
Maxime
Yes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.
Quoted 47 lines
Quoted 47 lines
Quoted 46 lines
A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/virtio_net.c +10
-1@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;while (!virtqueue_get_buf (vi->cvq, &tmp) && !virtqueue_is_broken (vi->cvq)) {cond_resched ();cpu_relax (); + +if (time_after (end_time, jiffies)) { +/* TODO Reset vq if possible? */ +virtio_break_device (vi->vdev); +break ; + } } unlock: --2.51.0
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 8 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.
I agree, this is the way to go.
Thanks for your insights,
Maxime
Quoted 50 lines
Quoted 49 lines
Quoted 49 lines
Quoted 48 lines
A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/virtio_net.c +10
-1@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;while (!virtqueue_get_buf (vi->cvq, &tmp) && !virtqueue_is_broken (vi->cvq)) {cond_resched ();cpu_relax (); + +if (time_after (end_time, jiffies)) { +/* TODO Reset vq if possible? */ +virtio_break_device (vi->vdev); +break ; + } } unlock: --2.51.0
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 35 lines · Maxime Coquelin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 8 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.
Quoted 4 lines
I agree, this is the way to go.
Thanks for your insights,
Maxime
A timeout still needs to be considered in this case. Or I may miss something?
Thanks
Quoted 52 lines
Quoted 51 lines
Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/virtio_net.c +10
-1@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;while (!virtqueue_get_buf (vi->cvq, &tmp) && !virtqueue_is_broken (vi->cvq)) {cond_resched ();cpu_relax (); + +if (time_after (end_time, jiffies)) { +/* TODO Reset vq if possible? */ +virtio_break_device (vi->vdev); +break ; + } } unlock: --2.51.0
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 36 lines · Jason Wang
Quoted 35 lines · Maxime Coquelin
Quoted 32 lines · Michael S. Tsirkin
Quoted 19 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
Quoted 5 lines
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.
Quoted 8 lines
Quoted 4 lines
I agree, this is the way to go.
Thanks for your insights,
MaximeA timeout still needs to be considered in this case. Or I may miss something?
Thanks
Not as such, kernel can use buffers (semi) predictably.
Quoted 52 lines
Quoted 52 lines
Quoted 51 lines
Quoted 50 lines
Quoted 50 lines
Quoted 49 lines
A less agressive path can be taken to recover the device, like only resetting the control virtqueue. However, the state of the device after this action is taken races, as the vq could be reset after the device writes the OK. Leaving TODO anyway.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/net/virtio_net.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/virtio_net.c +10
-1@@ -3576,6 +3576,7 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd {struct scatterlist *sgs[5 ], hdr, stat;u32 out_num =0 , tmp, in_num =0 ; +unsigned long end_time;bool ok;int ret;@@ -3614,11 +3615,20 @@ static bool virtnet_send_command_reply(struct virtnet_info *vi, u8 class, u8 cmd/* Spin for a response, the kick causes an ioport write, trapping * into the hypervisor, so the request should be handled immediately. +* +* Long timeout so a malicious device is not able to lock rtnl forever. */ + end_time = jiffies +30 *HZ ;while (!virtqueue_get_buf (vi->cvq, &tmp) && !virtqueue_is_broken (vi->cvq)) {cond_resched ();cpu_relax (); + +if (time_after (end_time, jiffies)) { +/* TODO Reset vq if possible? */ +virtio_break_device (vi->vdev); +break ; + } } unlock: --2.51.0
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
In reply to Michael S. TsirkinQuoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
The second one, what to do when the VDUSE cvq runs out of descriptors? While the driver has its descriptor returned with VIRTIO_NET_ERR, the VDUSE CVQ has the descriptor available. If this process repeats to make available all of the VDUSE CVQ descriptors, how can we proceed?
I think both of them can be solved with the DEVICE_NEEDS_RESET status bit, but it is not implemented in the drivers at this moment.
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.
Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 5 lines
The second one, what to do when the VDUSE cvq runs out of descriptors? While the driver has its descriptor returned with
VIRTIO_NET_ERR, the VDUSE CVQ has the descriptor available. If this process repeats to make available all of the VDUSE CVQ descriptors, how can we proceed?
There's no reason to return VIRTIO_NET_ERR ever and cvq will not run out of descriptors. Kernel uses cvq buffers.
Quoted 2 lines
I think both of them can be solved with the
DEVICE_NEEDS_RESETstatus bit, but it is not implemented in the drivers at this moment.
No need for a reset, either.
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 37 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 33 lines · Michael S. Tsirkin
Quoted 19 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
Quoted 5 lines
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.
Quoted 9 lines
Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
Quoted 17 lines
Quoted 7 lines
The second one, what to do when the VDUSE cvq runs out of descriptors? While the driver has its descriptor returned with
VIRTIO_NET_ERR, the VDUSE CVQ has the descriptor available. If this process repeats to make available all of the VDUSE CVQ descriptors, how can we proceed?There's no reason to return
VIRTIO_NET_ERRever and cvq will not run out of descriptors. Kernel uses cvq buffers.Quoted 2 lines
I think both of them can be solved with the
DEVICE_NEEDS_RESETstatus bit, but it is not implemented in the drivers at this moment.No need for a reset, either.
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 45 lines · Eugenio Perez Martin
Quoted 44 lines · Michael S. Tsirkin
Quoted 41 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
Quoted 5 lines
Quoted 2 lines
There's no timeout. Kernel can guarantee executing all requests.
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Quoted 17 lines
Quoted 17 lines
Quoted 7 lines
The second one, what to do when the VDUSE cvq runs out of descriptors? While the driver has its descriptor returned with
VIRTIO_NET_ERR, the VDUSE CVQ has the descriptor available. If this process repeats to make available all of the VDUSE CVQ descriptors, how can we proceed?There's no reason to return
VIRTIO_NET_ERRever and cvq will not run out of descriptors. Kernel uses cvq buffers.Quoted 2 lines
I think both of them can be solved with the
DEVICE_NEEDS_RESETstatus bit, but it is not implemented in the drivers at this moment.No need for a reset, either.
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 50 lines · Michael S. Tsirkin
Quoted 48 lines · Eugenio Perez Martin
Quoted 46 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 7 lines
Quoted 2 lines
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Let me take a step back, I think I didn't describe the scenario well enough.
We have a VDUSE device, and then the same host is interacting with the device through the virtio_net driver over virtio_vdpa.
Then, the virtio_net driver sends a control command though its CVQ, so it *takes the RTNL*. That command reaches the VDUSE CVQ.
It does not matter if the VDUSE device in the userland processes the commands through a CVQ, reading the vduse character device, or another system. The question is: what to do if the VDUSE device does not process that command in a timely manner? Should we just let the RTNL be taken forever?
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 65 lines · Eugenio Perez Martin
Quoted 50 lines · Michael S. Tsirkin
Quoted 48 lines · Eugenio Perez Martin
Quoted 46 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 7 lines
Quoted 2 lines
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Let me take a step back, I think I didn't describe the scenario well enough.
We have a VDUSE device, and then the same host is interacting with the device through the
virtio_netdriver overvirtio_vdpa.
Quoted 9 lines
Then, the
virtio_netdriver sends a control command though its CVQ, so it *takes the RTNL*. That command reaches the VDUSE CVQ.It does not matter if the VDUSE device in the userland processes the commands through a CVQ, reading the vduse character device, or another system. The question is: what to do if the VDUSE device does not process that command in a timely manner? Should we just let the RTNL be taken forever?
My understanding is that:
1. Virtio-net sends a control messages, waits for reply
2. VDUSE driver dequeues it, adds it to the SCVQ, replies OK to the CVQ
3. Userspace application dequeues the message from the SCVQ a. If handling is successful it replies OK
b. If handling fails, replies ERROR
4. VDUSE driver reads the reply
a. if OK, do nothing
b. if ERROR, mark the device as broken?
This is simplified as it does not take into account SCVQ overflow if the application is stuck.
If IIUC, Michael suggests to only enqueue a single message at the time in the SVQ,
and bufferize the pending messages in the VDUSE driver.
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 87 lines · Maxime Coquelin
Quoted 65 lines · Eugenio Perez Martin
Quoted 50 lines · Michael S. Tsirkin
Quoted 48 lines · Eugenio Perez Martin
Quoted 46 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 7 lines
Quoted 2 lines
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Let me take a step back, I think I didn't describe the scenario well enough.
We have a VDUSE device, and then the same host is interacting with the device through the
virtio_netdriver overvirtio_vdpa.Quoted 9 lines
Then, the
virtio_netdriver sends a control command though its CVQ, so it *takes the RTNL*. That command reaches the VDUSE CVQ.It does not matter if the VDUSE device in the userland processes the commands through a CVQ, reading the vduse character device, or another system. The question is: what to do if the VDUSE device does not process that command in a timely manner? Should we just let the RTNL be taken forever?
My understanding is that:
1. Virtio-net sends a control messages, waits for reply
2. VDUSE driver dequeues it, adds it to the SCVQ, replies OK to the CVQ
3. Userspace application dequeues the message from the SCVQ a. If handling is successful it replies OK
b. If handling fails, replies ERROR
4. VDUSE driver reads the reply
a. if OK, do nothing
b. if ERROR, mark the device as broken?
Quoted 5 lines
This is simplified as it does not take into account SCVQ overflow if the application is stuck.
If IIUC, Michael suggests to only enqueue a single message at the time in the SVQ,
and bufferize the pending messages in the VDUSE driver.
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Signature · 1 line
MST
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 95 lines · Michael S. Tsirkin
Quoted 87 lines · Maxime Coquelin
Quoted 65 lines · Eugenio Perez Martin
Quoted 50 lines · Michael S. Tsirkin
Quoted 48 lines · Eugenio Perez Martin
Quoted 46 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 7 lines
Quoted 2 lines
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Let me take a step back, I think I didn't describe the scenario well enough.
We have a VDUSE device, and then the same host is interacting with the device through the
virtio_netdriver overvirtio_vdpa.Quoted 9 lines
Then, the
virtio_netdriver sends a control command though its CVQ, so it *takes the RTNL*. That command reaches the VDUSE CVQ.It does not matter if the VDUSE device in the userland processes the commands through a CVQ, reading the vduse character device, or another system. The question is: what to do if the VDUSE device does not process that command in a timely manner? Should we just let the RTNL be taken forever?
My understanding is that:
1. Virtio-net sends a control messages, waits for reply
2. VDUSE driver dequeues it, adds it to the SCVQ, replies OK to the CVQ
3. Userspace application dequeues the message from the SCVQ a. If handling is successful it replies OK
b. If handling fails, replies ERROR
4. VDUSE driver reads the reply
a. if OK, do nothing
b. if ERROR, mark the device as broken?Quoted 5 lines
This is simplified as it does not take into account SCVQ overflow if the application is stuck.
If IIUC, Michael suggests to only enqueue a single message at the time in the SVQ,
and bufferize the pending messages in the VDUSE driver.
Quoted 3 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
The downside of such optimization is that it requires the VDUSE Kernel driver to be able to handle all the message types.
So every time we add support for a new control message type, we'll also have to patch VDUSE Kernel driver.
I am not sure the gain is worth the effort as the traffic on the control queue is
usually rather low?
Maxime
Quoted 4 lines
--
MST
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
In reply to Michael S. TsirkinQuoted 79 lines · Michael S. Tsirkin
Quoted 77 lines · Maxime Coquelin
Quoted 74 lines · Eugenio Perez Martin
Quoted 50 lines · Michael S. Tsirkin
Quoted 48 lines · Eugenio Perez Martin
Quoted 46 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 7 lines
Quoted 2 lines
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Let me take a step back, I think I didn't describe the scenario well enough.
We have a VDUSE device, and then the same host is interacting with the device through the
virtio_netdriver overvirtio_vdpa.Then, the
virtio_netdriver sends a control command though its CVQ, so it *takes the RTNL*. That command reaches the VDUSE CVQ.It does not matter if the VDUSE device in the userland processes the commands through a CVQ, reading the vduse character device, or another system. The question is: what to do if the VDUSE device does not process that command in a timely manner? Should we just let the RTNL be taken forever?
Quoted 6 lines
Quoted 6 lines
My understanding is that:
1. Virtio-net sends a control messages, waits for reply
2. VDUSE driver dequeues it, adds it to the SCVQ, replies OK to the CVQ
3. Userspace application dequeues the message from the SCVQ a. If handling is successful it replies OK
b. If handling fails, replies ERROR
If that's the case, everything would be ok now. In both cases, the RTNL is held only by that time. The problem is when the VDUSE device userland does not reply.
Quoted 9 lines
Quoted 9 lines
4. VDUSE driver reads the reply
a. if OK, do nothing
b. if ERROR, mark the device as broken?This is simplified as it does not take into account SCVQ overflow if the application is stuck.
If IIUC, Michael suggests to only enqueue a single message at the time in the SVQ,
and bufferize the pending messages in the VDUSE driver.
But the RTNL keeps being held in all that process, isn't it?
Quoted 5 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
I still don't follow how that unlocks the RTNL. Let me put some workflows:
1) MAC_TABLE_SET, what can we do if:
The driver sets a set of MAC addresses, (A, B, C). VDUSE device does send this set to the VDUSE userland device, as we don't have more information. Now, the driver sends a new table with addresses (A, B, D), but the device still didn't reply to the VDUSE driver.
VDUSE should track that the new state is (A, B, D), and then wait for the previous request to be replied by the device? What should we report to the driver? If we wait for the device to reply, we're in the same situation regarding the RTNL.
Now we receive a new state (A, B, E). We haven't sent the (A, B, D), so it is good to just replace the (A, B, D) with that. and send it when (A, B, C) is completed with either success or failure.
2) VQ_PAIRS_SET
The driver starts with 1 vq pair. Now the driver sets 3 vq pairs, and the VDUSE CVQ forwards the command. The driver still thinks that it is using 1 vq pair. I can store that the driver request was 3, and it is still in-flight. Now the timeout occurs, so the VDUSE device returns fail to the driver, and the driver frees the vq regions etc. After that, the device now replies OK. The memory that was sent as the new vqs avail ring and descriptor ring now contains garbage, and it could happen that the device start overriding unrelated memory.
Not even VQ_RESET protects against it as there is still a window between the CMD set and the VQ reset.
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 96 lines · Eugenio Perez Martin
Quoted 79 lines · Michael S. Tsirkin
Quoted 77 lines · Maxime Coquelin
Quoted 74 lines · Eugenio Perez Martin
Quoted 50 lines · Michael S. Tsirkin
Quoted 48 lines · Eugenio Perez Martin
Quoted 46 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 7 lines
Quoted 2 lines
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Let me take a step back, I think I didn't describe the scenario well enough.
We have a VDUSE device, and then the same host is interacting with the device through the
virtio_netdriver overvirtio_vdpa.Then, the
virtio_netdriver sends a control command though its CVQ, so it *takes the RTNL*. That command reaches the VDUSE CVQ.It does not matter if the VDUSE device in the userland processes the commands through a CVQ, reading the vduse character device, or another system. The question is: what to do if the VDUSE device does not process that command in a timely manner? Should we just let the RTNL be taken forever?
Quoted 6 lines
Quoted 6 lines
My understanding is that:
1. Virtio-net sends a control messages, waits for reply
2. VDUSE driver dequeues it, adds it to the SCVQ, replies OK to the CVQ
3. Userspace application dequeues the message from the SCVQ a. If handling is successful it replies OK
b. If handling fails, replies ERRORIf that's the case, everything would be ok now. In both cases, the RTNL is held only by that time. The problem is when the VDUSE device userland does not reply.
Quoted 4 lines
Quoted 4 lines
4. VDUSE driver reads the reply
a. if OK, do nothing
b. if ERROR, mark the device as broken?
Quoted 12 lines
Quoted 5 lines
Quoted 5 lines
This is simplified as it does not take into account SCVQ overflow if the application is stuck.
If IIUC, Michael suggests to only enqueue a single message at the time in the SVQ,
and bufferize the pending messages in the VDUSE driver.But the RTNL keeps being held in all that process, isn't it?
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 30 lines
Quoted 1 line
I still don't follow how that unlocks the RTNL. Let me put some workflows:
1)
MAC_TABLE_SET, what can we do if:
The driver sets a set of MAC addresses, (A, B, C). VDUSE device does send this set to the VDUSE userland device, as we don't have more information. Now, the driver sends a new table with addresses (A, B, D), but the device still didn't reply to the VDUSE driver.VDUSE should track that the new state is (A, B, D), and then wait for the previous request to be replied by the device? What should we report to the driver? If we wait for the device to reply, we're in the same situation regarding the RTNL.
Now we receive a new state (A, B, E). We haven't sent the (A, B, D), so it is good to just replace the (A, B, D) with that. and send it when (A, B, C) is completed with either success or failure.
2)
VQ_PAIRS_SETThe driver starts with 1 vq pair. Now the driver sets 3 vq pairs, and the VDUSE CVQ forwards the command. The driver still thinks that it is using 1 vq pair. I can store that the driver request was 3, and it is still in-flight. Now the timeout occurs, so the VDUSE device returns fail to the driver, and the driver frees the vq regions etc. After that, the device now replies OK. The memory that was sent as the new vqs avail ring and descriptor ring now contains garbage, and it could happen that the device start overriding unrelated memory.
Quoted 2 lines
Not even
VQ_RESETprotects against it as there is still a window between the CMD set and the VQ reset.
Yes, I think it would be fine if the command is the best effort that means the state in kernel VDUSE could be out of sync with userspace. But it would be problematic if the command is not the best effort. And implementing cvq means a device model is implemented in the kernel VDUSE which might be a burden. Hardening the cvq might still be a good idea to go e.g
1) the device might be backed by software that is running in DPU
2) in kernel emulation of cvq might be buggy (e.g mlx5_vdpa and simulator)
Thanks
Quoted 1 line
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Signature · 1 line
MST
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Quoted 7 lines
Quoted 4 lines
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here. Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise NEEDS_RESET since it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.
Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Thanks
Quoted 4 lines
--
MST
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 13 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 5 lines
Quoted 2 lines
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here.
we do not need a timeout.
Quoted 6 lines
Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise
NEEDS_RESETsince it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.
Quoted 7 lines
Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Thanks
userspace should manage its own timeouts.
Quoted 4 lines
Quoted 4 lines
--
MST
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 33 lines · Michael S. Tsirkin
Quoted 13 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 5 lines
Quoted 2 lines
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here.
we do not need a timeout.
Quoted 10 lines
Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise
NEEDS_RESETsince it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Quoted 7 lines
Quoted 3 lines
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Thanks
userspace should manage its own timeouts.
Can we just apply the patch 2/2 of this RFC directly and apply the VDUSE CVQ on top then? What are we missing to do it?
Quoted 45 lines · Michael S. Tsirkin
Quoted 13 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 5 lines
Quoted 2 lines
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here.
we do not need a timeout.
Quoted 6 lines
Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise
NEEDS_RESETsince it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.Quoted 7 lines
Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Thanks
userspace should manage its own timeouts.
Quoted 4 lines
Quoted 4 lines
--
MST
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 37 lines · Eugenio Perez Martin
Quoted 35 lines · Michael S. Tsirkin
Quoted 13 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 5 lines
Quoted 2 lines
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here.
we do not need a timeout.
Quoted 12 lines
Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise
NEEDS_RESETsince it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Thanks
userspace should manage its own timeouts.
Can we just apply the patch 2/2 of this RFC directly and apply the VDUSE CVQ on top then? What are we missing to do it?
Even better, can we just revert commit 56e71885b0349 ("vduse:
Temporarily fail if control queue feature requested") ?
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 45 lines · Eugenio Perez Martin
Quoted 43 lines · Eugenio Perez Martin
Quoted 40 lines · Michael S. Tsirkin
Quoted 13 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 5 lines
Quoted 2 lines
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here.
we do not need a timeout.
Quoted 6 lines
Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise
NEEDS_RESETsince it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.Quoted 7 lines
Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Thanks
userspace should manage its own timeouts.
Quoted 6 lines
Quoted 3 lines
Can we just apply the patch 2/2 of this RFC directly and apply the VDUSE CVQ on top then? What are we missing to do it?
Even better, can we just revert commit
56e71885b0349("vduse:
Temporarily fail if control queue feature requested") ?
No because both would let userspace hang kernels merely by not consuming buffers.
Signature · 1 line
MST
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 51 lines · Michael S. Tsirkin
Quoted 49 lines · Eugenio Perez Martin
Quoted 46 lines · Eugenio Perez Martin
Quoted 33 lines · Michael S. Tsirkin
Quoted 13 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 5 lines
Quoted 2 lines
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here.
we do not need a timeout.
Quoted 10 lines
Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise
NEEDS_RESETsince it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Quoted 7 lines
Quoted 3 lines
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Thanks
userspace should manage its own timeouts.
Can we just apply the patch 2/2 of this RFC directly and apply the VDUSE CVQ on top then? What are we missing to do it?
Quoted 6 lines
Quoted 2 lines
Even better, can we just revert commit
56e71885b0349("vduse:
Temporarily fail if control queue feature requested") ?No because both would let userspace hang kernels merely by not consuming buffers.
My understanding was that you want to be able to debug qemu with gdb from that hang [1].
Could you put an example of the whole chain of events you expect? From the moment the driver sends a VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command, the VDUSE CVQ Forwards the command to the VDUSE device in the userspace, and then the vduse userland device does not reply.
How does the VDUSE CVQ detect that the VDUSE device implemented in userland does not reply? What are the next steps from that point of the kernel VDUSE module?
Thanks!
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 68 lines · Eugenio Perez Martin
Quoted 51 lines · Michael S. Tsirkin
Quoted 49 lines · Eugenio Perez Martin
Quoted 46 lines · Eugenio Perez Martin
Quoted 33 lines · Michael S. Tsirkin
Quoted 13 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 5 lines
Quoted 2 lines
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here.
we do not need a timeout.
Quoted 10 lines
Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise
NEEDS_RESETsince it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Quoted 7 lines
Quoted 3 lines
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Thanks
userspace should manage its own timeouts.
Can we just apply the patch 2/2 of this RFC directly and apply the VDUSE CVQ on top then? What are we missing to do it?
Quoted 6 lines
Quoted 2 lines
Even better, can we just revert commit
56e71885b0349("vduse:
Temporarily fail if control queue feature requested") ?No because both would let userspace hang kernels merely by not consuming buffers.
My understanding was that you want to be able to debug qemu with gdb from that hang [1].
Could you put an example of the whole chain of events you expect? From the moment the driver sends a
VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand, the VDUSE CVQ Forwards the command to the VDUSE device in the userspace, and then the vduse userland device does not reply.
Quoted 6 lines
How does the VDUSE CVQ detect that the VDUSE device implemented in userland does not reply? What are the next steps from that point of the kernel VDUSE module?
Thanks!
Friendly ping!
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
In reply to Eugenio Perez MartinQuoted 59 lines · Eugenio Perez Martin
Quoted 51 lines · Michael S. Tsirkin
Quoted 49 lines · Eugenio Perez Martin
Quoted 46 lines · Eugenio Perez Martin
Quoted 33 lines · Michael S. Tsirkin
Quoted 13 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 9 lines · Jason Wang
Quoted 4 lines
Quoted 4 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
Note that there's a case that multiple commands need to be sent, e.g set rx mode. And assuming not all the commands are the best effort, kernel VDUSE still needs to wait for the usersapce at least for a while.
Quoted 5 lines
Quoted 2 lines
Not wait, record. Generate 1st command, after userspace consumed it - generate and send second command and so on.
Right, that's what I asked in another thread, we still need a timeout here.
we do not need a timeout.
Quoted 10 lines
Then I think it would not be too much difference whether it is VDUSE or CVQ that will fail or break the device. Conceptually, VDUSE can only advertise
NEEDS_RESETsince it's a device implementation. VDUSE can not simply break the device as it requires synchronization which is not easy.Quoted 3 lines
But for each bit of data, at most one command has to be sent, we do not care if guest tweaked rx mode 3 times, we only care about the latest state.
Quoted 7 lines
Quoted 3 lines
Yes, but I want to know what's best when VDUSE meets userspace timeout.
Thanks
userspace should manage its own timeouts.
Can we just apply the patch 2/2 of this RFC directly and apply the VDUSE CVQ on top then? What are we missing to do it?
Quoted 6 lines
Quoted 2 lines
Even better, can we just revert commit
56e71885b0349("vduse:
Temporarily fail if control queue feature requested") ?No because both would let userspace hang kernels merely by not consuming buffers.
Quoted 7 lines
My understanding was that you want to be able to debug qemu with gdb from that hang [1].
Could you put an example of the whole chain of events you expect? From the moment the driver sends a
VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand, the VDUSE CVQ Forwards the command to the VDUSE device in the userspace, and then the vduse userland device does not reply.
this is not the idea.
the idea is that kernel handles VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET.
separately it notifies userspace that some configuration changed and userspace gets the new value.
Or not, if it is stuck.
Quoted 7 lines
How does the VDUSE CVQ detect that the VDUSE device implemented in userland does not reply? What are the next steps from that point of the kernel VDUSE module?
Thanks!
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
In reply to Eugenio Perez MartinQuoted 117 lines · Eugenio Perez Martin
Quoted 79 lines · Michael S. Tsirkin
Quoted 77 lines · Maxime Coquelin
Quoted 74 lines · Eugenio Perez Martin
Quoted 50 lines · Michael S. Tsirkin
Quoted 48 lines · Eugenio Perez Martin
Quoted 46 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if the virtio-net driver is running on top of
virtio_vdpa. Let's break the device if it does not return the buffer in a longer-than-assumible timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 7 lines
Quoted 2 lines
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Let me take a step back, I think I didn't describe the scenario well enough.
We have a VDUSE device, and then the same host is interacting with the device through the
virtio_netdriver overvirtio_vdpa.Then, the
virtio_netdriver sends a control command though its CVQ, so it *takes the RTNL*. That command reaches the VDUSE CVQ.It does not matter if the VDUSE device in the userland processes the commands through a CVQ, reading the vduse character device, or another system. The question is: what to do if the VDUSE device does not process that command in a timely manner? Should we just let the RTNL be taken forever?
Quoted 6 lines
Quoted 6 lines
My understanding is that:
1. Virtio-net sends a control messages, waits for reply
2. VDUSE driver dequeues it, adds it to the SCVQ, replies OK to the CVQ
3. Userspace application dequeues the message from the SCVQ a. If handling is successful it replies OK
b. If handling fails, replies ERRORIf that's the case, everything would be ok now. In both cases, the RTNL is held only by that time. The problem is when the VDUSE device userland does not reply.
Quoted 9 lines
Quoted 9 lines
4. VDUSE driver reads the reply
a. if OK, do nothing
b. if ERROR, mark the device as broken?This is simplified as it does not take into account SCVQ overflow if the application is stuck.
If IIUC, Michael suggests to only enqueue a single message at the time in the SVQ,
and bufferize the pending messages in the VDUSE driver.But the RTNL keeps being held in all that process, isn't it?
Quoted 5 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
I still don't follow how that unlocks the RTNL. Let me put some workflows:
1)
MAC_TABLE_SET, what can we do if:
The driver sets a set of MAC addresses, (A, B, C). VDUSE device does send this set to the VDUSE userland device, as we don't have more information. Now, the driver sends a new table with addresses (A, B, D), but the device still didn't reply to the VDUSE driver.
Quoted 3 lines
VDUSE should track that the new state is (A, B, D), and then wait for the previous request to be replied by the device? What should we report to the driver?
you reply OK to the driver immediately.
Quoted 18 lines
If we wait for the device to reply, we're in the
same situation regarding the RTNL.Now we receive a new state (A, B, E). We haven't sent the (A, B, D), so it is good to just replace the (A, B, D) with that. and send it when (A, B, C) is completed with either success or failure.
2)
VQ_PAIRS_SETThe driver starts with 1 vq pair. Now the driver sets 3 vq pairs, and the VDUSE CVQ forwards the command. The driver still thinks that it is using 1 vq pair. I can store that the driver request was 3, and it is still in-flight. Now the timeout occurs, so the VDUSE device returns fail to the driver, and the driver frees the vq regions etc. After that, the device now replies OK. The memory that was sent as the new vqs avail ring and descriptor ring now contains garbage, and it could happen that the device start overriding unrelated memory.
Quoted 2 lines
Not even
VQ_RESETprotects against it as there is still a window between the CMD set and the VQ reset.
Timeouts should be up to userspace. If userspace times out and then gets confused, kernel is not to blame.
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 119 lines · Michael S. Tsirkin
Quoted 117 lines · Eugenio Perez Martin
Quoted 79 lines · Michael S. Tsirkin
Quoted 77 lines · Maxime Coquelin
Quoted 74 lines · Eugenio Perez Martin
Quoted 50 lines · Michael S. Tsirkin
Quoted 48 lines · Eugenio Perez Martin
Quoted 46 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 24 lines · Michael S. Tsirkin
Quoted 22 lines · Maxime Coquelin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Eugenio Pérez
An userland device implemented through VDUSE could take rtnl forever if
the virtio-net driver is running on top of virtio_vdpa. Let's break the
device if it does not return the buffer in a longer-than-assumible
timeout.Quoted 6 lines
So now I can't debug qemu with gdb because guest dies :( Let's not break valid use-cases please.
Instead, solve it in vduse, probably by handling cvq within kernel.
Would a shadow control virtqueue implementation in the VDUSE driver work? It would ack systematically messages sent by the Virtio-net driver, and so assume the userspace application will Ack them.
When the userspace application handles the message, if the handling fails, it somehow marks the device as broken?
Quoted 9 lines
Quoted 2 lines
Thanks,
MaximeYes but it's a bit more convoluted than just acking them. Once you use the buffer you can get another one and so on with no limit.
One fix is to actually maintain device state in the kernel, update it, and then notify userspace.Quoted 6 lines
I thought of implementing this approach at first, but it has two drawbacks.
The first one: it's racy. Let's say the driver updates the MAC filter, VDUSE timeout occurs, the guest receives the fail, and then the device replies with an OK. There is no way for the device or VDUSE to update the driver.
There's no timeout. Kernel can guarantee executing all requests.
Quoted 7 lines
Quoted 2 lines
I don't follow this. How should the VDUSE kernel module act if the VDUSE userland device does not use the CVQ buffer then?
First I am not sure a VQ is the best interface for talking to userspace. But assuming yes - just avoid sending more data, send it later after userspace used the buffer.
Let me take a step back, I think I didn't describe the scenario well enough.
We have a VDUSE device, and then the same host is interacting with the device through the
virtio_netdriver overvirtio_vdpa.Then, the
virtio_netdriver sends a control command though its CVQ, so it *takes the RTNL*. That command reaches the VDUSE CVQ.It does not matter if the VDUSE device in the userland processes the commands through a CVQ, reading the vduse character device, or another system. The question is: what to do if the VDUSE device does not process that command in a timely manner? Should we just let the RTNL be taken forever?
Quoted 6 lines
Quoted 6 lines
My understanding is that:
1. Virtio-net sends a control messages, waits for reply
2. VDUSE driver dequeues it, adds it to the SCVQ, replies OK to the CVQ
3. Userspace application dequeues the message from the SCVQ a. If handling is successful it replies OK
b. If handling fails, replies ERRORIf that's the case, everything would be ok now. In both cases, the RTNL is held only by that time. The problem is when the VDUSE device userland does not reply.
Quoted 9 lines
Quoted 9 lines
4. VDUSE driver reads the reply
a. if OK, do nothing
b. if ERROR, mark the device as broken?This is simplified as it does not take into account SCVQ overflow if the application is stuck.
If IIUC, Michael suggests to only enqueue a single message at the time in the SVQ,
and bufferize the pending messages in the VDUSE driver.But the RTNL keeps being held in all that process, isn't it?
Quoted 5 lines
Not exactly bufferize, record. E.g. we do not need to send 100 messages to enable/disable promisc mode - together they have no effect.
I still don't follow how that unlocks the RTNL. Let me put some workflows:
1)
MAC_TABLE_SET, what can we do if:
The driver sets a set of MAC addresses, (A, B, C). VDUSE device does send this set to the VDUSE userland device, as we don't have more information. Now, the driver sends a new table with addresses (A, B, D), but the device still didn't reply to the VDUSE driver.
Quoted 6 lines
Quoted 3 lines
VDUSE should track that the new state is (A, B, D), and then wait for the previous request to be replied by the device? What should we report to the driver?
you reply OK to the driver immediately.
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sends MQ_VQ_PAIRS_SET 2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sends MQ_VQ_PAIRS_SET 1
e) VDUSE CVQ sends ok to the virtio-net driver
The device didn't process the MQ_VQ_PAIRS_SET 1 command at this point, so it potentially uses the second rx queue. But, by the standard:
The device MUST NOT queue packets on receive queues greater than virtqueue_pairs once it has placed the VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command in a used buffer.
So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
And, what's worse, how to handle it if the device now replies with VIRTIO_NET_ERR to the VDUSE CVQ?
Quoted 18 lines
Quoted 18 lines
If we wait for the device to reply, we're in the
same situation regarding the RTNL.Now we receive a new state (A, B, E). We haven't sent the (A, B, D), so it is good to just replace the (A, B, D) with that. and send it when (A, B, C) is completed with either success or failure.
2)
VQ_PAIRS_SETThe driver starts with 1 vq pair. Now the driver sets 3 vq pairs, and the VDUSE CVQ forwards the command. The driver still thinks that it is using 1 vq pair. I can store that the driver request was 3, and it is still in-flight. Now the timeout occurs, so the VDUSE device returns fail to the driver, and the driver frees the vq regions etc. After that, the device now replies OK. The memory that was sent as the new vqs avail ring and descriptor ring now contains garbage, and it could happen that the device start overriding unrelated memory.
Quoted 7 lines
Quoted 2 lines
Not even
VQ_RESETprotects against it as there is still a window between the CMD set and the VQ reset.Timeouts should be up to userspace. If userspace times out and then gets confused, kernel is not to blame.
I meant the virtio-net driver will be confused.
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:
Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 2 lines
And, what's worse, how to handle it if the device now replies with
VIRTIO_NET_ERRto the VDUSE CVQ?
this part does not bother me much. break it, probably.
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
If we wait for the device to reply, we're in the
same situation regarding the RTNL.Now we receive a new state (A, B, E). We haven't sent the (A, B, D), so it is good to just replace the (A, B, D) with that. and send it when (A, B, C) is completed with either success or failure.
2)
VQ_PAIRS_SETThe driver starts with 1 vq pair. Now the driver sets 3 vq pairs, and the VDUSE CVQ forwards the command. The driver still thinks that it is using 1 vq pair. I can store that the driver request was 3, and it is still in-flight. Now the timeout occurs, so the VDUSE device returns fail to the driver, and the driver frees the vq regions etc. After that, the device now replies OK. The memory that was sent as the new vqs avail ring and descriptor ring now contains garbage, and it could happen that the device start overriding unrelated memory.
Quoted 7 lines
Quoted 2 lines
Not even
VQ_RESETprotects against it as there is still a window between the CMD set and the VQ reset.Timeouts should be up to userspace. If userspace times out and then gets confused, kernel is not to blame.
I meant the virtio-net driver will be confused.
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 18 lines · Michael S. Tsirkin
Quoted 16 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.
Quoted 8 lines
Quoted 3 lines
So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Sure.
Quoted 6 lines
Quoted 3 lines
And, what's worse, how to handle it if the device now replies with
VIRTIO_NET_ERRto the VDUSE CVQ?this part does not bother me much. break it, probably.
To "successfully break it" we should implement NEED_RESET, or would it work to just stop forwarding messages?
Quoted 28 lines
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
If we wait for the device to reply, we're in the
same situation regarding the RTNL.Now we receive a new state (A, B, E). We haven't sent the (A, B, D), so it is good to just replace the (A, B, D) with that. and send it when (A, B, C) is completed with either success or failure.
2)
VQ_PAIRS_SETThe driver starts with 1 vq pair. Now the driver sets 3 vq pairs, and the VDUSE CVQ forwards the command. The driver still thinks that it is using 1 vq pair. I can store that the driver request was 3, and it is still in-flight. Now the timeout occurs, so the VDUSE device returns fail to the driver, and the driver frees the vq regions etc. After that, the device now replies OK. The memory that was sent as the new vqs avail ring and descriptor ring now contains garbage, and it could happen that the device start overriding unrelated memory.
Quoted 7 lines
Quoted 2 lines
Not even
VQ_RESETprotects against it as there is still a window between the CMD set and the VQ reset.Timeouts should be up to userspace. If userspace times out and then gets confused, kernel is not to blame.
I meant the virtio-net driver will be confused.
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 23 lines · Eugenio Perez Martin
Quoted 22 lines · Michael S. Tsirkin
Quoted 19 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
Quoted 6 lines
Quoted 4 lines
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Signature · 1 line
MST
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually. For example, unbinding and binding the driver in Linux. The point is that the driver cannot trust the device anymore as it is in an invalid state. Maybe suspend and reset all the vqs is also a valid solution to un-broke it if the device supports it but I think a race is unavoidable there, and I'm not sure how to communicate it to userspace for all kinds of devices. Incrementing rx errors could be a first proposal.
If we want to track it in VDUSE we should implement NEEDS_RESET and leave all the old drivers without solution. That's why I think it is better to solve all the problems at once in the driver.
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 31 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.
Quoted 11 lines
For example, unbinding and binding the driver in Linux. The point is that the driver cannot trust the device anymore as it is in an invalid state. Maybe suspend and reset all the vqs is also a valid solution to un-broke it if the device supports it but I think a race is unavoidable there, and I'm not sure how to communicate it to userspace for all kinds of devices. Incrementing rx errors could be a first proposal.
If we want to track it in VDUSE we should implement
NEEDS_RESETand leave all the old drivers without solution. That's why I think it is better to solve all the problems at once in the driver.
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 39 lines · Michael S. Tsirkin
Quoted 37 lines · Eugenio Perez Martin
Quoted 35 lines · Michael S. Tsirkin
Quoted 23 lines · Eugenio Perez Martin
Quoted 22 lines · Michael S. Tsirkin
Quoted 19 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
Quoted 6 lines
Quoted 4 lines
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Quoted 8 lines
Quoted 2 lines
Well my proposal is to mark it as broken so it needs to be reset manually.
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.
I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
Re: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 45 lines · Eugenio Perez Martin
Quoted 43 lines · Michael S. Tsirkin
Quoted 39 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Quoted 9 lines
Quoted 4 lines
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
At least for this case virtio-vDPA + VDUSE, there's no way for the userspace to poke after reset since everything is done via IOTLB.
For other devices, if we want this extra safety, we need to enable swiotlb.
Thanks
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
In reply to Eugenio Perez MartinQuoted 45 lines · Eugenio Perez Martin
Quoted 43 lines · Michael S. Tsirkin
Quoted 39 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Quoted 8 lines
Quoted 4 lines
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
Friendly ping.
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 52 lines · Eugenio Perez Martin
Quoted 50 lines · Eugenio Perez Martin
Quoted 47 lines · Michael S. Tsirkin
Quoted 31 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.
Quoted 5 lines
Quoted 3 lines
I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
Friendly ping.
OK I thought about it a bunch. A lot of net drivers actually just queue ethtool commands and finish them asynchronously. Thinkably virtio could expose an API on whether it is safe to wait for buffers to be used. virtio-net would then either send commands directly or do the asynchronous thing. Hmm?
Signature · 1 line
MST
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 62 lines · Michael S. Tsirkin
Quoted 52 lines · Eugenio Perez Martin
Quoted 50 lines · Eugenio Perez Martin
Quoted 47 lines · Michael S. Tsirkin
Quoted 31 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.Quoted 5 lines
Quoted 3 lines
I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
Friendly ping.
Quoted 7 lines
OK I thought about it a bunch. A lot of net drivers actually just queue ethtool commands and finish them asynchronously. Thinkably virtio could expose an API on whether it is safe to wait for buffers to be used. virtio-net would then either send commands directly or do the asynchronous thing. Hmm?
I think it's the best solution too, yes. The series [1] implements for set_rx_mode. We can do it for all the CVQ commands and then whitelist them in VDUSE code. Am I missing something? Does anyone foresee any command that will not be possible to convert?
Thanks!
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 72 lines · Eugenio Perez Martin
Quoted 62 lines · Michael S. Tsirkin
Quoted 52 lines · Eugenio Perez Martin
Quoted 50 lines · Eugenio Perez Martin
Quoted 47 lines · Michael S. Tsirkin
Quoted 31 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.Quoted 5 lines
Quoted 3 lines
I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
Friendly ping.
Quoted 7 lines
OK I thought about it a bunch. A lot of net drivers actually just queue ethtool commands and finish them asynchronously. Thinkably virtio could expose an API on whether it is safe to wait for buffers to be used. virtio-net would then either send commands directly or do the asynchronous thing. Hmm?
Quoted 5 lines
I think it's the best solution too, yes. The series [1] implements for
set_rx_mode. We can do it for all the CVQ commands and then whitelist them in VDUSE code. Am I missing something? Does anyone foresee any command that will not be possible to convert?
Adding the [1] link...
Michael S. Tsirkin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 80 lines · Eugenio Perez Martin
Quoted 72 lines · Eugenio Perez Martin
Quoted 62 lines · Michael S. Tsirkin
Quoted 52 lines · Eugenio Perez Martin
Quoted 50 lines · Eugenio Perez Martin
Quoted 47 lines · Michael S. Tsirkin
Quoted 31 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.Quoted 5 lines
Quoted 3 lines
I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
Friendly ping.
Quoted 7 lines
OK I thought about it a bunch. A lot of net drivers actually just queue ethtool commands and finish them asynchronously. Thinkably virtio could expose an API on whether it is safe to wait for buffers to be used. virtio-net would then either send commands directly or do the asynchronous thing. Hmm?
Quoted 5 lines
I think it's the best solution too, yes. The series [1] implements for
set_rx_mode. We can do it for all the CVQ commands and then whitelist them in VDUSE code. Am I missing something? Does anyone foresee any command that will not be possible to convert?
Quoted 3 lines
Adding the [1] link...
what's the status of that one?
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 82 lines · Michael S. Tsirkin
Quoted 80 lines · Eugenio Perez Martin
Quoted 77 lines · Eugenio Perez Martin
Quoted 62 lines · Michael S. Tsirkin
Quoted 52 lines · Eugenio Perez Martin
Quoted 50 lines · Eugenio Perez Martin
Quoted 47 lines · Michael S. Tsirkin
Quoted 31 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 12 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sendsMQ_VQ_PAIRS_SET2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sendsMQ_VQ_PAIRS_SET1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the
MQ_VQ_PAIRS_SET1 command at this point, so it potentially uses the second rx queue. But, by the standard:Quoted 7 lines
The device MUST NOT queue packets on receive queues greater than
virtqueue_pairsonce it has placed theVIRTIO_NET_CTRL_MQ_VQ_PAIRS_SETcommand in a used buffer.So the driver does not expect rx buffers on that queue at all. From the driver's POV, the device is invalid, and it could mark it as broken.
ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.Quoted 5 lines
Quoted 3 lines
I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
Friendly ping.
Quoted 7 lines
OK I thought about it a bunch. A lot of net drivers actually just queue ethtool commands and finish them asynchronously. Thinkably virtio could expose an API on whether it is safe to wait for buffers to be used. virtio-net would then either send commands directly or do the asynchronous thing. Hmm?
I think it's the best solution too, yes. The series [1] implements for
set_rx_mode. We can do it for all the CVQ commands and then whitelist them in VDUSE code. Am I missing something? Does anyone foresee any command that will not be possible to convert?
Quoted 6 lines
Quoted 3 lines
Adding the [1] link...
what's the status of that one?
Still under review.
Aleksandr Loktionov <[email protected]> added the Reviewed-by tag to most of patches but he spotted a sync issue in the realtek 8139cp driver.
Eugenio Perez Martin
maintainerRe: [RFC 1/2] virtio_net: timeout control virtqueue commands
Quoted 91 lines · Eugenio Perez Martin
Quoted 82 lines · Michael S. Tsirkin
Quoted 80 lines · Eugenio Perez Martin
Quoted 77 lines · Eugenio Perez Martin
Quoted 62 lines · Michael S. Tsirkin
Quoted 52 lines · Eugenio Perez Martin
Quoted 50 lines · Eugenio Perez Martin
Quoted 47 lines · Michael S. Tsirkin
Quoted 31 lines · Eugenio Perez Martin
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Eugenio Perez Martin
Quoted 26 lines · Michael S. Tsirkin
Quoted 19 lines · Eugenio Perez Martin
Let me switch to MQ as I think it illustrates the point better.
IIUC the workflow:
a) virtio-net sends MQ_VQ_PAIRS_SET 2 to the device
b) VDUSE CVQ sends ok to the virtio-net driver
c) VDUSE CVQ sends the command to the VDUSE device
d) Now the virtio-net driver sends virtio-net sends MQ_VQ_PAIRS_SET 1
e) VDUSE CVQ sends ok to the virtio-net driverThe device didn't process the MQ_VQ_PAIRS_SET 1 command at this point,
so it potentially uses the second rx queue. But, by the standard:The device MUST NOT queue packets on receive queues greater than
virtqueue_pairs once it has placed the VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
command in a used buffer.So the driver does not expect rx buffers on that queue at all. From
the driver's POV, the device is invalid, and it could mark it as
broken.ok intresting. Note that if userspace processes vqs it should process cvq too. I don't know what to do in this case yet, I'm going on vacation, let me ponder this a bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Sure.
So let me ask you this, how are you going to handle device reset? Same issue, it seems to me.
Well my proposal is to mark it as broken so it needs to be reset manually.
Heh but guest assumes after reset device does not poke at guest memory, and will free up and reuse that memory.
If userspace still pokes at it -> plus plus ungood.Quoted 5 lines
Quoted 3 lines
I don't get this part. Once the device is reset, the device should not poke at guest memory (unless it is malicious or similar). Why would it do it?
Friendly ping.
Quoted 7 lines
OK I thought about it a bunch. A lot of net drivers actually just queue ethtool commands and finish them asynchronously. Thinkably virtio could expose an API on whether it is safe to wait for buffers to be used. virtio-net would then either send commands directly or do the asynchronous thing. Hmm?
I think it's the best solution too, yes. The series [1] implements for
set_rx_mode. We can do it for all the CVQ commands and then whitelist them in VDUSE code. Am I missing something? Does anyone foresee any command that will not be possible to convert?Quoted 6 lines
Quoted 3 lines
Adding the [1] link...
what's the status of that one?
Quoted 7 lines
Still under review.
Aleksandr Loktionov <[email protected]> added the Reviewed-by tag to most of patches but he spotted a sync issue in the realtek 8139cp driver.
Ok, that one is merged now but it still does not solve the rtnl issue :(. It just moves the driver call to set rx mode to a place where it can sleep while holding the rtnl.
In the case of the mac address change it actually takes the lock way earlier, as soon as rtnl_newlink. I'm trying to remove the rtnl when the CVQ command is issued, but that complicates the scenario quickly. The plan is to get the callers of net/core/dev.c:netif_set_mac_address() not have the rtnl taken, only the device one. And then some polished version of this:
@@ -10223,16 +10223,21 @@ int netif_set_mac_address(struct net_device *dev, struct sockaddr_storage *ss,
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
+ rtnl_lock();
err = netif_pre_changeaddr_notify(dev, ss->__data, extack);
if (err)
return err;
if (memcmp(dev->dev_addr, ss->__data, dev->addr_len)) {
+ rtnl_unlock();
err = ops->ndo_set_mac_address(dev, ss);
if (err)
return err;
+ rtnl_lock();
}
dev->addr_assign_type = NET_ADDR_SET;
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
+ rtnl_unlock();
add_device_randomness(dev->dev_addr, dev->addr_len);
return 0;}
However syncrhronizing the NETDEV_PRE_CHANGEADDR notifications to the actual CVQ command seems hard, as new notifiers can be added in the middle. It checks if any listener objects to the MAC address change. As far as I can see, only Nvidia's spectrum driver can deny that MAC address change if there are too many MAC addresses, so maybe we can just adapt it, but I might be missing something [1].
If my guess is right, setting the MAc address out of rtnl and run the PRE_CHANGEADDR notifiers again with rtnl taken could be a step forward. If the notifiers fail (the Nvidia device denies the address change), we can trigger a rollback of the MAC address outside the rtnl.
Ccing netdev and Stanislav who added the set_rx_mode_async to check if this is the right direction or if there are efforts / attempt to make this happen.
Rx mode, the number of enabled virtqueues, etc., have similar problems, but maybe we can start with the MAC address.
[1]
$ git grep -n 'NETDEV_PRE_CHANGEADDR' drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9921: case NETDEV_PRE_CHANGEADDR: drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9949: case NETDEV_PRE_CHANGEADDR: drivers/net/ipvlan/ipvlan_main.c:867: case NETDEV_PRE_CHANGEADDR: include/linux/netdevice.h:3255: NETDEV_PRE_CHANGEADDR, /* notify before the address change */ net/bridge/br.c:76: case NETDEV_PRE_CHANGEADDR: net/core/dev.c:10192: * netif_pre_changeaddr_notify() - Call NETDEV_PRE_CHANGEADDR. net/core/dev.c:10209: rc = call_netdevice_notifiers_info(NETDEV_PRE_CHANGEADDR, &info.info); net/core/lock_debug.c:35: case NETDEV_PRE_CHANGEADDR:
$ git grep -n -A9 'case NETDEV_PRE_CHANGEADDR' net/bridge/br.c net/bridge/br.c:76: case NETDEV_PRE_CHANGEADDR: net/bridge/br.c:77: if (br->dev->addr_assign_type == NET_ADDR_SET) net/bridge/br.c:78: break; net/bridge/br.c:79: prechaddr_info = ptr; net/bridge/br.c:80: err = netif_pre_changeaddr_notify(br->dev, net/bridge/br.c:81: prechaddr_info->dev_addr, net/bridge/br.c:82: extack); net/bridge/br.c:83: if (err) net/bridge/br.c:84: return notifier_from_errno(err); net/bridge/br.c:85: break;
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9736:static int mlxsw_sp_router_port_pre_changeaddr_event(struct mlxsw_sp_rif *rif, drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9737:
struct netdev_notifier_pre_changeaddr_info *info)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9738:{ drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9739:
struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9740:
struct mlxsw_sp_rif_mac_profile *profile; drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9741:
struct netlink_ext_ack *extack;drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9742: u8max_rif_mac_profiles;drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9743: u64 occ;drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9744:drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9745:
extack = netdev_notifier_info_to_extack(&info->info); drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9746:drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9747:
profile = mlxsw_sp_rif_mac_profile_find(mlxsw_sp, info->dev_addr);drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9748: if (profile)drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9749:
return 0;
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9750:drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9751:max_rif_mac_profiles = mlxsw_sp->router->max_rif_mac_profile;drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9752: occ
= mlxsw_sp_rif_mac_profiles_occ_get(mlxsw_sp);drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9753: if
(occ < max_rif_mac_profiles) drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9754:
return 0;
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9755:drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9756: if
(!mlxsw_sp_rif_mac_profile_is_shared(rif)) drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9757:
return 0;
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9758:drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9759:
NL_SET_ERR_MSG_MOD(extack, "Exceeded number of supported router interface MA
C profiles"); drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9760:
return -ENOBUFS; drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:9761:}
Eugenio Pérez
maintainerRFC 2/2 vduse: lift restriction about net devices with CVQ
In reply to Eugenio PérezNow that the virtio_net driver is able to recover from a stall virtqueue, let's lift the restriction.
--- drivers/vdpa/vdpa_user/vduse_dev.c | 3 --- 1 file changed, 3 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +0 -3
@@ -1726,9 +1726,6 @@ static bool features_is_valid(struct vduse_dev_config *config)if ((config->device_id ==VIRTIO_ID_BLOCK ) && (config->features &BIT_ULL (VIRTIO_BLK_F_CONFIG_WCE )))return false; -else if ((config->device_id ==VIRTIO_ID_NET ) && - (config->features &BIT_ULL (VIRTIO_NET_F_CTRL_VQ ))) -return false;if ((config->device_id ==VIRTIO_ID_NET ) && !(config->features &BIT_ULL (VIRTIO_F_VERSION_1 )))
Signature · 1 line
2.51.0
Re: [RFC 2/2] vduse: lift restriction about net devices with CVQ
Quoted 13 lines · Eugenio Pérez
Now that the
virtio_netdriver is able to recover from a stall virtqueue, let's lift the restriction.Signed-off-by Eugenio Pérez <[email protected]>--- drivers/vdpa/vdpa_user/vduse_dev.c | 3 --- 1 file changed, 3 deletions(-)drivers/vdpa/vdpa_user/vduse_dev.c +0
-0
drivers/vdpa/vdpa_user/vduse_dev.c static bool features_is_valid(struct vduse_dev_config *config) · line 1731
Quoted 9 lines
drivers/vdpa/vdpa_user/vduse_dev.c +0
-3@@ -1726,9 +1726,6 @@ static bool features_is_valid(struct vduse_dev_config *config)if ((config->device_id ==VIRTIO_ID_BLOCK ) && (config->features &BIT_ULL (VIRTIO_BLK_F_CONFIG_WCE )))return false; -else if ((config->device_id ==VIRTIO_ID_NET ) && - (config->features &BIT_ULL (VIRTIO_NET_F_CTRL_VQ ))) -return false;if ((config->device_id ==VIRTIO_ID_NET ) && !(config->features &BIT_ULL (VIRTIO_F_VERSION_1 )))
I wonder whether the API version should be increased, otherwise I don't see how the app creating the VDUSE device knows whether it can safely advertises the CVQ support (except without doing trial and error).
Eugenio Perez Martin
maintainerRe: [RFC 2/2] vduse: lift restriction about net devices with CVQ
Quoted 24 lines · Maxime Coquelin
Quoted 20 lines · Eugenio Pérez
Now that the
virtio_netdriver is able to recover from a stall virtqueue, let's lift the restriction.Signed-off-by Eugenio Pérez <[email protected]>--- drivers/vdpa/vdpa_user/vduse_dev.c | 3 --- 1 file changed, 3 deletions(-)drivers/vdpa/vdpa_user/vduse_dev.c +0
-3@@ -1726,9 +1726,6 @@ static bool features_is_valid(struct vduse_dev_config *config)if ((config->device_id ==VIRTIO_ID_BLOCK ) && (config->features &BIT_ULL (VIRTIO_BLK_F_CONFIG_WCE )))return false; -else if ((config->device_id ==VIRTIO_ID_NET ) && - (config->features &BIT_ULL (VIRTIO_NET_F_CTRL_VQ ))) -return false;
Quoted 7 lines
drivers/vdpa/vdpa_user/vduse_dev.c static bool features_is_valid(struct vduse_dev_config *config) · line 1731
Quoted 2 lines
drivers/vdpa/vdpa_user/vduse_dev.c +0
-0if ((config->device_id ==VIRTIO_ID_NET ) && !(config->features &BIT_ULL (VIRTIO_F_VERSION_1 )))I wonder whether the API version should be increased, otherwise I don't see how the app creating the VDUSE device knows whether it can safely advertises the CVQ support (except without doing trial and error).
Ok good point! I'll do it in the next version.
Michael S. Tsirkin
maintainerRe: [RFC 2/2] vduse: lift restriction about net devices with CVQ
In reply to Eugenio PérezQuoted 2 lines · Eugenio Pérez
Now that the
virtio_netdriver is able to recover from a stall virtqueue,
it's not able to recover, is it?
Quoted 23 lines
let's lift the restriction.
Signed-off-by Eugenio Pérez <[email protected]>--- drivers/vdpa/vdpa_user/vduse_dev.c | 3 --- 1 file changed, 3 deletions(-)drivers/vdpa/vdpa_user/vduse_dev.c +0
-3@@ -1726,9 +1726,6 @@ static bool features_is_valid(struct vduse_dev_config *config)if ((config->device_id ==VIRTIO_ID_BLOCK ) && (config->features &BIT_ULL (VIRTIO_BLK_F_CONFIG_WCE )))return false; -else if ((config->device_id ==VIRTIO_ID_NET ) && - (config->features &BIT_ULL (VIRTIO_NET_F_CTRL_VQ ))) -return false;if ((config->device_id ==VIRTIO_ID_NET ) && !(config->features &BIT_ULL (VIRTIO_F_VERSION_1 )))Signature · 1 line
2.51.0
Eugenio Perez Martin
maintainerRe: [RFC 2/2] vduse: lift restriction about net devices with CVQ
Quoted 7 lines · Michael S. Tsirkin
Quoted 2 lines · Eugenio Pérez
Now that the
virtio_netdriver is able to recover from a stall virtqueue,it's not able to recover, is it?
Maybe recover is not the best word here :). s/recover from a stall virtqueue/unlock the RTNL from a stalled control virtqueue/.