File tree Expand file tree Collapse file tree 5 files changed +36
-5
lines changed Expand file tree Collapse file tree 5 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -413,3 +413,14 @@ bool hv_isolation_type_snp(void)
413
413
{
414
414
return static_branch_unlikely (& isolation_type_snp );
415
415
}
416
+
417
+ DEFINE_STATIC_KEY_FALSE (isolation_type_en_snp );
418
+ /*
419
+ * hv_isolation_type_en_snp - Check system runs in the AMD SEV-SNP based
420
+ * isolation enlightened VM.
421
+ */
422
+ bool hv_isolation_type_en_snp (void )
423
+ {
424
+ return static_branch_unlikely (& isolation_type_en_snp );
425
+ }
426
+
Original file line number Diff line number Diff line change 26
26
union hv_ghcb ;
27
27
28
28
DECLARE_STATIC_KEY_FALSE (isolation_type_snp );
29
+ DECLARE_STATIC_KEY_FALSE (isolation_type_en_snp );
29
30
30
31
typedef int (* hyperv_fill_flush_list_func )(
31
32
struct hv_guest_mapping_flush_list * flush ,
@@ -239,6 +240,7 @@ static inline void hv_vtom_init(void) {}
239
240
#endif
240
241
241
242
extern bool hv_isolation_type_snp (void );
243
+ extern bool hv_isolation_type_en_snp (void );
242
244
243
245
static inline bool hv_is_synic_reg (unsigned int reg )
244
246
{
Original file line number Diff line number Diff line change @@ -402,8 +402,12 @@ static void __init ms_hyperv_init_platform(void)
402
402
pr_info ("Hyper-V: Isolation Config: Group A 0x%x, Group B 0x%x\n" ,
403
403
ms_hyperv .isolation_config_a , ms_hyperv .isolation_config_b );
404
404
405
- if (hv_get_isolation_type () == HV_ISOLATION_TYPE_SNP )
405
+
406
+ if (cc_platform_has (CC_ATTR_GUEST_SEV_SNP )) {
407
+ static_branch_enable (& isolation_type_en_snp );
408
+ } else if (hv_get_isolation_type () == HV_ISOLATION_TYPE_SNP ) {
406
409
static_branch_enable (& isolation_type_snp );
410
+ }
407
411
}
408
412
409
413
if (hv_max_functions_eax >= HYPERV_CPUID_NESTED_FEATURES ) {
@@ -473,7 +477,8 @@ static void __init ms_hyperv_init_platform(void)
473
477
474
478
#if IS_ENABLED (CONFIG_HYPERV )
475
479
if ((hv_get_isolation_type () == HV_ISOLATION_TYPE_VBS ) ||
476
- (hv_get_isolation_type () == HV_ISOLATION_TYPE_SNP ))
480
+ ((hv_get_isolation_type () == HV_ISOLATION_TYPE_SNP ) &&
481
+ ms_hyperv .paravisor_present ))
477
482
hv_vtom_init ();
478
483
/*
479
484
* Setup the hook to get control post apic initialization.
Original file line number Diff line number Diff line change @@ -502,6 +502,12 @@ bool __weak hv_isolation_type_snp(void)
502
502
}
503
503
EXPORT_SYMBOL_GPL (hv_isolation_type_snp );
504
504
505
+ bool __weak hv_isolation_type_en_snp (void )
506
+ {
507
+ return false;
508
+ }
509
+ EXPORT_SYMBOL_GPL (hv_isolation_type_en_snp );
510
+
505
511
void __weak hv_setup_vmbus_handler (void (* handler )(void ))
506
512
{
507
513
}
Original file line number Diff line number Diff line change @@ -36,15 +36,21 @@ struct ms_hyperv_info {
36
36
u32 nested_features ;
37
37
u32 max_vp_index ;
38
38
u32 max_lp_index ;
39
- u32 isolation_config_a ;
39
+ union {
40
+ u32 isolation_config_a ;
41
+ struct {
42
+ u32 paravisor_present : 1 ;
43
+ u32 reserved_a1 : 31 ;
44
+ };
45
+ };
40
46
union {
41
47
u32 isolation_config_b ;
42
48
struct {
43
49
u32 cvm_type : 4 ;
44
- u32 reserved1 : 1 ;
50
+ u32 reserved_b1 : 1 ;
45
51
u32 shared_gpa_boundary_active : 1 ;
46
52
u32 shared_gpa_boundary_bits : 6 ;
47
- u32 reserved2 : 20 ;
53
+ u32 reserved_b2 : 20 ;
48
54
};
49
55
};
50
56
u64 shared_gpa_boundary ;
@@ -58,6 +64,7 @@ extern void * __percpu *hyperv_pcpu_output_arg;
58
64
extern u64 hv_do_hypercall (u64 control , void * inputaddr , void * outputaddr );
59
65
extern u64 hv_do_fast_hypercall8 (u16 control , u64 input8 );
60
66
extern bool hv_isolation_type_snp (void );
67
+ extern bool hv_isolation_type_en_snp (void );
61
68
62
69
/* Helper functions that provide a consistent pattern for checking Hyper-V hypercall status. */
63
70
static inline int hv_result (u64 status )
You can’t perform that action at this time.
0 commit comments