From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: Ilya Maximets <i.maximets@samsung.com>, dev@dpdk.org
Cc: Tiwei Bie <tiwei.bie@intel.com>,
Zhihong Wang <zhihong.wang@intel.com>,
jfreimann@redhat.com, stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] vhost: fix double read of descriptor flags
Date: Tue, 11 Dec 2018 15:47:17 +0100 [thread overview]
Message-ID: <2d823cb0-2663-6de4-733e-2ccde720efae@redhat.com> (raw)
In-Reply-To: <20181205150926.4895-1-i.maximets@samsung.com>
On 12/5/18 4:09 PM, Ilya Maximets wrote:
> 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: d3211c98c456 ("vhost: add helpers for packed virtqueues")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
> lib/librte_vhost/vhost.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> index 5218f1b12..84cbee2b6 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -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
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
next prev parent reply other threads:[~2018-12-11 14:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20181205150935eucas1p11698df8ed58ff02a4326dd5780af4470@eucas1p1.samsung.com>
2018-12-05 15:09 ` Ilya Maximets
2018-12-11 14:47 ` Maxime Coquelin [this message]
2018-12-11 18:33 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d823cb0-2663-6de4-733e-2ccde720efae@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=dev@dpdk.org \
--cc=i.maximets@samsung.com \
--cc=jfreimann@redhat.com \
--cc=stable@dpdk.org \
--cc=tiwei.bie@intel.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).