Commit 7ad47239 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin
Browse files

vhost: move smp_rmb() into vhost_get_avail_idx()



All callers of vhost_get_avail_idx() use smp_rmb() to
order the available ring entry read and avail_idx read.

Make vhost_get_avail_idx() call smp_rmb() itself whenever the avail_idx
is accessed. This way, the callers don't need to worry about the memory
barrier. As a side benefit, we also validate the index on all paths now,
which will hopefully help prevent/catch earlier future bugs.

Note that current code is inconsistent in how the errors are handled.
They are treated as an empty ring in some places, but as non-empty
ring in other places. This patch doesn't attempt to change the existing
behaviour.

No functional change intended.

Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarGavin Shan <gshan@redhat.com>
Acked-by: default avatarWill Deacon <will@kernel.org>
Message-Id: <20240429232748.642356-1-gshan@redhat.com>
parent fdba68d2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment