Received: by 10.213.65.68 with SMTP id h4csp341562imn; Tue, 13 Mar 2018 06:13:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELsKcNbqXPot2W4aXXJKv0OlbNG95mdVdoKL2SVDkktXGobIJygAbvHJiacOT6Os0rJ2bs7C X-Received: by 10.99.47.132 with SMTP id v126mr505050pgv.42.1520946788415; Tue, 13 Mar 2018 06:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520946788; cv=none; d=google.com; s=arc-20160816; b=bJG5B3WS0DX3mKTZno0qyJctGHADfu8TySNRwDoszyfjupHkriKDxUu1AKABYdXkDm 9lOSsEsFERaVckPG6CRD0Ol1k5EjEI8h2gqSzv+BIrssjk+qFgoxpVjalhnPbaitp51o yWzsZeiI0/81SF3l5KIId+Ypi3l7NOGlEzqLMffy5+svi8EfyyYtIA3oFZQIQBdBUN9d LIrChK3SRib9ElaqLApIeGoBZgVBixt87eDKcEGNutNY9IlCVMKyCg0mUgKmkzfgp+36 Ua4agCWWZAPCEKlBFjW0/s3K6PCV1ADZd+jhaY+oadxeZe8F89ib41pM+Z7qeicbYAWz NdOg== 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:arc-authentication-results; bh=okAqbTHHlKD1WTdEMlteb2RmfYP9Tb4yQrkXDThDP+o=; b=z9iI53dAxCYx9w91tCZuTXG2oTmq3syP68Qds7j65PAeuWR59UrAtWEUtXp3wzKm6s fb0gYSb/HqwOPOZ4pdzEK5qJS6nVBBBBdve9XUOQsYevjhQk1OoZR+59wkJodYEt+uCg egkGxNxwxhTTm3j47aijnoE03sBXbJOqw6eUehpJ1JjqK5H+A1VaEmyxvOMv9GjdxNP1 5JX+lcpeF34hSLcWoI2sBdGtyYRAdA/CBiEBQOE5iMNFg+MD97j57TVCnHt5LBGB6W+M eQpUYwmv1vQpCXeDKaNR05x3AJt7yzXPXHhxHur7wNZ6/TZ2b9jFuzP7hGgfKhXjxpZf PZjg== 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 x1si110682pgp.89.2018.03.13.06.12.53; Tue, 13 Mar 2018 06:13:08 -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 S1752716AbeCMNK0 (ORCPT + 99 others); Tue, 13 Mar 2018 09:10:26 -0400 Received: from verein.lst.de ([213.95.11.211]:57831 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932618AbeCMNKH (ORCPT ); Tue, 13 Mar 2018 09:10:07 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 1F3C47FDE1; Tue, 13 Mar 2018 14:10:05 +0100 (CET) Date: Tue, 13 Mar 2018 14:10:05 +0100 From: Christoph Hellwig To: Tom Lendacky Cc: Christoph Hellwig , x86@kernel.org, Konrad Rzeszutek Wilk , David Woodhouse , Muli Ben-Yehuda , Jon Mason , Joerg Roedel , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 11/13] dma-direct: handle the memory encryption bit in common code Message-ID: <20180313131005.GA6260@lst.de> References: <20180305174655.9878-1-hch@lst.de> <20180305174655.9878-12-hch@lst.de> <114e27be-5814-4258-4985-af08763c8a74@amd.com> <0c9d3e4a-8407-282a-73eb-21d28047e0e3@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0c9d3e4a-8407-282a-73eb-21d28047e0e3@amd.com> 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 Mon, Mar 12, 2018 at 02:48:51PM -0500, Tom Lendacky wrote: > Ok, I found one issue that allows this to work when the IOMMU isn't > enabled (see below). Thanks, folded! > But the bigger issue is when the IOMMU is enabled. The IOMMU code uses > a common mapping routine to create the I/O page tables. This routine > assumes that all memory being mapped is encrypted and therefore sets the > encryption bit in the I/O page tables. With this patch, the call to > dma_alloc_direct() now returns un-encrypted memory which results in an > encryption mis-match. I think keeping dma_alloc_direct() as it was prior > to this patch is the way to go. It allows SME DMA allocations to remain > encrypted and avoids added complexity in the amd_iommu.c file. This > would mean that SEV would still have special DMA operations (so that the > alloc/free can change the memory to un-encrypted). > > What do you think? In terms of logic you are right. I still don't like keeping a just slightly tweaked version of dma_alloc_direct around just for this, it will be perpetually out of sync in terms of features and bug fixes. What do you think about this version that does the decision at runtime: http://git.infradead.org/users/hch/misc.git/commitdiff/b89f24dc856595dc7610d672bf077195ab0dabf4 The full tree is available here for testing: git://git.infradead.org/users/hch/misc.git dma-direct-x86