From patchwork Mon Jul 20 11:27:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 51271 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9AD17228F7 for ; Mon, 20 Jul 2015 11:27:27 +0000 (UTC) Received: by wgik5 with SMTP id k5sf4388127wgi.0 for ; Mon, 20 Jul 2015 04:27:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=QQhJS+WBuVy+z8OfMkM0H031q2smWucQm5RBPVaurS0=; b=PXSjx2JbMOusJaeAq43WhqM7dhiUtkG5rjV97JkUN8gKakHmNg8i3chrY2oCNdOpnY OtmB7bgkGaTbZcTSsD1prJ9GUdtyC1TZ++4IvkDjETu3VjI8EHvZxYDelhGSuIVSifRF SidIj92W1olV6ZeasotoCtJ/VaFZaJ+BnuLx4aSM446sdonVOQrwRBaWa5oUPNyQyLcE /XvnQVHYT1QNjjbBtbzVq4O8xNh1L1y261JaUaZD1ygqJ2sVdab1UoNVUgdOuhgK651O eKBA60nA/J7woJm42AjcWOBttlifT+UR4UQB4jDsU6td2KDm1cdfD/CMyMYe650Nww4f JWlw== X-Gm-Message-State: ALoCoQmvVgb96urrQ5xI6B6SD2lMCJh33RuFdjGvc5DCkIuepiRypLo9zMxDhMdc0hoQAE31iaX9 X-Received: by 10.180.160.133 with SMTP id xk5mr1047314wib.1.1437391646760; Mon, 20 Jul 2015 04:27:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.194 with SMTP id v2ls847335lag.59.gmail; Mon, 20 Jul 2015 04:27:26 -0700 (PDT) X-Received: by 10.152.9.137 with SMTP id z9mr27488913laa.68.1437391646599; Mon, 20 Jul 2015 04:27:26 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id xh9si11810389lac.122.2015.07.20.04.27.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jul 2015 04:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbyj8 with SMTP id yj8so93302126lbb.0 for ; Mon, 20 Jul 2015 04:27:26 -0700 (PDT) X-Received: by 10.112.133.72 with SMTP id pa8mr27097679lbb.117.1437391639862; Mon, 20 Jul 2015 04:27:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.7.198 with SMTP id l6csp740642lba; Mon, 20 Jul 2015 04:27:19 -0700 (PDT) X-Received: by 10.180.74.132 with SMTP id t4mr21672744wiv.55.1437391639258; Mon, 20 Jul 2015 04:27:19 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id iw1si34637797wjb.166.2015.07.20.04.27.18 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 20 Jul 2015 04:27:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZH9E5-0008Dl-0s; Mon, 20 Jul 2015 12:27:17 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Paolo Bonzini Subject: [PATCH] exec.c: Use atomic_rcu_read() to access dispatch in memory_region_section_get_iotlb() Date: Mon, 20 Jul 2015 12:27:16 +0100 Message-Id: <1437391637-31576-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When accessing the dispatch pointer in an AddressSpace within an RCU critical section we should always use atomic_rcu_read(). Fix an access within memory_region_section_get_iotlb() which was incorrectly doing a direct pointer access. Signed-off-by: Peter Maydell --- I discussed this on IRC with Paolo a while back, and IIRC he said that although this is a bug it's not one that can currently have any ill effects, though I forget why (probably because this code path is TCG only and TCG is single-threaded right now). exec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 7d60e15..0a4a0c5 100644 --- a/exec.c +++ b/exec.c @@ -954,7 +954,10 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, iotlb |= PHYS_SECTION_ROM; } } else { - iotlb = section - section->address_space->dispatch->map.sections; + AddressSpaceDispatch *d; + + d = atomic_rcu_read(§ion->address_space->dispatch); + iotlb = section - d->map.sections; iotlb += xlat; }