From: Paolo Bonzini <pbonzini@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] exec.c: ensure all AddressSpaceDispatch updates under RCU
Date: Mon, 24 Oct 2016 16:17:02 +0200 [thread overview]
Message-ID: <0f28b3f0-c782-a0e4-d853-218d0a8a609a@redhat.com> (raw)
In-Reply-To: <20161021153418.21571-1-alex.bennee@linaro.org>
On 21/10/2016 17:34, Alex Bennée wrote:
> The memory_dispatch field is meant to be protected by RCU so we should
> use the correct primitives when accessing it. This race was flagged up
> by the ThreadSanitizer.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> exec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index 738e8ba..c5e4073 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -459,7 +459,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
> hwaddr *xlat, hwaddr *plen)
> {
> MemoryRegionSection *section;
> - AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch;
> + AddressSpaceDispatch *d = atomic_rcu_read(&cpu->cpu_ases[asidx].memory_dispatch);
>
> section = address_space_translate_internal(d, addr, xlat, plen, false);
>
> @@ -2342,7 +2342,7 @@ static void tcg_commit(MemoryListener *listener)
> * may have split the RCU critical section.
> */
> d = atomic_rcu_read(&cpuas->as->dispatch);
> - cpuas->memory_dispatch = d;
> + atomic_rcu_set(&cpuas->memory_dispatch, d);
> tlb_flush(cpuas->cpu, 1);
> }
>
>
Oops, this missed today's pull request but it's a bug so it can go in later.
Thanks,
Paolo
prev parent reply other threads:[~2016-10-24 14:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 15:34 [Qemu-devel] [PATCH] exec.c: ensure all AddressSpaceDispatch updates under RCU Alex Bennée
2016-10-24 14:17 ` Paolo Bonzini [this message]
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=0f28b3f0-c782-a0e4-d853-218d0a8a609a@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=crosthwaite.peter@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).