From patchwork Fri Feb 21 07:41:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 230849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA7E4C35642 for ; Fri, 21 Feb 2020 08:26:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8394C20637 for ; Fri, 21 Feb 2020 08:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273586; bh=Cn24knfDqUAqJvb4N8NFHPFVd8dzAnate7ktenvU3Ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=aLCTPWxICFpX8nATCs6Tn33wYAN83NLWf5xhUwHMfZWeRAZHQB8Rbm2i06pmS726x Spde4xwgt6zbZGyGFYUlGTtO2ddcKSzvnrqRTfOz+lhlQKTpJuA42z8PPQAup5sSR2 q9eQq4Z0g8nFARmqXSVCIJxsHcUaELnsKCYJppVU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731059AbgBUIXr (ORCPT ); Fri, 21 Feb 2020 03:23:47 -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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 */