vhost: fix double read of descriptor flags
Flags could be updated in a separate process leading to the
inconsistent check.
Additionally, read marked as 'volatile' to highlight the shared
nature of the variable and avoid such issues in the future.
Fixes: d3211c98c4
("vhost: add helpers for packed virtqueues")
Cc: stable@dpdk.org
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
parent
81e5cdf19e
commit
48cae0bfa6
@ -393,8 +393,10 @@ vq_is_packed(struct virtio_net *dev)
|
||||
static inline bool
|
||||
desc_is_avail(struct vring_packed_desc *desc, bool wrap_counter)
|
||||
{
|
||||
return wrap_counter == !!(desc->flags & VRING_DESC_F_AVAIL) &&
|
||||
wrap_counter != !!(desc->flags & VRING_DESC_F_USED);
|
||||
uint16_t flags = *((volatile uint16_t *) &desc->flags);
|
||||
|
||||
return wrap_counter == !!(flags & VRING_DESC_F_AVAIL) &&
|
||||
wrap_counter != !!(flags & VRING_DESC_F_USED);
|
||||
}
|
||||
|
||||
#define VHOST_LOG_PAGE 4096
|
||||
|
Loading…
Reference in New Issue
Block a user