Skip to content

Commit a725ee3

Browse files
amlutodavem330
authored andcommitted
virtio-net: Remove more stack DMA
VLAN and MQ control was doing DMA from the stack. Fix it. Cc: Michael S. Tsirkin <[email protected]> Cc: "[email protected]" <[email protected]> Signed-off-by: Andy Lutomirski <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cbce91c commit a725ee3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/net/virtio_net.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ struct virtnet_info {
144144
/* Control VQ buffers: protected by the rtnl lock */
145145
struct virtio_net_ctrl_hdr ctrl_hdr;
146146
virtio_net_ctrl_ack ctrl_status;
147+
struct virtio_net_ctrl_mq ctrl_mq;
147148
u8 ctrl_promisc;
148149
u8 ctrl_allmulti;
150+
u16 ctrl_vid;
149151

150152
/* Ethtool settings */
151153
u8 duplex;
@@ -1058,14 +1060,13 @@ static void virtnet_ack_link_announce(struct virtnet_info *vi)
10581060
static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs)
10591061
{
10601062
struct scatterlist sg;
1061-
struct virtio_net_ctrl_mq s;
10621063
struct net_device *dev = vi->dev;
10631064

10641065
if (!vi->has_cvq || !virtio_has_feature(vi->vdev, VIRTIO_NET_F_MQ))
10651066
return 0;
10661067

1067-
s.virtqueue_pairs = cpu_to_virtio16(vi->vdev, queue_pairs);
1068-
sg_init_one(&sg, &s, sizeof(s));
1068+
vi->ctrl_mq.virtqueue_pairs = cpu_to_virtio16(vi->vdev, queue_pairs);
1069+
sg_init_one(&sg, &vi->ctrl_mq, sizeof(vi->ctrl_mq));
10691070

10701071
if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ,
10711072
VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET, &sg)) {
@@ -1172,7 +1173,8 @@ static int virtnet_vlan_rx_add_vid(struct net_device *dev,
11721173
struct virtnet_info *vi = netdev_priv(dev);
11731174
struct scatterlist sg;
11741175

1175-
sg_init_one(&sg, &vid, sizeof(vid));
1176+
vi->ctrl_vid = vid;
1177+
sg_init_one(&sg, &vi->ctrl_vid, sizeof(vi->ctrl_vid));
11761178

11771179
if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
11781180
VIRTIO_NET_CTRL_VLAN_ADD, &sg))
@@ -1186,7 +1188,8 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev,
11861188
struct virtnet_info *vi = netdev_priv(dev);
11871189
struct scatterlist sg;
11881190

1189-
sg_init_one(&sg, &vid, sizeof(vid));
1191+
vi->ctrl_vid = vid;
1192+
sg_init_one(&sg, &vi->ctrl_vid, sizeof(vi->ctrl_vid));
11901193

11911194
if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
11921195
VIRTIO_NET_CTRL_VLAN_DEL, &sg))

0 commit comments

Comments
 (0)