Michael S. Tsirkin
2018-Apr-19 05:30 UTC
[PATCH v2 net 2/3] virtio_net: fix adding vids on big-endian
Programming vids (adding or removing them) still passes guest-endian values in the DMA buffer. That's wrong if guest is big-endian and when virtio 1 is enabled. Note: this is on top of a previous patch: virtio_net: split out ctrl buffer Fixes: 9465a7a6f ("virtio_net: enable v1.0 support") Signed-off-by: Michael S. Tsirkin <mst at redhat.com> --- drivers/net/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 3d0eff53..f84fe04 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -154,7 +154,7 @@ struct control_buf { struct virtio_net_ctrl_mq mq; u8 promisc; u8 allmulti; - u16 vid; + __virtio16 vid; u64 offloads; }; @@ -1718,7 +1718,7 @@ static int virtnet_vlan_rx_add_vid(struct net_device *dev, struct virtnet_info *vi = netdev_priv(dev); struct scatterlist sg; - vi->ctrl->vid = vid; + vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid); sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, @@ -1733,7 +1733,7 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev, struct virtnet_info *vi = netdev_priv(dev); struct scatterlist sg; - vi->ctrl->vid = vid; + vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid); sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid)); if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, -- MST
Jason Wang
2018-Apr-19 12:26 UTC
[PATCH v2 net 2/3] virtio_net: fix adding vids on big-endian
On 2018?04?19? 13:30, Michael S. Tsirkin wrote:> Programming vids (adding or removing them) still passes > guest-endian values in the DMA buffer. That's wrong > if guest is big-endian and when virtio 1 is enabled. > > Note: this is on top of a previous patch: > virtio_net: split out ctrl buffer > > Fixes: 9465a7a6f ("virtio_net: enable v1.0 support") > Signed-off-by: Michael S. Tsirkin <mst at redhat.com> > --- > drivers/net/virtio_net.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 3d0eff53..f84fe04 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -154,7 +154,7 @@ struct control_buf { > struct virtio_net_ctrl_mq mq; > u8 promisc; > u8 allmulti; > - u16 vid; > + __virtio16 vid; > u64 offloads; > }; > > @@ -1718,7 +1718,7 @@ static int virtnet_vlan_rx_add_vid(struct net_device *dev, > struct virtnet_info *vi = netdev_priv(dev); > struct scatterlist sg; > > - vi->ctrl->vid = vid; > + vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid); > sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid)); > > if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, > @@ -1733,7 +1733,7 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev, > struct virtnet_info *vi = netdev_priv(dev); > struct scatterlist sg; > > - vi->ctrl->vid = vid; > + vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid); > sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid)); > > if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,Acked-by: Jason Wang <jasowang at redhat.com>
Cornelia Huck
2018-Apr-19 13:26 UTC
[PATCH v2 net 2/3] virtio_net: fix adding vids on big-endian
On Thu, 19 Apr 2018 08:30:49 +0300 "Michael S. Tsirkin" <mst at redhat.com> wrote:> Programming vids (adding or removing them) still passes > guest-endian values in the DMA buffer. That's wrong > if guest is big-endian and when virtio 1 is enabled. > > Note: this is on top of a previous patch: > virtio_net: split out ctrl buffer > > Fixes: 9465a7a6f ("virtio_net: enable v1.0 support") > Signed-off-by: Michael S. Tsirkin <mst at redhat.com> > --- > drivers/net/virtio_net.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-)Ouch. Have you seen any bug reports for that?
Michael S. Tsirkin
2018-Apr-19 14:56 UTC
[PATCH v2 net 2/3] virtio_net: fix adding vids on big-endian
On Thu, Apr 19, 2018 at 03:26:41PM +0200, Cornelia Huck wrote:> On Thu, 19 Apr 2018 08:30:49 +0300 > "Michael S. Tsirkin" <mst at redhat.com> wrote: > > > Programming vids (adding or removing them) still passes > > guest-endian values in the DMA buffer. That's wrong > > if guest is big-endian and when virtio 1 is enabled. > > > > Note: this is on top of a previous patch: > > virtio_net: split out ctrl buffer > > > > Fixes: 9465a7a6f ("virtio_net: enable v1.0 support") > > Signed-off-by: Michael S. Tsirkin <mst at redhat.com> > > --- > > drivers/net/virtio_net.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > Ouch. Have you seen any bug reports for that?No, but then vlans within VMs aren't used too often (as opposed to attaching vlans by the HV). -- MST
Seemingly Similar Threads
- [PATCH v2 net 2/3] virtio_net: fix adding vids on big-endian
- [PATCH v2 net 2/3] virtio_net: fix adding vids on big-endian
- [PATCH RFC 07/11] virtio_net: use v1.0 endian.
- [PATCH RFC v2 10/16] virtio_net: use v1.0 endian.
- [PATCH RFC v3 10/16] virtio_net: use v1.0 endian.