From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Lendacky Subject: Re: [RFC PATCH v3 20/20] x86: Add support to make use of Secure Memory Encryption Date: Tue, 29 Nov 2016 12:48:17 -0600 Message-ID: <4cffdd71-dcc6-35e9-2654-e39067a525a8@amd.com> References: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> <20161110003838.3280.23327.stgit@tlendack-t1.amdoffice.net> <20161126204703.wlcd6cw7dxzvpxyc@pd.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20161126204703.wlcd6cw7dxzvpxyc@pd.tnic> Sender: owner-linux-mm@kvack.org To: Borislav Petkov Cc: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Rik van Riel , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Ingo Molnar , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Thomas Gleixner , Dmitry Vyukov List-Id: linux-arch.vger.kernel.org On 11/26/2016 2:47 PM, Borislav Petkov wrote: > On Wed, Nov 09, 2016 at 06:38:38PM -0600, Tom Lendacky wrote: >> This patch adds the support to check if SME has been enabled and if the >> mem_encrypt=on command line option is set. If both of these conditions >> are true, then the encryption mask is set and the kernel is encrypted >> "in place." >> >> Signed-off-by: Tom Lendacky >> --- >> arch/x86/kernel/head_64.S | 1 + >> arch/x86/kernel/mem_encrypt_init.c | 60 +++++++++++++++++++++++++++++++++++- >> arch/x86/mm/mem_encrypt.c | 2 + >> 3 files changed, 62 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S >> index e8a7272..c225433 100644 >> --- a/arch/x86/kernel/head_64.S >> +++ b/arch/x86/kernel/head_64.S >> @@ -100,6 +100,7 @@ startup_64: >> * to include it in the page table fixups. >> */ >> push %rsi >> + movq %rsi, %rdi >> call sme_enable >> pop %rsi >> movq %rax, %r12 >> diff --git a/arch/x86/kernel/mem_encrypt_init.c b/arch/x86/kernel/mem_encrypt_init.c >> index 7bdd159..c94ceb8 100644 >> --- a/arch/x86/kernel/mem_encrypt_init.c >> +++ b/arch/x86/kernel/mem_encrypt_init.c >> @@ -16,9 +16,14 @@ >> #include >> >> #include >> +#include >> +#include >> +#include >> >> #ifdef CONFIG_AMD_MEM_ENCRYPT >> >> +static char sme_cmdline_arg[] __initdata = "mem_encrypt=on"; > > One more thing: just like we're adding an =on switch, we'd need an =off > switch in case something's wrong with the SME code. IOW, if a user > supplies "mem_encrypt=off", we do not encrypt. Well, we can document "off", but if the exact string "mem_encrypt=on" isn't specified on the command line then the encryption won't occur. The cmdline_find_option_bool() function looks for the exact string and isn't interpreting the value on the right side of the equal sign. So omitting mem_encrypt=on or using mem_encrypt=off is the same. Thanks, Tom > > Thanks. > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam01on0076.outbound.protection.outlook.com ([104.47.34.76]:57066 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751566AbcK2Ss1 (ORCPT ); Tue, 29 Nov 2016 13:48:27 -0500 Subject: Re: [RFC PATCH v3 20/20] x86: Add support to make use of Secure Memory Encryption References: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> <20161110003838.3280.23327.stgit@tlendack-t1.amdoffice.net> <20161126204703.wlcd6cw7dxzvpxyc@pd.tnic> From: Tom Lendacky Message-ID: <4cffdd71-dcc6-35e9-2654-e39067a525a8@amd.com> Date: Tue, 29 Nov 2016 12:48:17 -0600 MIME-Version: 1.0 In-Reply-To: <20161126204703.wlcd6cw7dxzvpxyc@pd.tnic> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Borislav Petkov Cc: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Rik van Riel , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Ingo Molnar , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Thomas Gleixner , Dmitry Vyukov Message-ID: <20161129184817.5RgDoTWER6NBuM5nIexZv8PHraunU4sxOSeVU6bpbko@z> On 11/26/2016 2:47 PM, Borislav Petkov wrote: > On Wed, Nov 09, 2016 at 06:38:38PM -0600, Tom Lendacky wrote: >> This patch adds the support to check if SME has been enabled and if the >> mem_encrypt=on command line option is set. If both of these conditions >> are true, then the encryption mask is set and the kernel is encrypted >> "in place." >> >> Signed-off-by: Tom Lendacky >> --- >> arch/x86/kernel/head_64.S | 1 + >> arch/x86/kernel/mem_encrypt_init.c | 60 +++++++++++++++++++++++++++++++++++- >> arch/x86/mm/mem_encrypt.c | 2 + >> 3 files changed, 62 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S >> index e8a7272..c225433 100644 >> --- a/arch/x86/kernel/head_64.S >> +++ b/arch/x86/kernel/head_64.S >> @@ -100,6 +100,7 @@ startup_64: >> * to include it in the page table fixups. >> */ >> push %rsi >> + movq %rsi, %rdi >> call sme_enable >> pop %rsi >> movq %rax, %r12 >> diff --git a/arch/x86/kernel/mem_encrypt_init.c b/arch/x86/kernel/mem_encrypt_init.c >> index 7bdd159..c94ceb8 100644 >> --- a/arch/x86/kernel/mem_encrypt_init.c >> +++ b/arch/x86/kernel/mem_encrypt_init.c >> @@ -16,9 +16,14 @@ >> #include >> >> #include >> +#include >> +#include >> +#include >> >> #ifdef CONFIG_AMD_MEM_ENCRYPT >> >> +static char sme_cmdline_arg[] __initdata = "mem_encrypt=on"; > > One more thing: just like we're adding an =on switch, we'd need an =off > switch in case something's wrong with the SME code. IOW, if a user > supplies "mem_encrypt=off", we do not encrypt. Well, we can document "off", but if the exact string "mem_encrypt=on" isn't specified on the command line then the encryption won't occur. The cmdline_find_option_bool() function looks for the exact string and isn't interpreting the value on the right side of the equal sign. So omitting mem_encrypt=on or using mem_encrypt=off is the same. Thanks, Tom > > Thanks. >