linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Prakash Gupta <guptap@codeaurora.org>
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 <guptap@codeaurora.org>
Subject: [PATCH] iommu/dma: limit iova free size to unmmaped iova
Date: Thu, 21 May 2020 17:00:04 +0530	[thread overview]
Message-ID: <20200521113004.12438-1-guptap@codeaurora.org> (raw)

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 <guptap@codeaurora.org>

: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,
 
 	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);
 }
 
 static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation


             reply	other threads:[~2020-05-21 11:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 11:30 Prakash Gupta [this message]
2020-05-21 18:49 ` [PATCH] iommu/dma: limit iova free size to unmmaped iova Andrew Morton
2020-05-25 14:28   ` Joerg Roedel
2020-05-21 20:16 ` Robin Murphy
2020-05-22  6:25   ` guptap
2020-05-22  9:24     ` Robin Murphy
2020-05-26  7:19       ` guptap
2020-06-02  9:39         ` guptap
2020-06-02 13:07         ` Robin Murphy
2020-06-03  7:37           ` guptap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200521113004.12438-1-guptap@codeaurora.org \
    --to=guptap@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).