Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1592548pxb; Mon, 11 Oct 2021 09:05:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGvEL8ejSeVApRLcM69AUdyhOVO/ia7axyW7V+bUEypFGwCLdTdlYxInmM0C2nFZmcrPst X-Received: by 2002:a17:90a:7e8f:: with SMTP id j15mr32092106pjl.131.1633968344752; Mon, 11 Oct 2021 09:05:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633968344; cv=none; d=google.com; s=arc-20160816; b=jGgxlcBEMN1zPR3BF7ZvV+4AkTH5+uzVcdLliN2llHc1ZZwkyU/2crg/zvx4+xD+gE zeRr1VB0nUVPtpMXjSucI6KWk5O4xWbGsfx1mtvHFMklCC1ouiLURK2JlgUMV7I+AWBq VxYpdR2GR6N8lszTkJlXpvO+rGSFYEjWptqHwQr7Ae9nPgmK6mvkfiyPvqTGFUgKTMni Y9UOcSJpNdQa8vXOIgDpqndhzAkTkqtvJxhPxvwfg0iJo5jp5NAqM7sCq7IoNrCTcvNd siY98yJsi/7U3gEZGlrGzVStumBsF7+/hwXPAXu7Zf8Wrch6FRE4sqU75kX1uF2Izo2P kY1A== 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:dkim-signature; bh=xo81DUxTI79r4bZwrBo156JdbuucSEWl4rjAfXkYrPw=; b=UdLxS7atrEGAQMKJ6xRZQh7Z7DN/qeTvrR8AaN8k0F778UklQuxcR1KBzFanDeYcIm d919jA++UtGnbiXTBIfb2vHmUDbg6A9QEvuVbwp+jth25kqU/0gxDQ0hHGkIGW0MzNtk slVJ+bkOkb6H0x+RfbY4Z0s5VC5FnrSBm2s46iwl013IquhZMoBE6oc0sUJT1EIrTG3u TXeD/7f/M1+3H6c7LTkSAuBEr6hsjt8U65kP0Da7WrXHzk27ie7V4UfodCmYPgIjyYqN VMQUARrQG17EOTDrorvQvqiq0skCgkss/J5EhLT4qzrR2B0HRLAAlWCcBLVbD8JxJaN2 smAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=jXbvDrA8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t20si10637020pgv.302.2021.10.11.09.05.30; Mon, 11 Oct 2021 09:05:44 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=jXbvDrA8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231899AbhJKQFL (ORCPT + 99 others); Mon, 11 Oct 2021 12:05:11 -0400 Received: from mail.skyhub.de ([5.9.137.197]:40342 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232721AbhJKQFK (ORCPT ); Mon, 11 Oct 2021 12:05:10 -0400 Received: from zn.tnic (p200300ec2f08bb0030636ca0dab1dbfc.dip0.t-ipconnect.de [IPv6:2003:ec:2f08:bb00:3063:6ca0:dab1:dbfc]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 89FC81EC03CA; Mon, 11 Oct 2021 18:03:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1633968187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=xo81DUxTI79r4bZwrBo156JdbuucSEWl4rjAfXkYrPw=; b=jXbvDrA8iQpoe7DXvfBYZhvwCTU87omzg8Bld7rWiSSHH+3DkQXyPGhANN+axk4179afsg Hp3k36SZ0Ix4VzpM5yJTkDyr/3K1m6wTFLRGufuptvpP6plCtdveKd9wCMFO4duFWdE5Mx 3Ka/xiEBNWs+uTb3ZHdYZZVJ1qs+wXY= Date: Mon, 11 Oct 2021 18:03:03 +0200 From: Borislav Petkov To: Alex Deucher , Tom Lendacky Cc: Paul Menzel , Thomas Gleixner , Ingo Molnar , X86 ML , Dave Hansen , Andy Lutomirski , Peter Zijlstra , LKML , amd-gfx list Subject: [PATCH -v2] x86/Kconfig: Do not enable AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT automatically Message-ID: References: <96f6dbed-b027-c65e-6888-c0e8630cc006@amd.com> <87d93314-ba3e-464f-d051-84a8de674b06@amd.com> <139ed784-d622-b0d2-3650-736b42e624f0@molgen.mpg.de> <8b21ebbd-f7ca-8af3-5398-8320c6ed6422@molgen.mpg.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ok, here's v2, I've added "however" number 3 below which should summarize Christian's note about coherent and concurrent use of memory by the GPU and CPU, which obviously cannot work with bounce buffers. I'll send it to Linus next week if there are no more complaints. Thx. --- From: Borislav Petkov This Kconfig option was added initially so that memory encryption is enabled by default on machines which support it. However, devices which have DMA masks that are less than the bit position of the encryption bit, aka C-bit, require the use of an IOMMU or the use of SWIOTLB. If the IOMMU is disabled or in passthrough mode, the kernel would switch to SWIOTLB bounce-buffering for those transfers. In order to avoid that, 2cc13bb4f59f ("iommu: Disable passthrough mode when SME is active") disables the default IOMMU passthrough mode so that devices for which the default 256K DMA is insufficient, can use the IOMMU instead. However 2, there are cases where the IOMMU is disabled in the BIOS, etc. (think the usual hardware folk "oops, I dropped the ball there" cases) or a driver doesn't properly use the DMA APIs or a device has a firmware or hardware bug, e.g.: ea68573d408f ("drm/amdgpu: Fail to load on RAVEN if SME is active") However 3, in the above GPU use case, there are APIs like Vulkan and some OpenGL/OpenCL extensions which are under the assumption that user-allocated memory can be passed in to the kernel driver and both the GPU and CPU can do coherent and concurrent access to the same memory. That cannot work with SWIOTLB bounce buffers, of course. So, in order for those devices to function, drop the "default y" for the SME by default active option so that users who want to have SME enabled, will need to either enable it in their config or use "mem_encrypt=on" on the kernel command line. [ tlendacky: Generalize commit message. ] Fixes: 7744ccdbc16f ("x86/mm: Add Secure Memory Encryption (SME) support") Reported-by: Paul Menzel Signed-off-by: Borislav Petkov Cc: Link: https://lkml.kernel.org/r/8bbacd0e-4580-3194-19d2-a0ecad7df09c@molgen.mpg.de --- arch/x86/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index bd70e8a39fbf..d9830e7e1060 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1525,7 +1525,6 @@ config AMD_MEM_ENCRYPT config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT bool "Activate AMD Secure Memory Encryption (SME) by default" - default y depends on AMD_MEM_ENCRYPT help Say yes to have system memory encrypted by default if running on -- 2.29.2 -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette