From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byg3s-0003WS-CA for qemu-devel@nongnu.org; Mon, 24 Oct 2016 10:17:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byg3o-00019o-D9 for qemu-devel@nongnu.org; Mon, 24 Oct 2016 10:17:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57416) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byg3o-00019X-6O for qemu-devel@nongnu.org; Mon, 24 Oct 2016 10:17:08 -0400 References: <20161021153418.21571-1-alex.bennee@linaro.org> From: Paolo Bonzini Message-ID: <0f28b3f0-c782-a0e4-d853-218d0a8a609a@redhat.com> Date: Mon, 24 Oct 2016 16:17:02 +0200 MIME-Version: 1.0 In-Reply-To: <20161021153418.21571-1-alex.bennee@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] exec.c: ensure all AddressSpaceDispatch updates under RCU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= Cc: qemu-devel@nongnu.org, Peter Crosthwaite , Richard Henderson On 21/10/2016 17:34, Alex Benn=C3=A9e 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. >=20 > Signed-off-by: Alex Benn=C3=A9e > --- > exec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > 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, in= t asidx, hwaddr addr, > hwaddr *xlat, hwaddr *plen) > { > MemoryRegionSection *section; > - AddressSpaceDispatch *d =3D cpu->cpu_ases[asidx].memory_dispatch; > + AddressSpaceDispatch *d =3D atomic_rcu_read(&cpu->cpu_ases[asidx].= memory_dispatch); > =20 > section =3D address_space_translate_internal(d, addr, xlat, plen, = false); > =20 > @@ -2342,7 +2342,7 @@ static void tcg_commit(MemoryListener *listener) > * may have split the RCU critical section. > */ > d =3D atomic_rcu_read(&cpuas->as->dispatch); > - cpuas->memory_dispatch =3D d; > + atomic_rcu_set(&cpuas->memory_dispatch, d); > tlb_flush(cpuas->cpu, 1); > } > =20 >=20 Oops, this missed today's pull request but it's a bug so it can go in lat= er. Thanks, Paolo