[PATCH 1/1] vhost: fix a double fetch when dequeue offloading

Wangyunjian(wangyunjian,TongTu) wangyunjian at huawei.com
Fri Dec 20 03:17:12 CET 2024


> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Friday, December 20, 2024 12:16 AM
> To: Wangyunjian(wangyunjian,TongTu) <wangyunjian at huawei.com>
> Cc: dev at dpdk.org; maxime.coquelin at redhat.com; chenbox at nvidia.com;
> Lilijun (Jerry) <jerry.lilijun at huawei.com>; xiawei (H) <xiawei40 at huawei.com>;
> wangzengyuan <wangzengyuan at huawei.com>; stable at dpdk.org
> Subject: Re: [PATCH 1/1] vhost: fix a double fetch when dequeue offloading
> 
> On Thu, 19 Dec 2024 14:38:28 +0800
> Yunjian Wang <wangyunjian at huawei.com> wrote:
> 
> > -			hdr = (struct virtio_net_hdr *)((uintptr_t)buf_vec[0].buf_addr);
> > +			rte_memcpy((void *)(uintptr_t)&tmp_hdr,
> > +				(void *)(uintptr_t)buf_vec[0].buf_addr,
> > +				sizeof(struct virtio_net_hdr));
> >  		}
> 
> Do not introduce more rte_memcpy of a fixed size.
> You don't need that many casts!
> Why can you not use a structure assignment here.

 The virtio_hdr is a shared component, and other fields within it are read
multiple times. This can potentially result in a double fetch scenario.


More information about the stable mailing list