From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2nam01on0046.outbound.protection.outlook.com ([104.47.34.46]:29450 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752695AbcKSSuf (ORCPT ); Sat, 19 Nov 2016 13:50:35 -0500 Subject: Re: [RFC PATCH v3 12/20] x86: Decrypt trampoline area if memory encryption is active References: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> <20161110003708.3280.29934.stgit@tlendack-t1.amdoffice.net> <20161117180913.ha5h4bfgrr5u6ccg@pd.tnic> From: Tom Lendacky Message-ID: Date: Sat, 19 Nov 2016 12:50:24 -0600 MIME-Version: 1.0 In-Reply-To: <20161117180913.ha5h4bfgrr5u6ccg@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: <20161119185024.Du6UvPv1KQ0geEzedR4s5L6ml2yawr-m_PLmXYAkrC8@z> On 11/17/2016 12:09 PM, Borislav Petkov wrote: > On Wed, Nov 09, 2016 at 06:37:08PM -0600, Tom Lendacky wrote: >> When Secure Memory Encryption is enabled, the trampoline area must not >> be encrypted. A CPU running in real mode will not be able to decrypt >> memory that has been encrypted because it will not be able to use addresses >> with the memory encryption mask. >> >> Signed-off-by: Tom Lendacky >> --- >> arch/x86/realmode/init.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c >> index 5db706f1..44ed32a 100644 >> --- a/arch/x86/realmode/init.c >> +++ b/arch/x86/realmode/init.c >> @@ -6,6 +6,7 @@ >> #include >> #include >> #include >> +#include >> >> struct real_mode_header *real_mode_header; >> u32 *trampoline_cr4_features; >> @@ -130,6 +131,14 @@ static void __init set_real_mode_permissions(void) >> unsigned long text_start = >> (unsigned long) __va(real_mode_header->text_start); >> >> + /* >> + * If memory encryption is active, the trampoline area will need to >> + * be in un-encrypted memory in order to bring up other processors >> + * successfully. >> + */ >> + sme_early_mem_dec(__pa(base), size); >> + sme_set_mem_unenc(base, size); > > We're still unsure about the non-encrypted state: dec vs unenc. Please > unify those for ease of use, code reading, etc etc. > > sme_early_decrypt(__pa(base), size); > sme_mark_decrypted(base, size); > > or similar looks much more readable and understandable to me. Yeah, I'll go through and change everything so that the implication or action is expressed better. Thanks, Tom >