From patchwork Mon Dec 19 20:38:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nate Watterson X-Patchwork-Id: 9480749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A504601C2 for ; Mon, 19 Dec 2016 20:44:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B08128449 for ; Mon, 19 Dec 2016 20:44:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FA7E2849D; Mon, 19 Dec 2016 20:44:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4DFDD28487 for ; Mon, 19 Dec 2016 20:44:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJ4lX-0001xV-3L; Mon, 19 Dec 2016 20:42:35 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJ4lS-0001jD-K0 for linux-arm-kernel@lists.infradead.org; Mon, 19 Dec 2016 20:42:31 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7A2A8615A8; Mon, 19 Dec 2016 20:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1482180126; bh=FBd+ssMCxHOywWW/i/wHsEO4bld3cMrv14hgXh+8W6Y=; h=From:To:Cc:Subject:Date:From; b=Y3dOxn3qmuLznfsQOqyLMQ5DcHYQlEKq9WwGE4o5ydfVaUuOJcWB1Xw+MifkNWr+N 6xsp7s45zAkMWkQBhj1y/sJGRZXZ5y77L4Z7QUw3Bz85rc66YK/800iAJ5KXERWcZS ad3wC85YLFYEoeGg5ok2tTx08EvtPpWR45EDgMEw= Received: from ssd-mint172.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nwatters@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2328D614E5; Mon, 19 Dec 2016 20:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1482180125; bh=FBd+ssMCxHOywWW/i/wHsEO4bld3cMrv14hgXh+8W6Y=; h=From:To:Cc:Subject:Date:From; b=aktVTv9a66k/yV8vUkLPNd203ODOePSN+ZfXSt1AA3SawoU7sc5yBR61RbNitHY7v RV5GgAkmqU/c4QJ43n8LfL9EMUYk4GTSEPqOeca5f9OCcurJV/eXJSVWPBJvrO2fGh RZbtSYfwHSZlOUFRUwuT9FkJCIzIyf/BgB9ZvRCs= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 2328D614E5 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=nwatters@codeaurora.org From: Nate Watterson To: Will Deacon , Robin Murphy , Joerg Roedel , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/arm-smmu-v3: prevent corruption of ste stage-1 context ptr Date: Mon, 19 Dec 2016 15:38:38 -0500 Message-Id: <1482179918-4457-1-git-send-email-nwatters@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161219_124230_749294_0A256133 X-CRM114-Status: GOOD ( 10.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nate Watterson MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To ensure that the stage-1 context ptr for an ste points to the intended context descriptor, this patch adds code to clear away the stale context ptr value prior to or'ing in the new one. Signed-off-by: Nate Watterson --- drivers/iommu/arm-smmu-v3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 4d6ec44..093f9f1 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1080,6 +1080,8 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid, if (smmu->features & ARM_SMMU_FEAT_STALLS) dst[1] |= cpu_to_le64(STRTAB_STE_1_S1STALLD); + val &= ~(STRTAB_STE_0_S1CTXPTR_MASK << + STRTAB_STE_0_S1CTXPTR_SHIFT); val |= (ste->s1_cfg->cdptr_dma & STRTAB_STE_0_S1CTXPTR_MASK << STRTAB_STE_0_S1CTXPTR_SHIFT) | STRTAB_STE_0_CFG_S1_TRANS;