From patchwork Mon Oct 31 14:37:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 80210 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp159229qge; Mon, 31 Oct 2016 07:58:42 -0700 (PDT) X-Received: by 10.237.35.53 with SMTP id h50mr26367044qtc.101.1477925922153; Mon, 31 Oct 2016 07:58:42 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k185si6163478qkc.96.2016.10.31.07.58.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 31 Oct 2016 07:58:42 -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; dkim=fail header.i=@gmail.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]:36146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1E2r-0007ic-IP for patch@linaro.org; Mon, 31 Oct 2016 10:58:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Dil-0005UZ-IX for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:37:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1Dik-0003oC-JK for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:37:55 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1Dik-0003o4-Bf for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:37:54 -0400 Received: by mail-wm0-x242.google.com with SMTP id c17so18713423wmc.3 for ; Mon, 31 Oct 2016 07:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0uKKcZkQE9KPH1vAVPDqHvSENV5a5cRjGKcdNVRIRN4=; b=bYCeK2H9zf88d9HA8LawAcHnCt/J8ZdSmGG6uFj6swH9Pcn/LSFqc8kZlY9mKeA12j xbKDYTrFql/slFjRwnORS9dX/JhUj4j2Z3rPUAvGoySoQ0LEwa6I6iJf2g2/Xpw8X4Dz EDuMw+LqoIIy2CeyadGsqOyeGiTFHVaqcQgE9UaBzouHfIBAdB7x7BdRAu6+gezt7ZZz MHk11yO3Ii1SHZ1sWYzeHn938kzodxE8s9s4eAxu0LVEqcU1f8dxV4HiBTY1985d3IH9 ysuP31qar2IwcuO9va7D1c4Jp4jugm3NHBZabuGPW9HwTiu2x6yhZVvjI/ePODQMDgI6 7HbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0uKKcZkQE9KPH1vAVPDqHvSENV5a5cRjGKcdNVRIRN4=; b=k5pZAtHjYB76yX2SBoK5gnsMFp5D2Vm1RbQbTRMAGu2QbZjmjR4gIJVUiLmfrmhbOF 2SQ+ZzAc+MXAM+GfjY4o99B5mUk8DIGQBFVLrml1AmYBZrY1pPqPNmWDntKtVAyO+nfw 21YLgFCQ96Kn+IArBN9doCFnpwSgnqh5iHM1ZN0doXWCsqrrGVn6Pcjv7sLKh2jMxfAb au5CTXdOmwIUCqH1pXG3jc0woC0flb8PLebzwxpulfy//1PoJRD9TjZR0nKL6BqT6Uwl DGV6DlxQAhtKW6alV3LsZ/vmH5YZBXX+55W8g5uc2q3q8GKFPSZHi8sfkAwFPM3o20Ic PIQw== X-Gm-Message-State: ABUngvdkZ8Wv1+SZnZR/U2yGMsWCjx0v9kvtVKM3tnbhsBNY5MhUg2dyammzupgJ4i+bzQ== X-Received: by 10.28.215.204 with SMTP id o195mr10210583wmg.29.1477924673092; Mon, 31 Oct 2016 07:37:53 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-246-178.clienti.tiscali.it. [78.12.246.178]) by smtp.gmail.com with ESMTPSA id r72sm25166766wmd.21.2016.10.31.07.37.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 07:37:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 31 Oct 2016 15:37:21 +0100 Message-Id: <1477924663-30950-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477924663-30950-1-git-send-email-pbonzini@redhat.com> References: <1477924663-30950-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 05/27] 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 4c84389..fc4d31d 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); @@ -2356,7 +2356,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); }