From patchwork Fri Oct 21 15:34:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 78686 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1362429qge; Fri, 21 Oct 2016 08:35:42 -0700 (PDT) X-Received: by 10.55.126.130 with SMTP id z124mr1904538qkc.63.1477064142324; Fri, 21 Oct 2016 08:35: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 n187si2245280qkf.84.2016.10.21.08.35.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 21 Oct 2016 08:35: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=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxbrB-0007uS-S0 for patch@linaro.org; Fri, 21 Oct 2016 11:35:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxbq4-0007Wj-3l for qemu-devel@nongnu.org; Fri, 21 Oct 2016 11:34:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxbq0-0004yO-Tp for qemu-devel@nongnu.org; Fri, 21 Oct 2016 11:34:32 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:37347) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bxbq0-0004yA-FJ for qemu-devel@nongnu.org; Fri, 21 Oct 2016 11:34:28 -0400 Received: by mail-wm0-x236.google.com with SMTP id f193so1861245wmg.0 for ; Fri, 21 Oct 2016 08:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=L/SL4cL37wIsuUB0MBDFuo2QQN561RnNYRRkTIVV5o4=; b=NJDJ3bHH8gK/bMVRCg3H5FMRi416+r26s0ljGyuHOYs9Cx8VA/r312uHTjpxmTQ6sl VWwvKjlQBjgaqXQIjFSvNLqeCdEpcPQPq9mi5ILlfFyXFVYrGt1XX+EYYQE2MuvTuU6z QiwvQDuEurUiNuJBleQ3NqE4IlcVKQy5HY9Ls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=L/SL4cL37wIsuUB0MBDFuo2QQN561RnNYRRkTIVV5o4=; b=lgPVEqpzImfnQUI3Nx2//moKuuZRu2bTqn6F/7ZoBjDSWBrDYlvZZFjF9fr1hEYWeq dHTX/Ekktb0ad9rD6OS0eszW3a+a9lwQ6pprKHyI72zhPQ2GyRITin7DyPRVq8vrXhLE s7HiZXJhtVijmT7jP6fmwuS+ASTMzpVf4v4k8zNxMxsGxNOldQHWrkrnnohE9ZM1Cp+4 3bQIbrzPscvkVaLnO2FEarVnjdwXkT8Qdu+hvMKJUBGKz9/JJ8Q/Ig+3VW22cZdzvN+X mxBKNiXdQNgnmZycQrgLaXySOZ9NLKAIN7L0LEf0gyjOV2DWpPfG5qDjcz4RLMF+UmnN b2pA== X-Gm-Message-State: AA6/9RkDdzRkBrzR+RNw/4Qy+JK5vNZDSJD4Oh+t39/QKZaS6XBlGbikeotTOf2dkmynWks1 X-Received: by 10.28.38.195 with SMTP id m186mr3370953wmm.81.1477064067120; Fri, 21 Oct 2016 08:34:27 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s133sm4765190wmd.19.2016.10.21.08.34.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Oct 2016 08:34:26 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id DF9CA3E007F; Fri, 21 Oct 2016 16:34:25 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: pbonzini@redhat.com Date: Fri, 21 Oct 2016 16:34:18 +0100 Message-Id: <20161021153418.21571-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.9.3 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::236 Subject: [Qemu-devel] [PATCH] 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: Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Peter Crosthwaite Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.3 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); }