From patchwork Wed Mar 28 14:39:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 10313449 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 A0ED260353 for ; Wed, 28 Mar 2018 14:40:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76DA029F9F for ; Wed, 28 Mar 2018 14:40:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 754E629FE9; Wed, 28 Mar 2018 14:40:08 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7560629F94 for ; Wed, 28 Mar 2018 14:40:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=ooBMFKt8wsClnjbY2OMEFqLqVpAf9PeclLanrA+k5Sg=; b=SUl 3qd7UzNZCw8LTXJ044W2u7PxGi4MJJztesFdk3eIZBDYOjkFn9s2gun9df3IsCBjMygjd1WFntgQH XtzC9LaWgjn1Ja7oHg+aNYsdLrkdwdGp9rzGVLXPf9JsALNE9giFAWqzuOwAec7ZQvLr/JbTxhQed miSUKhy7S3RPby/QFVc68W5t29gqYHI1dCLsdeHoz65H1iD7FfKL7Cc8HYQfd0wLMdeXU3QfD8bg8 lfjWsySKQM8P82IDPx089HwHRTaolQhYiIFSO6bWxfOgTjz2kQPfZWUwtG8E1jNZt27wtqjARYOa/ 4vndGV15jDUND08iBjll1a/ZgwpP6gg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1CF4-0006tx-K9; Wed, 28 Mar 2018 14:39:58 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f1CF1-0006sq-Nc for linux-arm-kernel@lists.infradead.org; Wed, 28 Mar 2018 14:39:57 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D205660224; Wed, 28 Mar 2018 14:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522247984; bh=Crf+pyzl8GBmWK9ekngXbhWw7yM2QQO4qsbfrN0YAA8=; h=From:To:Cc:Subject:Date:From; b=bSM1mqncE8Su4h3l3Ma4z93jTlI3XZLE7D56WYCzmyWXa9tN5uyXKrhA0lGkXf6oQ PJuRGtGt6hWNe6+N3FTxi+jWEKn6Dc70F7nBfGu0gLdOMeMCSWafddmRLAA0EJ5YeP l7K0OTVFn7JG7+fQHqJQTnyhM3nURi4vlWXTHzyk= Received: from timur-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id BEA34603AF; Wed, 28 Mar 2018 14:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522247984; bh=Crf+pyzl8GBmWK9ekngXbhWw7yM2QQO4qsbfrN0YAA8=; h=From:To:Cc:Subject:Date:From; b=bSM1mqncE8Su4h3l3Ma4z93jTlI3XZLE7D56WYCzmyWXa9tN5uyXKrhA0lGkXf6oQ PJuRGtGt6hWNe6+N3FTxi+jWEKn6Dc70F7nBfGu0gLdOMeMCSWafddmRLAA0EJ5YeP l7K0OTVFn7JG7+fQHqJQTnyhM3nURi4vlWXTHzyk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BEA34603AF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=timur@codeaurora.org From: Timur Tabi To: linux-arm-kernel@lists.infradead.org, Will Deacon , Robin Murphy , Joerg Roedel , nwatters@codeaurora.org, iommu@lists.linux-foundation.org, Sameer Goel Subject: [PATCH] iommu/arm-smmu-v3: Set GBPA to abort all transactions Date: Wed, 28 Mar 2018 09:39:40 -0500 Message-Id: <1522247980-31892-1-git-send-email-timur@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-20180328_073955_786287_BED189E8 X-CRM114-Status: GOOD ( 13.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: timur@codeaurora.org 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 From: Sameer Goel Set SMMU_GBPA to abort all incoming translations during the SMMU reset when SMMUEN==0. This prevents a race condition where a stray DMA from the crashed primary kernel can try to access an IOVA address as an invalid PA when SMMU is disabled during reset in the crash kernel. Signed-off-by: Sameer Goel --- drivers/iommu/arm-smmu-v3.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 3f2f1fc68b52..c04a89310c59 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2458,6 +2458,18 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass) if (reg & CR0_SMMUEN) dev_warn(smmu->dev, "SMMU currently enabled! Resetting...\n"); + /* + * Abort all incoming translations. This can happen in a kdump case + * where SMMU is initialized when a prior DMA is pending. Just + * disabling the SMMU in this case might result in writes to invalid + * PAs. + */ + ret = arm_smmu_update_gbpa(smmu, 1, GBPA_ABORT); + if (ret) { + dev_err(smmu->dev, "GBPA not responding to update\n"); + return ret; + } + ret = arm_smmu_device_disable(smmu); if (ret) return ret;