From mboxrd@z Thu Jan 1 00:00:00 1970 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.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 288C3C433DF for ; Thu, 21 May 2020 11:30:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D515F207D3 for ; Thu, 21 May 2020 11:30:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="P2qpzIcF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D515F207D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 69AE280008; Thu, 21 May 2020 07:30:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64B5580007; Thu, 21 May 2020 07:30:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53A4280008; Thu, 21 May 2020 07:30:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 3A0E080007 for ; Thu, 21 May 2020 07:30:39 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EA63E2C12 for ; Thu, 21 May 2020 11:30:38 +0000 (UTC) X-FDA: 76840508556.12.seat82_5c5e8a2f4963f X-HE-Tag: seat82_5c5e8a2f4963f X-Filterd-Recvd-Size: 3571 Received: from mail27.static.mailgun.info (mail27.static.mailgun.info [104.130.122.27]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Thu, 21 May 2020 11:30:34 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1590060638; h=Content-Transfer-Encoding: MIME-Version: Message-Id: Date: Subject: Cc: To: From: Sender; bh=lhRGU6l23pWyhwgP/bWEorni345nvViGnvyOWBGS/6U=; b=P2qpzIcFYYwziizDD5ZohnAfr67OQhud8BeXO8fx4zTMWOaOrjJQcKlKiyDgURaE6l7fH3yQ j1SPYnEkWCoDxeKb7iDnunA9upAlGlpq7JWW31Ggp2l1wWncsI0Gq82MCqo0B+nAKrLhhRrd 8kvInladXQL15tR1AuTLVxdHDAg= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyIwY2Q3OCIsICJsaW51eC1tbUBrdmFjay5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5ec66649.7f4f73a81df8-smtp-out-n01; Thu, 21 May 2020 11:30:17 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 5730BC433C8; Thu, 21 May 2020 11:30:17 +0000 (UTC) Received: from guptap1-linux.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: guptap) by smtp.codeaurora.org (Postfix) with ESMTPSA id 58119C433C6; Thu, 21 May 2020 11:30:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 58119C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=guptap@codeaurora.org From: Prakash Gupta To: akpm@linux-foundation.org, mhocko@suse.com, joro@8bytes.org Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Prakash Gupta Subject: [PATCH] iommu/dma: limit iova free size to unmmaped iova Date: Thu, 21 May 2020 17:00:04 +0530 Message-Id: <20200521113004.12438-1-guptap@codeaurora.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Limit the iova size while freeing based on unmapped size. In absence of this even with unmap failure, invalid iova is pushed to iova rcache and subsequently can cause panic while rcache magazine is freed. Signed-off-by: Prakash Gupta :100644 100644 4959f5df21bd 098f7d377e04 M drivers/iommu/dma-iommu.c diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 4959f5df21bd..098f7d377e04 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -472,7 +472,8 @@ static void __iommu_dma_unmap(struct device *dev, dma= _addr_t dma_addr, =20 if (!cookie->fq_domain) iommu_tlb_sync(domain, &iotlb_gather); - iommu_dma_free_iova(cookie, dma_addr, size); + if (unmapped) + iommu_dma_free_iova(cookie, dma_addr, unmapped); } =20 static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys, --=20 QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation