Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10435161ybi; Thu, 11 Jul 2019 05:18:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBkGid0e9bjM8dItXUynFd5lHQyVoyubPcHUlWl6U4SrnbbIxqvXT9u8zLW3jEePgzi509 X-Received: by 2002:a63:a41:: with SMTP id z1mr4138579pgk.290.1562847484198; Thu, 11 Jul 2019 05:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562847484; cv=none; d=google.com; s=arc-20160816; b=Kf6ecpMCj1OHdRvdu2+rO2B9+SQzqJHI3x2MqsPK7sqZvCIlPuBHtL2j9RENaiNQKL XCQA3wr+6po0chhYuS2KaCKQN7u2slmvF8xsb2wj9wNiSGdWL0vg4lBOEFt+BwumFmI9 RDz2BINFHKlkr8xwMP0L11S5lHrUxzhDTTt9xDOkPBDcGHvxITj2qRc3xR4J6BpxAc2b Tf7RWQJLZWwLbKrVVSLDT7rRCNe41Igm0hRGEmTLEWRfVF0ldYDehSbVolaZUGlUaBJv BsojY0sRC1jCncT6gTvSQrYRwU7ppJX5P3RHI0h6sL2Kl9ME8ep6A/Gep+OzJzcSLUrr ERDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=SCYSaVqIK6jtODiVRMZJeRuJDHgOsRTgzIQwYDwnxEA=; b=ZdnCEXyevYfn+9zukWejJFsC7YKlXNgZcAGVNeyqRSE43EaVV58UlsnSbWw8e3NEcA 1dENWEq0Qm6XPO6bw59BQAX4H7aIkTARMQ+D27vVs/4dxqbJhpYqpELZc24m+ofU4TQW owquTmyMfRk7/r9QZZZQ0uAuW8ndJHFiEkSOghKMpw8hY37EZO3EZBMEEwzrXTkBVz4a q28IwjzIvuSNCUbcHJsyOKTPgunAJIrWx2NF/GJHPexzboAIM49Iut4Npgl5iVUZmcGE 0sfPVyLzhr42jNeeAL0gGHbsTI4lwxjJiVfJbUA7dLqqWarug9cuE8hYKLlGc92kpYEi VXEw== 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 p33si2310595pgb.0.2019.07.11.05.17.41; Thu, 11 Jul 2019 05:18:04 -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 S1728672AbfGKMRC (ORCPT + 99 others); Thu, 11 Jul 2019 08:17:02 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:49771 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbfGKMRC (ORCPT ); Thu, 11 Jul 2019 08:17:02 -0400 Received: from [5.158.153.55] (helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hlY0M-00067N-Ax; Thu, 11 Jul 2019 14:16:54 +0200 Date: Thu, 11 Jul 2019 14:16:48 +0200 (CEST) From: Thomas Gleixner To: "Lendacky, Thomas" cc: "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Lianbo Jiang Subject: Re: [PATCH] dma-direct: Force unencrypted DMA under SME for certain DMA masks In-Reply-To: <10b83d9ff31bca88e94da2ff34e30619eb396078.1562785123.git.thomas.lendacky@amd.com> Message-ID: References: <10b83d9ff31bca88e94da2ff34e30619eb396078.1562785123.git.thomas.lendacky@amd.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 10 Jul 2019, Lendacky, Thomas wrote: > From: Tom Lendacky > > If a device doesn't support DMA to a physical address that includes the > encryption bit (currently bit 47, so 48-bit DMA), then the DMA must > occur to unencrypted memory. SWIOTLB is used to satisfy that requirement > if an IOMMU is not active (enabled or configured in passthrough mode). > > However, commit fafadcd16595 ("swiotlb: don't dip into swiotlb pool for > coherent allocations") modified the coherent allocation support in SWIOTLB > to use the DMA direct coherent allocation support. When an IOMMU is not > active, this resulted in dma_alloc_coherent() failing for devices that > didn't support DMA addresses that included the encryption bit. > > Addressing this requires changes to the force_dma_unencrypted() function > in kernel/dma/direct.c. Since the function is now non-trivial and SME/SEV > specific, update the DMA direct support to add an arch override for the > force_dma_unencrypted() function. The arch override is selected when > CONFIG_AMD_MEM_ENCRYPT is set. The arch override function resides in the > arch/x86/mm/mem_encrypt.c file and forces unencrypted DMA when either SEV > is active or SME is active and the device does not support DMA to physical > addresses that include the encryption bit. > > Fixes: fafadcd16595 ("swiotlb: don't dip into swiotlb pool for coherent allocations") > Suggested-by: Christoph Hellwig > Signed-off-by: Tom Lendacky > --- > > Based on tree git://git.infradead.org/users/hch/dma-mapping.git for-next > > arch/x86/Kconfig | 1 + For the x86 parts: Acked-by: Thomas Gleixner