Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1619763ybv; Fri, 21 Feb 2020 00:25:13 -0800 (PST) X-Google-Smtp-Source: APXvYqyQ/7ionJQi/DnKxLUhvGETU9L02nWC3PJIH6vcxh/ngrvXiozinaU3vEoLEBi9LRCdhVPF X-Received: by 2002:aca:1204:: with SMTP id 4mr1025305ois.143.1582273513038; Fri, 21 Feb 2020 00:25:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273513; cv=none; d=google.com; s=arc-20160816; b=0t+o+Y97hHS3WaM7aVOOJGH8GKzW85f5tSCJ6JbgmQ+hL4/DfO3JiwGhnXoCCUN26t c7PvRvu9A4fT1Xcx1/iJ23cyowMO4fcXobHlGj3DHbAjwNCOKT8xNAgdt7HlifPSJ4vZ 5phAnmOCpumRbDgNJRCfTziW0BJSuRtqXI6OQPi5VfV3lhP7j95MK4/W3bDHh5PIhCJ7 OmhuIG3EZHqOkVstktiRkjKJPpZhy+UtVreFIGxeyN67rljb6RvoT1xP4EKUZf/G5Z0M ySvgaNQuaa27XHP576e4jdiLSQE3+UKKYSlwRVKe+3sKIyRoa/gGxROiZslTDpuluy+f s8hA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VnzbSSuk7Rh5u3c5V6dOEWq78w/qVoX9yYo2n5By3yk=; b=Sj4R+NZ/GdIgaZQJoRt7e73j/netu68xbOME+jGALznwN56JBhELcqu3QwqWSZiwnf wGdpFc2o9z4jOJ+RSRYIuV4UIWWWlNO6LynMBcc1twdATBG93kfi/UH1TW00VJQUG54v K9jNqACKCaTzbni+bvLKi6cr8VokJ9kQVZI19k8t1a138gWPkMm0B8yTqft36WDMMaXp dSXvN+zy9pSn2Dwp0Fz4vrnWGPhmwMsBUX6WRuzl+fq3lpkedscSqIzeG/GYPuTu4Z+E xCE/coT5MmEn3DMAwMM+UCnA/77pQes/jTsGoWsSNRcdhqFpXh5CU4gpxPKyO02JIuqr SNFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=st1NPQK9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1si437254oix.12.2020.02.21.00.25.00; Fri, 21 Feb 2020 00:25:13 -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=st1NPQK9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730661AbgBUIXs (ORCPT + 99 others); Fri, 21 Feb 2020 03:23:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:35996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388543AbgBUIXq (ORCPT ); Fri, 21 Feb 2020 03:23:46 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A82A22469D; Fri, 21 Feb 2020 08:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273426; bh=Cn24knfDqUAqJvb4N8NFHPFVd8dzAnate7ktenvU3Ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=st1NPQK9GZWjCFDRXWQe9eVGsyfKhU3iK24cSOaaL9hYIcydTAxGPqeyU/F4Txhuc TKJ68V4Lo1Tc4SMBM1KNBgif5xppEQ2k6nHM8j52eZTxjN/Cp3/YOGRebGxctSFuN4 k+mRZ2NoTGlDyxfBQ4Ukg8yo3k7kA6wnDzikLtxE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jean-Philippe Brucker , Will Deacon , Sasha Levin Subject: [PATCH 4.19 130/191] iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE Date: Fri, 21 Feb 2020 08:41:43 +0100 Message-Id: <20200221072306.451259038@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 eff1f3aa5ef43..6b7664052b5be 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1185,7 +1185,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