]> Git Repo - linux.git/commitdiff
x86/sev: Get rid of special sev_es_enable_key
authorBorislav Petkov (AMD) <[email protected]>
Tue, 28 Mar 2023 20:17:12 +0000 (22:17 +0200)
committerBorislav Petkov (AMD) <[email protected]>
Mon, 8 May 2023 09:49:29 +0000 (11:49 +0200)
A SEV-ES guest is active on AMD when CC_ATTR_GUEST_STATE_ENCRYPT is set.
I.e., MSR_AMD64_SEV, bit 1, SEV_ES_Enabled. So no need for a special
static key.

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Acked-by: Tom Lendacky <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
arch/x86/include/asm/sev.h
arch/x86/kernel/sev.c

index 13dc2a9d23c1eb258ce4e2b78e74859902dd9f4b..f14060cbead28b310780b63b08510dbc4d118d88 100644 (file)
@@ -14,6 +14,7 @@
 #include <asm/insn.h>
 #include <asm/sev-common.h>
 #include <asm/bootparam.h>
+#include <asm/coco.h>
 
 #define GHCB_PROTOCOL_MIN      1ULL
 #define GHCB_PROTOCOL_MAX      2ULL
@@ -136,24 +137,26 @@ struct snp_secrets_page_layout {
 } __packed;
 
 #ifdef CONFIG_AMD_MEM_ENCRYPT
-extern struct static_key_false sev_es_enable_key;
 extern void __sev_es_ist_enter(struct pt_regs *regs);
 extern void __sev_es_ist_exit(void);
 static __always_inline void sev_es_ist_enter(struct pt_regs *regs)
 {
-       if (static_branch_unlikely(&sev_es_enable_key))
+       if (cc_vendor == CC_VENDOR_AMD &&
+           cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT))
                __sev_es_ist_enter(regs);
 }
 static __always_inline void sev_es_ist_exit(void)
 {
-       if (static_branch_unlikely(&sev_es_enable_key))
+       if (cc_vendor == CC_VENDOR_AMD &&
+           cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT))
                __sev_es_ist_exit();
 }
 extern int sev_es_setup_ap_jump_table(struct real_mode_header *rmh);
 extern void __sev_es_nmi_complete(void);
 static __always_inline void sev_es_nmi_complete(void)
 {
-       if (static_branch_unlikely(&sev_es_enable_key))
+       if (cc_vendor == CC_VENDOR_AMD &&
+           cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT))
                __sev_es_nmi_complete();
 }
 extern int __init sev_es_efi_map_ghcbs(pgd_t *pgd);
index b031244d6d2df4cfb5e508c28eaf8d15d580b69a..0ec0d963b8b70e68e0092a30328e84e87a5d6727 100644 (file)
@@ -113,8 +113,6 @@ struct ghcb_state {
 };
 
 static DEFINE_PER_CPU(struct sev_es_runtime_data*, runtime_data);
-DEFINE_STATIC_KEY_FALSE(sev_es_enable_key);
-
 static DEFINE_PER_CPU(struct sev_es_save_area *, sev_vmsa);
 
 struct sev_config {
@@ -1395,9 +1393,6 @@ void __init sev_es_init_vc_handling(void)
                        sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED);
        }
 
-       /* Enable SEV-ES special handling */
-       static_branch_enable(&sev_es_enable_key);
-
        /* Initialize per-cpu GHCB pages */
        for_each_possible_cpu(cpu) {
                alloc_runtime_data(cpu);
This page took 0.063685 seconds and 4 git commands to generate.