Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1336709ybk; Thu, 21 May 2020 04:33:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb90HyhdAETCWSg2Qi1FP40UXbIa0hNPajtP5lxEmYEQI5pomLmgwcmQdxXuTM81y+sLgj X-Received: by 2002:a17:906:1804:: with SMTP id v4mr2995917eje.104.1590060804273; Thu, 21 May 2020 04:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590060804; cv=none; d=google.com; s=arc-20160816; b=cfw0H+/8hqmD4nmw1aKD6ChE4++kcmpjkRx0XHWqGbHeqoT5bhUCwTc5tR/YMjOFqh bI+w8ePuzP+OeQ2ZDQSj7L9rn7Z+hGnA1qKebYRm8oUqsvksTylYUosx2lwhAlHCsw7Y QzeTrlPpm+qj8KSnXzED1qw4IMdhCHJnSvYJB00M8P8ZD5Cybee5EI72BGFkeJN8uaEk kuzglJ/O4bmXyaZwB6VnTTnJUJ2/VCSpBhjtcV7+hSfSoX9eLmFucRrjvUdJHGmEsaCl Zp3ZOlRtvyB2PzV7Z5SWRpmfOniAhVNVOJq9qHYpa0+0e5pJPe1FqwazuPLyKVaKJ0xA YaCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dmarc-filter:dkim-signature; bh=lhRGU6l23pWyhwgP/bWEorni345nvViGnvyOWBGS/6U=; b=HQYAaIb+RUqBOlu8IF5bd/VprztoAfVwOPRsvhuFS1yoDl/Vj9hQcatkJh5EGER4EZ 0ULrdFFscwXUll6u3bMNoKpPdM0NrVk7zPOzu728Xcv1a37qs9BIUrEViKWW+2n3j1IA Nfvw7CFiHDH/tUiOtcmG1Pz7CkSnXZvcTbPQjvbx/Cb1HzxVHnjdcFjVVTyyGKbfA/Hb 6mZcg7mPz939clw/XNFfzCsYUWTvmCzmahteeCvUjJ3XuBMJmAtwTmWEGegW/43Rvd/9 YQmQ+XWETdNoO5fyaYNx5mwjYQdRFWcAZ6YiGXNL1mjGZcHKPKnrqfNE2CZMkLxdDa2n K9PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=ihcmFw3Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t26si2666803edf.183.2020.05.21.04.32.58; Thu, 21 May 2020 04:33:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=ihcmFw3Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729050AbgEULal (ORCPT + 99 others); Thu, 21 May 2020 07:30:41 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:21597 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728348AbgEULal (ORCPT ); Thu, 21 May 2020 07:30:41 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1590060640; h=Content-Transfer-Encoding: MIME-Version: Message-Id: Date: Subject: Cc: To: From: Sender; bh=lhRGU6l23pWyhwgP/bWEorni345nvViGnvyOWBGS/6U=; b=ihcmFw3QJZu/H8uGaxbjrsBDwTF+YrOLx/rAou3WanQUUL/UmuNxupbXXFTmmcrATmXivp9I eY7Q5s+IKkHLgqZg00M+h+NSKzs06yinNhUJc+c4kXOiEcJzHepWQZdnG6JJbonfUo8rs9Qo 0Fi4PkGO3e+DQ82CMKfUVkbtoxs= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd 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.7f542eab6148-smtp-out-n01; Thu, 21 May 2020 11:30:17 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 6C227C433C9; Thu, 21 May 2020 11:30:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 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: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, 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