Re: [PATCH Part1 RFC v2 08/20] x86/mm: Add sev_snp_active() helper

From: Borislav Petkov
Date: Tue May 18 2021 - 14:11:07 EST


On Fri, Apr 30, 2021 at 07:16:04AM -0500, Brijesh Singh wrote:
> The sev_snp_active() helper can be used by the guest to query whether the
> SNP - Secure Nested Paging feature is active.
>
> Signed-off-by: Brijesh Singh <brijesh.singh@xxxxxxx>
> ---
> arch/x86/include/asm/mem_encrypt.h | 2 ++
> arch/x86/include/asm/msr-index.h | 2 ++
> arch/x86/mm/mem_encrypt.c | 9 +++++++++
> 3 files changed, 13 insertions(+)
>
> diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h
> index 31c4df123aa0..d99aa260d328 100644
> --- a/arch/x86/include/asm/mem_encrypt.h
> +++ b/arch/x86/include/asm/mem_encrypt.h
> @@ -54,6 +54,7 @@ void __init sev_es_init_vc_handling(void);
> bool sme_active(void);
> bool sev_active(void);
> bool sev_es_active(void);
> +bool sev_snp_active(void);
>
> #define __bss_decrypted __section(".bss..decrypted")
>
> @@ -79,6 +80,7 @@ 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; }
> +static inline bool sev_snp_active(void) { return false; }

Uff, yet another sev-something helper. So I already had this idea:

https://lore.kernel.org/kvm/20210421144402.GB5004@xxxxxxx/

How about you add the sev_feature_enabled() thing

which will return a boolean value depending on which SEV feature has
been queried and instead of having yet another helper, do

if (sev_feature_enabled(SEV_SNP))

or so?

I.e., just add the facility and the SNP bit - we will convert the rest
in time.

So that we can redesign this cleanly...

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette