@@ -48,6 +48,8 @@ extern u64 hv_current_partition_id;
48
48
49
49
extern union hv_ghcb * __percpu * hv_ghcb_pg ;
50
50
51
+ extern bool hv_isolation_type_en_snp (void );
52
+
51
53
int hv_call_deposit_pages (int node , u64 partition_id , u32 num_pages );
52
54
int hv_call_add_logical_proc (int node , u32 lp_index , u32 acpi_id );
53
55
int hv_call_create_vp (int node , u64 partition_id , u32 vp_index , u32 flags );
@@ -59,6 +61,16 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
59
61
u64 hv_status ;
60
62
61
63
#ifdef CONFIG_X86_64
64
+ if (hv_isolation_type_en_snp ()) {
65
+ __asm__ __volatile__("mov %4, %%r8\n"
66
+ "vmmcall"
67
+ : "=a" (hv_status ), ASM_CALL_CONSTRAINT ,
68
+ "+c" (control ), "+d" (input_address )
69
+ : "r" (output_address )
70
+ : "cc" , "memory" , "r8" , "r9" , "r10" , "r11" );
71
+ return hv_status ;
72
+ }
73
+
62
74
if (!hv_hypercall_pg )
63
75
return U64_MAX ;
64
76
@@ -102,7 +114,13 @@ static inline u64 _hv_do_fast_hypercall8(u64 control, u64 input1)
102
114
u64 hv_status ;
103
115
104
116
#ifdef CONFIG_X86_64
105
- {
117
+ if (hv_isolation_type_en_snp ()) {
118
+ __asm__ __volatile__(
119
+ "vmmcall"
120
+ : "=a" (hv_status ), ASM_CALL_CONSTRAINT ,
121
+ "+c" (control ), "+d" (input1 )
122
+ :: "cc" , "r8" , "r9" , "r10" , "r11" );
123
+ } else {
106
124
__asm__ __volatile__(CALL_NOSPEC
107
125
: "=a" (hv_status ), ASM_CALL_CONSTRAINT ,
108
126
"+c" (control ), "+d" (input1 )
@@ -147,7 +165,14 @@ static inline u64 _hv_do_fast_hypercall16(u64 control, u64 input1, u64 input2)
147
165
u64 hv_status ;
148
166
149
167
#ifdef CONFIG_X86_64
150
- {
168
+ if (hv_isolation_type_en_snp ()) {
169
+ __asm__ __volatile__("mov %4, %%r8\n"
170
+ "vmmcall"
171
+ : "=a" (hv_status ), ASM_CALL_CONSTRAINT ,
172
+ "+c" (control ), "+d" (input1 )
173
+ : "r" (input2 )
174
+ : "cc" , "r8" , "r9" , "r10" , "r11" );
175
+ } else {
151
176
__asm__ __volatile__("mov %4, %%r8\n"
152
177
CALL_NOSPEC
153
178
: "=a" (hv_status ), ASM_CALL_CONSTRAINT ,
@@ -240,7 +265,6 @@ static inline void hv_vtom_init(void) {}
240
265
#endif
241
266
242
267
extern bool hv_isolation_type_snp (void );
243
- extern bool hv_isolation_type_en_snp (void );
244
268
245
269
static inline bool hv_is_synic_reg (unsigned int reg )
246
270
{
0 commit comments