From patchwork Tue Nov 1 16:29:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 80383 Delivered-To: patch@linaro.org Received: by 10.80.142.83 with SMTP id 19csp749164edx; Tue, 1 Nov 2016 10:05:03 -0700 (PDT) X-Received: by 10.176.84.7 with SMTP id n7mr17471908uaa.30.1478019903775; Tue, 01 Nov 2016 10:05:03 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q10si14046030uab.126.2016.11.01.10.05.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 01 Nov 2016 10:05:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:49364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1cUh-0004Vr-3R for patch@linaro.org; Tue, 01 Nov 2016 13:05:03 -0400 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 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A668A80F63; Tue, 1 Nov 2016 16:29:53 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA1GThGq005173; Tue, 1 Nov 2016 12:29:52 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org 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 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 01 Nov 2016 16:29:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/30] exec.c: ensure all AddressSpaceDispatch updates under RCU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée 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 Message-Id: <20161021153418.21571-1-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 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 = 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); @@ -2376,7 +2376,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); }