diff options
author | Tom Lendacky <thomas.lendacky@amd.com> | 2021-09-09 01:58:36 +0300 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2021-10-04 12:46:46 +0300 |
commit | 32cb4d02fb02cae2e0696c1ce92d8195574faf59 (patch) | |
tree | 8e33210b05f9a0d2da8384b5494fa46c634d0b05 /arch/x86/mm/mem_encrypt_identity.c | |
parent | bfebd37e99dece9c83a373cf9f35def440fdd5df (diff) | |
download | linux-32cb4d02fb02cae2e0696c1ce92d8195574faf59.tar.xz |
x86/sme: Replace occurrences of sme_active() with cc_platform_has()
Replace uses of sme_active() with the more generic cc_platform_has()
using CC_ATTR_HOST_MEM_ENCRYPT. If future support is added for other
memory encryption technologies, the use of CC_ATTR_HOST_MEM_ENCRYPT
can be updated, as required.
This also replaces two usages of sev_active() that are really geared
towards detecting if SME is active.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210928191009.32551-6-bp@alien8.de
Diffstat (limited to 'arch/x86/mm/mem_encrypt_identity.c')
-rw-r--r-- | arch/x86/mm/mem_encrypt_identity.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c index 470b20208430..f8c612902038 100644 --- a/arch/x86/mm/mem_encrypt_identity.c +++ b/arch/x86/mm/mem_encrypt_identity.c @@ -30,6 +30,7 @@ #include <linux/kernel.h> #include <linux/mm.h> #include <linux/mem_encrypt.h> +#include <linux/cc_platform.h> #include <asm/setup.h> #include <asm/sections.h> @@ -287,7 +288,13 @@ void __init sme_encrypt_kernel(struct boot_params *bp) unsigned long pgtable_area_len; unsigned long decrypted_base; - if (!sme_active()) + /* + * This is early code, use an open coded check for SME instead of + * using cc_platform_has(). This eliminates worries about removing + * instrumentation or checking boot_cpu_data in the cc_platform_has() + * function. + */ + if (!sme_get_me_mask() || sev_status & MSR_AMD64_SEV_ENABLED) return; /* |