Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp97055pxb; Tue, 31 Aug 2021 16:05:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn3mUhXi1tHrVeE+AnBCbd4rFUvXW0MvPp2iybrr3cmH4WDGym1QBH0DXGutk+hTvVcwZR X-Received: by 2002:a05:6e02:e53:: with SMTP id l19mr22736455ilk.108.1630451158689; Tue, 31 Aug 2021 16:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630451158; cv=none; d=google.com; s=arc-20160816; b=lpJX4JnxNOizpqxSmf0p/oOyEQXi8VqlN7FHi/0cXuam2f0ntQVG5kVRjnvRZNdxV3 eDuJQus3rfnaVzILLWYffhqWjLF/DCuoAFE5zx4Gr68KMJqT+FDZylfNbQMpWttfT8R4 FsZ3iizhYuWDPMwkcteuFwIp+aUhQS98pMjp2ceqLjQNujWGaKj4wQe8r6JEZBZ1htR9 /tWGob4ffdC53NwYJXSM38YM27BOeJ2pEDXrNAMye61AIz/wPe8dk1NPtszMvbr7MlLr x+bpmUBxUNVSTWGH3XZ6vtxPz6YY0dJcT9t9SwjD1SQtUyPP4WTWvLdBw16b+4t8YFl0 sdDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=ZKGPDcXvR30Iph5GikWZxINg8gRyMFc1HULzJKhTZwM=; b=nDNijtlNsa5qKC6jE7QWP52mP1eSFQsshT8uF72F4o/0rmZfT/9s8lsN/avrxT2srG UoC/DdtIMRnV5d+0q+p5yeg4yNpe02CK+FiTbt1a+s/YYXp+y90c5uK1YFuN0X3YySSC 0A7QuQo2QXQWPYSnKQ12cWenCGV/Nth1AZz0aJVpwl5V3FGf7jjtCU2LOgF2Em0Th653 KVGjD0Onz1nCWQDGsrBZzowcOEDpS3KudKs451bGUseObOmIu6hg3uni0trGYRnzasnF 3gA9Pb7NxCOh0diaGKvO0JlInfvn/6ckgF3GMuy722PrqsZ4j4jFn7LC3xICIh4jiLFJ NUNA== ARC-Authentication-Results: i=1; mx.google.com; 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 b16si21783627ilf.63.2021.08.31.16.05.45; Tue, 31 Aug 2021 16:05:58 -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; 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 S240022AbhHaXF6 (ORCPT + 99 others); Tue, 31 Aug 2021 19:05:58 -0400 Received: from rosenzweig.io ([138.197.143.207]:44804 "EHLO rosenzweig.io" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240560AbhHaXF6 (ORCPT ); Tue, 31 Aug 2021 19:05:58 -0400 Date: Tue, 31 Aug 2021 17:30:18 -0400 From: Alyssa Rosenzweig To: Sven Peter Cc: iommu@lists.linux-foundation.org, Joerg Roedel , Will Deacon , Robin Murphy , Arnd Bergmann , Mohamed Mediouni , Alexander Graf , Hector Martin , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/8] iommu/dma: Disable get_sgtable for granule > PAGE_SIZE Message-ID: References: <20210828153642.19396-1-sven@svenpeter.dev> <20210828153642.19396-4-sven@svenpeter.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210828153642.19396-4-sven@svenpeter.dev> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I use this function for cross-device sharing on the M1 display driver. Arguably this is unsafe but it works on 16k kernels and if you want to test the function on 4k, you know where my code is. On Sat, Aug 28, 2021 at 05:36:37PM +0200, Sven Peter wrote: > Pretend that iommu_dma_get_sgtable is not implemented when > granule > PAGE_SIZE since I can neither test this function right now > nor do I fully understand how it is used. > > Signed-off-by: Sven Peter > --- > drivers/iommu/dma-iommu.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index d6e273ec3de6..64fbd9236820 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -1315,9 +1315,15 @@ static int iommu_dma_get_sgtable(struct device *dev, struct sg_table *sgt, > void *cpu_addr, dma_addr_t dma_addr, size_t size, > unsigned long attrs) > { > + struct iommu_domain *domain = iommu_get_dma_domain(dev); > + struct iommu_dma_cookie *cookie = domain->iova_cookie; > + struct iova_domain *iovad = &cookie->iovad; > struct page *page; > int ret; > > + if (iovad->granule > PAGE_SIZE) > + return -ENXIO; > + > if (IS_ENABLED(CONFIG_DMA_REMAP) && is_vmalloc_addr(cpu_addr)) { > struct page **pages = dma_common_find_pages(cpu_addr); > > -- > 2.25.1 >