[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210607195544.qlya6i5s2l2fkms2@box>
Date: Mon, 7 Jun 2021 22:55:44 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: Borislav Petkov <bp@...en8.de>
Cc: Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
Peter Zijlstra <peterz@...radead.org>,
Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...el.com>,
Tony Luck <tony.luck@...el.com>,
Andi Kleen <ak@...ux.intel.com>,
Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
Kuppuswamy Sathyanarayanan <knsathya@...nel.org>,
Dan Williams <dan.j.williams@...el.com>,
Raj Ashok <ashok.raj@...el.com>,
Sean Christopherson <seanjc@...gle.com>,
linux-kernel@...r.kernel.org,
Tom Lendacky <thomas.lendacky@....com>
Subject: Re: [RFC v2-fix-v2 1/1] x86: Introduce generic protected guest
abstractionn
On Thu, Jun 03, 2021 at 08:15:46PM +0200, Borislav Petkov wrote:
> From f1e9f051c86b09fe660f49b0307bc7c6cec5e6f4 Mon Sep 17 00:00:00 2001
> From: Borislav Petkov <bp@...e.de>
> Date: Thu, 3 Jun 2021 20:03:31 +0200
> Subject: Convert sme_active()
>
> diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h
> index 9c80c68d75b5..1bb9f22629fc 100644
> --- a/arch/x86/include/asm/mem_encrypt.h
> +++ b/arch/x86/include/asm/mem_encrypt.h
> @@ -50,7 +50,6 @@ void __init mem_encrypt_free_decrypted_mem(void);
> void __init mem_encrypt_init(void);
>
> void __init sev_es_init_vc_handling(void);
> -bool sme_active(void);
> bool sev_active(void);
> bool sev_es_active(void);
>
> @@ -75,7 +74,6 @@ static inline void __init sme_encrypt_kernel(struct boot_params *bp) { }
> static inline void __init sme_enable(struct boot_params *bp) { }
>
> static inline void sev_es_init_vc_handling(void) { }
> -static inline bool sme_active(void) { return false; }
> static inline bool sev_active(void) { return false; }
> static inline bool sev_es_active(void) { return false; }
>
> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
> index c078b0d3ab0e..1d88232146ab 100644
> --- a/arch/x86/kernel/machine_kexec_64.c
> +++ b/arch/x86/kernel/machine_kexec_64.c
> @@ -387,7 +387,7 @@ void machine_kexec(struct kimage *image)
> (unsigned long)page_list,
> image->start,
> image->preserve_context,
> - sme_active());
> + protected_guest_has(VM_HOST_MEM_ENCRYPT));
>
> #ifdef CONFIG_KEXEC_JUMP
> if (image->preserve_context)
I think conversions like this are wrong: relocate_kernel(), which got
called here, only knows how to deal with SME, not how to handle some
generic case.
(After a quick check, looks like all conversions in the patch are wrong
for the same reason.)
If code is written to handle a specific technology we need to stick with
a check that makes it clear. Trying to make sound generic only leads to
confusion.
Also, we have host memory encryption that doesn't require any of this
code: TME makes the ectryption transparently to OS.
Maybe it's better to take a conservative path: keep a check specific until
we find it can serve more than one HW feature?
--
Kirill A. Shutemov
Powered by blists - more mailing lists