Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1651545ybk; Thu, 21 May 2020 11:51:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2YpuS7KBElERmYjYWdmXugTPPieePf2KasokjAH2KEcRMW/TCBXlwfldlidQ7Rnf1/OB/ X-Received: by 2002:a50:8e56:: with SMTP id 22mr85595edx.268.1590087079737; Thu, 21 May 2020 11:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590087079; cv=none; d=google.com; s=arc-20160816; b=BDUTy5YFAwQUZRNuMhMhr2hsL583gQ9Qi1ZYDV9ekjZL0R1wKKSIi7m13IjhOmZ8PY dta0wJFRq3Gn1bJZAsPHHkdRMJJTvwZg1Cmw7Idzn1ig/jz5Ya199Ne6PVpscSuVQQUh sYY3DdReIiDpSuXx4ljJiiNLg9LVe0dTVPmIR9gBM2Vhl7m/XVFaM98kiGRuexYwN68m zVLG9SOm/zt0+ltR70GfT/wS+jEyCxGtU9A0K7P3G6m4pPSzT+5AkRhkVOpWmYCm7590 zk8sz+FUW4oDh0IwS7AgJl58C1TwPoSeBetEG54Ju/qojGhvGSQGkjePmeKH4MUq2OZ4 jzcw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=pb8LguC9drabCYjH2qHpYeonwPPa3SB33jnx3RwPor8=; b=Vr17wURSH9rhyRWVakqQuFM/xMCnEtN59QIwbglN0Klz6f5ofrqfqtoN6KL1KlVPOQ H+g7DwD/6gfd2CUracSDMpqqtHlOJuLPbKRJHlRLCu3UCpu5a5AvJCru1d6QQvxf/E3T kIm/4+tC85kFyF0KjEYKGuI7hO84Pl4rrzVtNA/vR6R8iogVIKYKO6vBbnhLmLonU3qK 2E8Hv5wCUFbs/xwvQmob1YGWqiCER0ZuA4KMSOPBVK+R71KRhNf+djrkLIpctO9Di6Gd UwhBM2a/UiUOi8678/No/3nT5PT4BjbqskfzKzfAQFX1ZMJCIE4bm80XRowPCxfrObX/ 3LlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QKmNH2Vv; 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 rl17si3718390ejb.241.2020.05.21.11.50.55; Thu, 21 May 2020 11:51:19 -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=pass header.i=@kernel.org header.s=default header.b=QKmNH2Vv; 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 S1729627AbgEUStH (ORCPT + 99 others); Thu, 21 May 2020 14:49:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:45624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729555AbgEUStH (ORCPT ); Thu, 21 May 2020 14:49:07 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C68EB2088E; Thu, 21 May 2020 18:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590086947; bh=MQiydCJAeNQDDg6xvAARulcUycFi5vbJdxdeJlhzfDE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QKmNH2VvPf57Na/zQ2gmA79CWHOkhxYqCWUHTz8GymARd56PJRzMnMs2ugMmGlMSL lWg2YzYv8S365N3SrLlBdxy2pcfoDtWYkKRmnetUqoAv3ba8S13xoQ2kkTYRrFJYT0 oG6yUhQgBGpz9WjQLfD8WBJ0b6BuVT+DUGET+qBQ= Date: Thu, 21 May 2020 11:49:06 -0700 From: Andrew Morton To: Prakash Gupta Cc: mhocko@suse.com, joro@8bytes.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] iommu/dma: limit iova free size to unmmaped iova Message-Id: <20200521114906.2f38fc04d3600d41f3409bd9@linux-foundation.org> In-Reply-To: <20200521113004.12438-1-guptap@codeaurora.org> References: <20200521113004.12438-1-guptap@codeaurora.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 May 2020 17:00:04 +0530 Prakash Gupta wrote: > 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 > I think we need a cc:stable here? > --- 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, I'll assume that Joerg will handle this fix?