From patchwork Tue Jun 26 02:30:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Goel, Sameer" X-Patchwork-Id: 10487873 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 F09F0603B5 for ; Tue, 26 Jun 2018 02:31:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCEB12871C for ; Tue, 26 Jun 2018 02:31:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C00A528726; Tue, 26 Jun 2018 02:31:11 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 60B072871C for ; Tue, 26 Jun 2018 02:31:11 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=dJ2xJW25vtaETHgp8wQa0Mu6LwZ5qkN2c0NEobj2mpM=; b=OMr+ZUFf0hXGP7 s2d1vy06SDk9VjysiN3MtAutfzu5c9KqIhcDPgRkOaXAkvKa/sgCAYqlzB4gRGz2CM/mnRK2zYabm ZeqkIrWHqwQn6/6jXAfXWxKdCLjFU914pxmvBSubI1ugSsbDm1rpl62R1VYINnwX+0O3Ig5eXBDir Uj6uSmqqgGrvG3BgXlcnvdMVM+Byzb/Jv854sTiEHyfPDD9qJvxGiIFXxDxzEwsDvuyuD1dNGOg7k rRmxt/ke6ngZ9hSEvrbZLk7zBfTKlaYX1HwGSAST7t5O7zHK/uge77GB0niXeZeVyzjemfUcEp7IX mSgT3PfdzxRvTJrdPrnA==; 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 1fXdkw-0006iX-I0; Tue, 26 Jun 2018 02:30: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 1fXdkt-0006hb-28 for linux-arm-kernel@lists.infradead.org; Tue, 26 Jun 2018 02:30:56 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9F7836063F; Tue, 26 Jun 2018 02:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529980243; bh=V/yduCNGFEs4lXp5LguZYmUAyiwLT0QapJnHmdzoO9M=; h=From:To:Cc:Subject:Date:From; b=IMafV2/Pt5cNDhMIrfZRtbLjjD/hCrn9sXlbhRp/uEkOg1Mk9XotprVB7yS6PhX8W URYDCuTF2rE0g8I9ArThs92ODxf7hsPWc37HnreyEvEvKCcfs8adt42RqWgWJcsp0k fNNEye45DAjo6SYe0TYkY7Q9z5e1LMAha0Ad308Y= Received: from sgoel1-lnx.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: sgoel@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 596DA606FA; Tue, 26 Jun 2018 02:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529980243; bh=V/yduCNGFEs4lXp5LguZYmUAyiwLT0QapJnHmdzoO9M=; h=From:To:Cc:Subject:Date:From; b=IMafV2/Pt5cNDhMIrfZRtbLjjD/hCrn9sXlbhRp/uEkOg1Mk9XotprVB7yS6PhX8W URYDCuTF2rE0g8I9ArThs92ODxf7hsPWc37HnreyEvEvKCcfs8adt42RqWgWJcsp0k fNNEye45DAjo6SYe0TYkY7Q9z5e1LMAha0Ad308Y= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 596DA606FA 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=sgoel@codeaurora.org From: Sameer Goel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, robin.murphy@arm.com, joro@8bytes.org, nwatters@codeaurora.org, marc.zyngier@arm.com Subject: [PATCH v2 1/1] iommu/arm-smmu-v3: Set GBPA to abort all transactions Date: Mon, 25 Jun 2018 20:30:39 -0600 Message-Id: <1529980239-1950-1-git-send-email-sgoel@codeaurora.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180625_193055_137799_BBB3A9EC X-CRM114-Status: GOOD ( 13.14 ) 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: Sameer Goel 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 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 1d64710..5fedb8e 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2395,6 +2395,20 @@ 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. Do this only if bypass is not set. + */ + if(!bypass || disable_bypass) { + 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;