Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1025120ybe; Wed, 4 Sep 2019 11:19:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxR51pp+aVbZq8PWH2kbeIuYIGRSn1p7txhhOvL1AilmSpnoYWgRdfyJFyCNGD1TnwoVmPL X-Received: by 2002:a63:c006:: with SMTP id h6mr35952290pgg.290.1567621179737; Wed, 04 Sep 2019 11:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567621179; cv=none; d=google.com; s=arc-20160816; b=JFdMEETSoZ7WxTJ5NeSZk3Sr9Ffn7Yv3VnUShaf5Jyr4smnK7uCbYS/e6skph+jJrZ BnxFYBiyvgJFSh3Y28+wSw9K0qbIfqsoniWp569SAsZGMrlPNOgYj4sLLWTLRXJM1PxH J+qAMfIsBAWGOqXRiya1+GMYSTK4mnemnZ9nitv9rXneVOOOX90GALgwKKX55NtukZWO 8EriXmUygKHjU/q5egTbZLJj8hxHj3iFsjjzjZpJBBL/ViYYR8wGN4gO+Cp7bb2fOYs0 rvDuFC0IM7QCeR+S7ujTaSUsNibZ0CobWb05/CDoMldvK96U3R72EDklh+Wane38GyHw lXzA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=70W19jIN2LJOmGWBOYHdgv98azul1MQJ6JSNBQedF0A=; b=O4aUFYeMUq/fISYISUjp5OBFw2zpeVg+WvXMdbC0+AbVql8WumG57mXQXrcrS06xhb 9mc2Iu0YWGTcIHn53qbxtiyJRqZgJ84hAl9R+uU/sp6sLxs5gpg+cQMblLfPccLCErzG gfVuwKS4gTe0BCyP6prhxBvrMd/g6shd2vXwOMAR46J7/AVpqXki+8OFmiqLJMm/lqsi 81FQHa1sssEavYreeO/JM58QGo++QbMCI4ArcMgDtfBSCdbRiFLYIXk/mwPiKsArb3dT yfta7Qwa0W5+O8zCZUkCRtTgwaj2Jvkirk9gz+rfJarFusxpGDlMwEsusEjw4fUnPEkQ 1wYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IvOf68s1; 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 q4si2792997pjv.74.2019.09.04.11.19.23; Wed, 04 Sep 2019 11:19:39 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IvOf68s1; 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 S2390043AbfIDSQq (ORCPT + 99 others); Wed, 4 Sep 2019 14:16:46 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:60428 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389740AbfIDSQn (ORCPT ); Wed, 4 Sep 2019 14:16:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=70W19jIN2LJOmGWBOYHdgv98azul1MQJ6JSNBQedF0A=; b=IvOf68s1KsEZhP8BdHB0vPABFG I0/DV8vkErG304FQTxpK9vNlSHc4LVwozJKPBNGhkwwv49juTiP/E7bryCZFe5Ld8X3KpbGt51Uvz 5D/XBf17bbui6QPJFq9u7+IxK04gNrdhIdqDIK/VT6s5N69A7zrmCK8398TolXaYFaTHmWd1dpfsQ Krx3QaX5/A/1yMSCaDXPYH5TdU01dtwt5LKwZQCgpWgk7P1IAoDAqu7iGZlhI9foxwVU9V8FGWgsx 770KbSksx64Il7mUJcijlfvshrDcweI0o8GBFGK88Hl2reYhkWQ2urFyKk7bmFvRasbvZHIzadbeB guiFGW5Q==; Received: from hch by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1i5Zpd-0002Rq-6j; Wed, 04 Sep 2019 18:16:37 +0000 Date: Wed, 4 Sep 2019 11:16:37 -0700 From: Christoph Hellwig To: Thomas =?iso-8859-1?Q?Hellstr=F6m_=28VMware=29?= Cc: Andy Lutomirski , Andy Lutomirski , Dave Hansen , Daniel Vetter , dri-devel , pv-drivers@vmware.com, VMware Graphics , Linux Kernel Mailing List , Tom Lendacky , Thomas Hellstrom , Peter Zijlstra , Dave Hansen , Heiko Carstens , Christian Borntraeger , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Thomas Gleixner , Christian =?iso-8859-1?Q?K=F6nig?= Subject: Re: [PATCH v2 3/4] drm/ttm, drm/vmwgfx: Correctly support support AMD memory encryption Message-ID: <20190904181637.GA26475@infradead.org> References: <6d0fafcc-b596-481b-7b22-1f26f0c02c5c@intel.com> <7fa3b178-b9b4-2df9-1eee-54e24d48342e@intel.com> <44b094c8-63fe-d9e5-1bf4-7da0788caccf@shipmail.org> <6d122d62-9c96-4c29-8d06-02f7134e5e2a@shipmail.org> <3393108b-c7e3-c9be-b65b-5860c15ca228@shipmail.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3393108b-c7e3-c9be-b65b-5860c15ca228@shipmail.org> User-Agent: Mutt/1.11.4 (2019-03-13) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 04, 2019 at 08:49:03AM +0200, Thomas Hellström (VMware) wrote: > For device DMA address purposes, the encryption status is encoded in the dma > address by the dma layer in phys_to_dma(). > > > > There doesn’t seem to be any real funny business in dma_mmap_attrs() or dma_common_mmap(). > > No, from what I can tell the call in these functions to dma_pgprot() > generates an incorrect page protection since it doesn't take unencrypted > coherent memory into account. I don't think anybody has used these functions > yet with SEV. Yes, I think dma_pgprot is not correct for SEV. Right now that function isn't used much on x86, it had more grave bugs up to a few -rcs ago.. > > Would it make sense to add a vmf_insert_dma_page() to directly do exactly what you’re trying to do? > > Yes, but as a longer term solution I would prefer a general dma_pgprot() > exported, so that we could, in a dma-compliant way, use coherent pages with > other apis, like kmap_atomic_prot() and vmap(). That is, basically split > coherent page allocation in two steps: Allocation and mapping. The thing is that dma_pgprot is of no help for you at all, as the DMA API hides the page from you entirely. In fact we do have backends that do not even have a page backing. But I think we can have a vmf_insert_page equivalent that does the right thing behind your back for the varius different implementation (contiguous page(s) in the kernel lineary, contiguous page(s) with a vmap/ioremap remapping in various flavours, non-contigous pages(s) with a vmap remapping, and deeply magic firmware populated pools (well, except maybe for the last, but at least we can fail gracefully there)).