Re: [PATCH 1/1] hv: drivers: vmbus: Prevent load re-ordering when reading ring buffer

Wei Liu
2022-03-29T13:20:44Z

On Tue, Mar 29, 2022 at 01:12:33AM +0200, Andrea Parri wrote:
> On Sun, Mar 27, 2022 at 08:25:10AM -0700, Michael Kelley wrote:
> > When reading a packet from a host-to-guest ring buffer, there is no
> > memory barrier between reading the write index (to see if there is
> > a packet to read) and reading the contents of the packet. The Hyper-V
> > host uses store-release when updating the write index to ensure that
> > writes of the packet data are completed first. On the guest side,
> > the processor can reorder and read the packet data before the write
> > index, and sometimes get stale packet data. Getting such stale packet
> > data has been observed in a reproducible case in a VM on ARM64.
> >
> > Fix this by using virt_load_acquire() to read the write index,
> > ensuring that reads of the packet data cannot be reordered
> > before it. Preventing such reordering is logically correct, and
> > with this change, getting stale data can no longer be reproduced.
> >
> > Signed-off-by: Michael Kelley <mikelley@microsoft.com>
>
> Reviewed-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
>
> Nit: subject prefix -> "Drivers: hv: vmbus:".

Applied to hyperv-fixes. Thanks.

>
> Thanks,
> Andrea