Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4575273yba; Tue, 9 Apr 2019 23:49:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyI/hwRd/tCBc+hnCWzu533F65evzCHO0dhmYRV3bllDF5SliAjJm7FkUy/Us/6Ss1I1FMy X-Received: by 2002:a17:902:2bc9:: with SMTP id l67mr26134203plb.237.1554878997538; Tue, 09 Apr 2019 23:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554878997; cv=none; d=google.com; s=arc-20160816; b=WWsOY05JKfothegGD52F79Mr+fJqBFamLSTbn48tmVoTEbmlDaGBIEwtpZsSikIgLl KlZCQUuKLF4GrAGRQBoIpuiHurXxUf+ZUusnZutCGxzsRqH3xe5viVj+vRxR9kzHrhxb XrtFs1gJzVuVCZJAQmhnsKNkvNyhkanL9CcmQZWIgeWVuKNvY0syTdt0q3tpgS10p7zS dZfhQ6qXY5m6Fs6S8GH9di3xIn0+xvbrazD4L/5/lqaHT4R6HQ2kCAH8/pfV9qeqgnan ePBkrMNj6/0HsaHcL9JQVSJj5DIjlCCWeLEnVZFl4D0jeREL3j7vAtYE6xx+sjB4yJK1 ZGSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZUh7BJzt8zVrFErw66vUDTwNTfak2xTDOfs/9LhS6gk=; b=KWjDtnZ3UczCOmkBBBDEzFkdJB+VtQ3Lgzah/mhe66px1rKUJ/RjsnM70mOns/aFti MJ6lpLdn7/Z6x8+jHV7+PTYbv+q3KxJT1nVeiSalYu6mk6cj8hV6faMAl+phLS8zDUQe LBapej+HqLX/jLsxieXIhpbJef28TErEYF2A40iX2jfVMhBxmVYM+o0JLXCwihKIRQEw 3tR4YpFyjXGPCAVd5XU+EGioufloPxcRX62TNse2TYvhwIUt6upnUWBwTiJVgXajk8Dz 2s/LR/XwSQ0XYPTCyJZhql1CHfBGjJ1NL6o6xeJQouZ6T4zxNxqbnB0cnvEA0SZFURn0 1jqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si14766991pfb.251.2019.04.09.23.49.42; Tue, 09 Apr 2019 23:49:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727464AbfDJGoL (ORCPT + 99 others); Wed, 10 Apr 2019 02:44:11 -0400 Received: from verein.lst.de ([213.95.11.211]:55175 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbfDJGoL (ORCPT ); Wed, 10 Apr 2019 02:44:11 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 8DE4C68B02; Wed, 10 Apr 2019 08:43:59 +0200 (CEST) Date: Wed, 10 Apr 2019 08:43:59 +0200 From: "hch@lst.de" To: Thomas Hellstrom Cc: "hch@lst.de" , "torvalds@linux-foundation.org" , "linux-kernel@vger.kernel.org" , Deepak Singh Rawat , "iommu@lists.linux-foundation.org" Subject: Re: revert dma direct internals abuse Message-ID: <20190410064359.GC5543@lst.de> References: <20190408105525.5493-1-hch@lst.de> <7d5f35da4a6b58639519f0764c7edbfe4dd1ba02.camel@vmware.com> <20190409095740.GE6827@lst.de> <5f0837ffc135560c764c38849eead40269cebb48.camel@vmware.com> <20190409133157.GA10876@lst.de> <466e658c73607fca5112d718972e87c0b78653ad.camel@vmware.com> <20190409152538.GA12816@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 09, 2019 at 05:24:48PM +0000, Thomas Hellstrom wrote: > > Note that this only affects external, untrusted devices. But that > > may include eGPU, > > What about discrete graphics cards, like Radeon and Nvidia? Who gets to > determine what's trusted? Based on firmware tables. discrete graphics would not qualify unless they are attached through thunderbolt bridges or external PCIe ports. > GPU libraries traditionally have been taking care of the CPU mapping > caching modes since the first AGP drivers. GPU MMU ptes commonly > support various caching options and pages are changing caching mode > dynamically. > So even if the DMA layer needs to do the remapping, couldn't we do that > on-demand when needed with a simple interface? The problem is that there is no "simple" interface as the details depend on the architecture. We have the following base variants to create coherent memory: 1) do nothing - this works on x86-like platforms where I/O is always coherent 2) use a special kernel segment, after flushing the caches for the normal segment, done on platforms like mips that have this special segment 3) remap the existing kernel direct mapping, after flushing the caches, done by openrisc and in some cases arm32 4) create a new mapping in vmap or ioremap space after flushing the caches - done by most architectures with an MMU and non-coherent devices 5) use a special pool of uncached memory set aside by the hardware or firmware - done by most architectures without an MMU but with non-coherent devices So that is just five major variants with a lot of details on how it is done in practice. Add to that that many of the operations are fairly expensive and need to be pre-loaded. > > That being said: your driver already uses the dma coherent API > > under various circumstances, so you already have the above issues. > > Yes, but they are hidden behind driver options. We can't have someone > upgrade their kernel and suddenly things don't work anymore, That said, > I think the SWIOTLB case is rare enough for the below solution to be > acceptable, although the TTM check for the coherent page pool being > available still needs to remain. So can you please respin a version acceptable to you and submit it for 5.1 ASAP? Otherwise I'll need to move ahead with the simple revert.