From patchwork Wed Dec 21 04:11:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nate Watterson X-Patchwork-Id: 9482481 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 D1F3B60772 for ; Wed, 21 Dec 2016 04:17:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3A9227EED for ; Wed, 21 Dec 2016 04:17:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6AA22818B; Wed, 21 Dec 2016 04:17:43 +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 541E127EED for ; Wed, 21 Dec 2016 04:17:42 +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 1cJYJc-0001S0-99; Wed, 21 Dec 2016 04:15:44 +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 1cJYJW-0000hk-6q for linux-arm-kernel@lists.infradead.org; Wed, 21 Dec 2016 04:15:39 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 94830615F3; Wed, 21 Dec 2016 04:15:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1482293715; bh=MuPWDAKqnVQxILMiOnyElj4crQcjTCP2YHA/6cmalW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OSBdxfVyxCmYhQ3drtVucsIHoJpmkTCeGTcrUlfwMlZprRdgWIrklhY83C2Ei0anS JF9FODnVI8K69ukfuMqtzPfsWki7jnfbwMj2LT176V/bH+IhlDigPF4FqFN4VcwKnm t4c4t/qysdYBCHmTD5InGzF5YRtK7cX5Lpm8KJfs= 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 3053B615BA; Wed, 21 Dec 2016 04:15:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1482293714; bh=MuPWDAKqnVQxILMiOnyElj4crQcjTCP2YHA/6cmalW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1grm8OamAPJC49vy5L6Xxw9y1VZBaCy9y5ors/TDn+4Iwzc6XBBWBdQrrgHcKzUF 5i7jKJ4uA00j5jZ8b0DSINqMuhVKXHftV8j0Cf7uyZwtmTxYKNh3lsEFbF0IpJoj7L BKEg0f2MLttNubX9HfOYJFvOwj2HVjzfpGMYoL0Q= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 3053B615BA 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: Clear prior settings when updating STEs Date: Tue, 20 Dec 2016 23:11:48 -0500 Message-Id: <1482293508-21621-1-git-send-email-nwatters@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <20161220095340.GB10132@arm.com> References: <20161220095340.GB10132@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161220_201538_345356_851256BF X-CRM114-Status: GOOD ( 11.30 ) 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 prevent corruption of the stage-1 context pointer field when updating STEs, rebuild the entire containing dword instead of clearing individual fields. Signed-off-by: Nate Watterson --- drivers/iommu/arm-smmu-v3.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 4d6ec44..94f305d 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1042,13 +1042,8 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid, } } - /* Nuke the existing Config, as we're going to rewrite it */ - val &= ~(STRTAB_STE_0_CFG_MASK << STRTAB_STE_0_CFG_SHIFT); - - if (ste->valid) - val |= STRTAB_STE_0_V; - else - val &= ~STRTAB_STE_0_V; + /* Nuke the existing STE_0 value, as we're going to rewrite it */ + val = ste->valid ? STRTAB_STE_0_V : 0; if (ste->bypass) { val |= disable_bypass ? STRTAB_STE_0_CFG_ABORT @@ -1083,7 +1078,6 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid, val |= (ste->s1_cfg->cdptr_dma & STRTAB_STE_0_S1CTXPTR_MASK << STRTAB_STE_0_S1CTXPTR_SHIFT) | STRTAB_STE_0_CFG_S1_TRANS; - } if (ste->s2_cfg) {