Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1931596ybv; Fri, 14 Feb 2020 08:26:15 -0800 (PST) X-Google-Smtp-Source: APXvYqxXQIh1XOiLisp6fDBRxcYDu3pZ4YFhmFvTnaB2Pqbi+dx6xVtFy073+XCx9kd9HroFVhMm X-Received: by 2002:aca:5258:: with SMTP id g85mr2475070oib.80.1581697575447; Fri, 14 Feb 2020 08:26:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697575; cv=none; d=google.com; s=arc-20160816; b=d3CZ0INDldTQFmypty2Odd4u6XtjFmpufRKJ686xxOFdFxe1SvIocc64h/vYGA7rv/ LIYsHiCM5HokwAZ6si0eMP5kngrVIzDmVc7c00YFHFJQYtys5go2sMFZ2nPYIqiShcQk EGxN7BBBMFnPtbl9AfwRXse1+gFUz4h70c3d7lmecNkznqB+GiczuHq9hzlxG6M9etK9 QS/xy2Afz115OvmdxH7+PALQKhSI8x2+dEjzDiBY/1Gi7P1Nyn4WgbgG+R7nXpAKa2m/ h9JxY7BChikzZX0lbcJFPnVSxXtp5c88hwkLt6ShK4Pd7QIxMJo6odtJrNCs2Gf7U1Wo 2Dqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7jch0dbtQQX0hvqRZE1rXRzkU1WO4GSGVt9jaaNN7so=; b=sZQNlHC5EmgSBkj1F3YAj4fM4VBz9CkSiSUFBfS9QqkWe8avkvIfABYpDFdlT+LVuy GjWK6H5NoiL5a2p44s0Yieq/orJ34Ir3HYwys40wp9flPxoU1ebQiWCSV/TTctjEfAQM M2++Gqi+A8PM6XfvJ/VO2PRrXUWVOMXiwgZfoxpRPt4AGjfFsl0da1SClZ5IRNzO8Nkp Q4JEyl85gq80mkpj0iUV+K5eLiQ49drj8GZAZY8hVk9RgID3VIgnYEbm3nsLnN4d9QiK v4j7NHmSyHu7QpXOZaMPYNBLeMm1kKgC/IqRLAM32P/ILiOFzEj0hsZXI8A5/8N1TVm1 +sqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u7O2o9pt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p83si2811223oih.198.2020.02.14.08.26.03; Fri, 14 Feb 2020 08:26:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u7O2o9pt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406163AbgBNQZh (ORCPT + 99 others); Fri, 14 Feb 2020 11:25:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:59818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405657AbgBNQXb (ORCPT ); Fri, 14 Feb 2020 11:23:31 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7703A24776; Fri, 14 Feb 2020 16:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697410; bh=zg6Uq7ArT0C+WyG4FP67wrVc7ANAPFZHEsRcL6m0R6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u7O2o9pt8U4bwIJB2bBN42fv7kVC+tBRtcngVnxRe920X0lPEKQf5tUWj4XYxbkbR 72rDkaMgf9R9+9oXydNhrFZ77t0COvOdbRWy3BV4argW+4ZuM2NyBoJSMyunHTDm3D 50quqgDZcsKAhLeedWqOH2uPrOVY6ampY5O8A41A= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Will Deacon , Jean-Philippe Brucker , Sasha Levin , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org Subject: [PATCH AUTOSEL 4.9 102/141] iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE Date: Fri, 14 Feb 2020 11:20:42 -0500 Message-Id: <20200214162122.19794-102-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon [ Upstream commit d71e01716b3606a6648df7e5646ae12c75babde4 ] If, for some bizarre reason, the compiler decided to split up the write of STE DWORD 0, we could end up making a partial structure valid. Although this probably won't happen, follow the example of the context-descriptor code and use WRITE_ONCE() to ensure atomicity of the write. Reported-by: Jean-Philippe Brucker Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/iommu/arm-smmu-v3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 7bd98585d78d2..48d3820087881 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1103,7 +1103,8 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid, } arm_smmu_sync_ste_for_sid(smmu, sid); - dst[0] = cpu_to_le64(val); + /* See comment in arm_smmu_write_ctx_desc() */ + WRITE_ONCE(dst[0], cpu_to_le64(val)); arm_smmu_sync_ste_for_sid(smmu, sid); /* It's likely that we'll want to use the new STE soon */ -- 2.20.1