From mboxrd@z Thu Jan 1 00:00:00 1970 From: Borislav Petkov Subject: Re: [Part1 PATCH v4 14/17] x86: Add support for changing memory encryption attribute in early boot Date: Sun, 17 Sep 2017 17:25:46 +0200 Message-ID: <20170917152546.GL4733@nazgul.tnic> References: <20170916123418.37807-1-brijesh.singh@amd.com> <20170916123418.37807-15-brijesh.singh@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Tom Lendacky To: Brijesh Singh Return-path: Content-Disposition: inline In-Reply-To: <20170916123418.37807-15-brijesh.singh@amd.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Sat, Sep 16, 2017 at 07:34:15AM -0500, Brijesh Singh wrote: > Some KVM-specific custom MSRs share the guest physical address with the > hypervisor in early boot. When SEV is active, the shared physical address > must be mapped with memory encryption attribute cleared so that both > hypervisor and guest can access the data. > > Add APIs to change the memory encryption attribute in early boot code. > > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: Borislav Petkov > Cc: x86@kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: Tom Lendacky > Signed-off-by: Brijesh Singh > --- > arch/x86/include/asm/mem_encrypt.h | 17 ++++++ > arch/x86/mm/mem_encrypt.c | 121 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 138 insertions(+) > > diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h > index 2b024741bce9..21b9d8fc8293 100644 > --- a/arch/x86/include/asm/mem_encrypt.h > +++ b/arch/x86/include/asm/mem_encrypt.h > @@ -42,6 +42,11 @@ void __init sme_early_init(void); > void __init sme_encrypt_kernel(void); > void __init sme_enable(struct boot_params *bp); > > +int __init early_set_memory_decrypted(resource_size_t paddr, > + unsigned long size); > +int __init early_set_memory_encrypted(resource_size_t paddr, > + unsigned long size); > + Let those stick out on a single line. > /* Architecture __weak replacement functions */ > void __init mem_encrypt_init(void); > > @@ -70,6 +75,18 @@ static inline void __init sme_enable(struct boot_params *bp) { } > static inline bool sme_active(void) { return false; } > static inline bool sev_active(void) { return false; } > > +static inline int __init early_set_memory_decrypted(resource_size_t paddr, > + unsigned long size) > +{ > + return 0; > +} > + > +static inline int __init early_set_memory_encrypted(resource_size_t paddr, > + unsigned long size) > +{ > + return 0; > +} Yeah, let's save some screen real-estate like this: static inline int __init early_set_memory_decrypted(resource_size_t paddr, unsigned long size) { return 0; } static inline int __init early_set_memory_encrypted(resource_size_t paddr, unsigned long size) { return 0; } With that fixed: Reviewed-by: Borislav Petkov -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --