Skip to content

Commit f742b90

Browse files
codomaniasuryasaimadhu
authored andcommitted
x86/mm: Extend cc_attr to include AMD SEV-SNP
The CC_ATTR_GUEST_SEV_SNP can be used by the guest to query whether the SNP (Secure Nested Paging) feature is active. Signed-off-by: Brijesh Singh <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent bcce829 commit f742b90

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

arch/x86/coco/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ static bool amd_cc_platform_has(enum cc_attr attr)
5757
return (sev_status & MSR_AMD64_SEV_ENABLED) &&
5858
!(sev_status & MSR_AMD64_SEV_ES_ENABLED);
5959

60+
case CC_ATTR_GUEST_SEV_SNP:
61+
return sev_status & MSR_AMD64_SEV_SNP_ENABLED;
62+
6063
default:
6164
return false;
6265
}

arch/x86/include/asm/msr-index.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,10 @@
502502
#define MSR_AMD64_SEV 0xc0010131
503503
#define MSR_AMD64_SEV_ENABLED_BIT 0
504504
#define MSR_AMD64_SEV_ES_ENABLED_BIT 1
505+
#define MSR_AMD64_SEV_SNP_ENABLED_BIT 2
505506
#define MSR_AMD64_SEV_ENABLED BIT_ULL(MSR_AMD64_SEV_ENABLED_BIT)
506507
#define MSR_AMD64_SEV_ES_ENABLED BIT_ULL(MSR_AMD64_SEV_ES_ENABLED_BIT)
508+
#define MSR_AMD64_SEV_SNP_ENABLED BIT_ULL(MSR_AMD64_SEV_SNP_ENABLED_BIT)
507509

508510
#define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f
509511

arch/x86/mm/mem_encrypt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ static void print_mem_encrypt_feature_info(void)
6262
if (cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT))
6363
pr_cont(" SEV-ES");
6464

65+
/* Secure Nested Paging */
66+
if (cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
67+
pr_cont(" SEV-SNP");
68+
6569
pr_cont("\n");
6670
}
6771

include/linux/cc_platform.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ enum cc_attr {
7272
* Examples include TDX guest & SEV.
7373
*/
7474
CC_ATTR_GUEST_UNROLL_STRING_IO,
75+
76+
/**
77+
* @CC_ATTR_SEV_SNP: Guest SNP is active.
78+
*
79+
* The platform/OS is running as a guest/virtual machine and actively
80+
* using AMD SEV-SNP features.
81+
*/
82+
CC_ATTR_GUEST_SEV_SNP,
7583
};
7684

7785
#ifdef CONFIG_ARCH_HAS_CC_PLATFORM

0 commit comments

Comments
 (0)