File tree Expand file tree Collapse file tree 3 files changed +27
-11
lines changed Expand file tree Collapse file tree 3 files changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -610,11 +610,15 @@ void sev_enable(struct boot_params *bp)
610
610
* features.
611
611
*/
612
612
if (sev_status & MSR_AMD64_SEV_SNP_ENABLED ) {
613
- if (!(get_hv_features () & GHCB_HV_FT_SNP ))
613
+ u64 hv_features ;
614
+ int ret ;
615
+
616
+ hv_features = get_hv_features ();
617
+ if (!(hv_features & GHCB_HV_FT_SNP ))
614
618
sev_es_terminate (SEV_TERM_SET_GEN , GHCB_SNP_UNSUPPORTED );
615
619
616
620
/*
617
- * Enforce running at VMPL0.
621
+ * Enforce running at VMPL0 or with an SVSM .
618
622
*
619
623
* Use RMPADJUST (see the rmpadjust() function for a description of
620
624
* what the instruction does) to update the VMPL1 permissions of a
@@ -623,7 +627,14 @@ void sev_enable(struct boot_params *bp)
623
627
* only ever run at a single VMPL level so permission mask changes of a
624
628
* lesser-privileged VMPL are a don't-care.
625
629
*/
626
- if (rmpadjust ((unsigned long )& boot_ghcb_page , RMP_PG_SIZE_4K , 1 ))
630
+ ret = rmpadjust ((unsigned long )& boot_ghcb_page , RMP_PG_SIZE_4K , 1 );
631
+
632
+ /*
633
+ * Running at VMPL0 is not required if an SVSM is present and the hypervisor
634
+ * supports the required SVSM GHCB events.
635
+ */
636
+ if (ret &&
637
+ !(snp_vmpl && (hv_features & GHCB_HV_FT_SNP_MULTI_VMPL )))
627
638
sev_es_terminate (SEV_TERM_SET_LINUX , GHCB_TERM_NOT_VMPL0 );
628
639
}
629
640
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ enum psc_op {
122
122
123
123
#define GHCB_HV_FT_SNP BIT_ULL(0)
124
124
#define GHCB_HV_FT_SNP_AP_CREATION BIT_ULL(1)
125
+ #define GHCB_HV_FT_SNP_MULTI_VMPL BIT_ULL(5)
125
126
126
127
/*
127
128
* SNP Page State Change NAE event
Original file line number Diff line number Diff line change @@ -2352,23 +2352,27 @@ static void dump_cpuid_table(void)
2352
2352
* expected, but that initialization happens too early in boot to print any
2353
2353
* sort of indicator, and there's not really any other good place to do it,
2354
2354
* so do it here.
2355
+ *
2356
+ * If running as an SNP guest, report the current VM privilege level (VMPL).
2355
2357
*/
2356
- static int __init report_cpuid_table (void )
2358
+ static int __init report_snp_info (void )
2357
2359
{
2358
2360
const struct snp_cpuid_table * cpuid_table = snp_cpuid_get_table ();
2359
2361
2360
- if (!cpuid_table -> count )
2361
- return 0 ;
2362
+ if (cpuid_table -> count ) {
2363
+ pr_info ("Using SNP CPUID table, %d entries present.\n" ,
2364
+ cpuid_table -> count );
2362
2365
2363
- pr_info ("Using SNP CPUID table, %d entries present.\n" ,
2364
- cpuid_table -> count );
2366
+ if (sev_cfg .debug )
2367
+ dump_cpuid_table ();
2368
+ }
2365
2369
2366
- if (sev_cfg . debug )
2367
- dump_cpuid_table ( );
2370
+ if (cc_platform_has ( CC_ATTR_GUEST_SEV_SNP ) )
2371
+ pr_info ( "SNP running at VMPL%u.\n" , snp_vmpl );
2368
2372
2369
2373
return 0 ;
2370
2374
}
2371
- arch_initcall (report_cpuid_table );
2375
+ arch_initcall (report_snp_info );
2372
2376
2373
2377
static int __init init_sev_config (char * str )
2374
2378
{
You can’t perform that action at this time.
0 commit comments