From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1bwh-0001JK-8k for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1bwg-0006TN-GG for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1bwg-0006T8-Bj for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:54 -0400 From: Paolo Bonzini Date: Tue, 1 Nov 2016 17:29:18 +0100 Message-Id: <1478017783-7703-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1478017783-7703-1-git-send-email-pbonzini@redhat.com> References: <1478017783-7703-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 05/30] exec.c: ensure all AddressSpaceDispatch updates under RCU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= From: Alex Benn=C3=A9e 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=C3=83=C2=A9e Message-Id: <20161021153418.21571-1-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 4d08581..a19ed21 100644 --- a/exec.c +++ b/exec.c @@ -493,7 +493,7 @@ address_space_translate_for_iotlb(CPUState *cpu, int = 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].me= mory_dispatch); =20 section =3D address_space_translate_internal(d, addr, xlat, plen, fa= lse); =20 @@ -2376,7 +2376,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 2.7.4