18
18
* arg2 - Hypercall command
19
19
* arg3 bits [15:0] - Port number, LB and direction flags
20
20
*
21
+ * - Low bandwidth TDX hypercalls (x86_64 only) are similar to LB
22
+ * hypercalls. They also have up to 6 input and 6 output on registers
23
+ * arguments, with different argument to register mapping:
24
+ * %r12 (arg0), %rbx (arg1), %r13 (arg2), %rdx (arg3),
25
+ * %rsi (arg4), %rdi (arg5).
26
+ *
21
27
* - High bandwidth (HB) hypercalls are I/O port based only. They have
22
28
* up to 7 input and 7 output arguments passed and returned using
23
29
* registers: %eax (arg0), %ebx (arg1), %ecx (arg2), %edx (arg3),
54
60
#define VMWARE_CMD_GETHZ 45
55
61
#define VMWARE_CMD_GETVCPU_INFO 68
56
62
#define VMWARE_CMD_STEALCLOCK 91
63
+ /*
64
+ * Hypercall command mask:
65
+ * bits [6:0] command, range [0, 127]
66
+ * bits [19:16] sub-command, range [0, 15]
67
+ */
68
+ #define VMWARE_CMD_MASK 0xf007fU
57
69
58
70
#define CPUID_VMWARE_FEATURES_ECX_VMMCALL BIT(0)
59
71
#define CPUID_VMWARE_FEATURES_ECX_VMCALL BIT(1)
@@ -64,6 +76,15 @@ extern unsigned long vmware_hypercall_slow(unsigned long cmd,
64
76
u32 * out1 , u32 * out2 , u32 * out3 ,
65
77
u32 * out4 , u32 * out5 );
66
78
79
+ #define VMWARE_TDX_VENDOR_LEAF 0x1af7e4909ULL
80
+ #define VMWARE_TDX_HCALL_FUNC 1
81
+
82
+ extern unsigned long vmware_tdx_hypercall (unsigned long cmd ,
83
+ unsigned long in1 , unsigned long in3 ,
84
+ unsigned long in4 , unsigned long in5 ,
85
+ u32 * out1 , u32 * out2 , u32 * out3 ,
86
+ u32 * out4 , u32 * out5 );
87
+
67
88
/*
68
89
* The low bandwidth call. The low word of %edx is presumed to have OUT bit
69
90
* set. The high word of %edx may contain input data from the caller.
@@ -79,6 +100,10 @@ unsigned long vmware_hypercall1(unsigned long cmd, unsigned long in1)
79
100
{
80
101
unsigned long out0 ;
81
102
103
+ if (cpu_feature_enabled (X86_FEATURE_TDX_GUEST ))
104
+ return vmware_tdx_hypercall (cmd , in1 , 0 , 0 , 0 ,
105
+ NULL , NULL , NULL , NULL , NULL );
106
+
82
107
if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
83
108
return vmware_hypercall_slow (cmd , in1 , 0 , 0 , 0 ,
84
109
NULL , NULL , NULL , NULL , NULL );
@@ -100,6 +125,10 @@ unsigned long vmware_hypercall3(unsigned long cmd, unsigned long in1,
100
125
{
101
126
unsigned long out0 ;
102
127
128
+ if (cpu_feature_enabled (X86_FEATURE_TDX_GUEST ))
129
+ return vmware_tdx_hypercall (cmd , in1 , 0 , 0 , 0 ,
130
+ out1 , out2 , NULL , NULL , NULL );
131
+
103
132
if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
104
133
return vmware_hypercall_slow (cmd , in1 , 0 , 0 , 0 ,
105
134
out1 , out2 , NULL , NULL , NULL );
@@ -121,6 +150,10 @@ unsigned long vmware_hypercall4(unsigned long cmd, unsigned long in1,
121
150
{
122
151
unsigned long out0 ;
123
152
153
+ if (cpu_feature_enabled (X86_FEATURE_TDX_GUEST ))
154
+ return vmware_tdx_hypercall (cmd , in1 , 0 , 0 , 0 ,
155
+ out1 , out2 , out3 , NULL , NULL );
156
+
124
157
if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
125
158
return vmware_hypercall_slow (cmd , in1 , 0 , 0 , 0 ,
126
159
out1 , out2 , out3 , NULL , NULL );
@@ -143,6 +176,10 @@ unsigned long vmware_hypercall5(unsigned long cmd, unsigned long in1,
143
176
{
144
177
unsigned long out0 ;
145
178
179
+ if (cpu_feature_enabled (X86_FEATURE_TDX_GUEST ))
180
+ return vmware_tdx_hypercall (cmd , in1 , in3 , in4 , in5 ,
181
+ NULL , out2 , NULL , NULL , NULL );
182
+
146
183
if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
147
184
return vmware_hypercall_slow (cmd , in1 , in3 , in4 , in5 ,
148
185
NULL , out2 , NULL , NULL , NULL );
@@ -167,6 +204,10 @@ unsigned long vmware_hypercall6(unsigned long cmd, unsigned long in1,
167
204
{
168
205
unsigned long out0 ;
169
206
207
+ if (cpu_feature_enabled (X86_FEATURE_TDX_GUEST ))
208
+ return vmware_tdx_hypercall (cmd , in1 , in3 , 0 , 0 ,
209
+ NULL , out2 , out3 , out4 , out5 );
210
+
170
211
if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
171
212
return vmware_hypercall_slow (cmd , in1 , in3 , 0 , 0 ,
172
213
NULL , out2 , out3 , out4 , out5 );
@@ -191,6 +232,10 @@ unsigned long vmware_hypercall7(unsigned long cmd, unsigned long in1,
191
232
{
192
233
unsigned long out0 ;
193
234
235
+ if (cpu_feature_enabled (X86_FEATURE_TDX_GUEST ))
236
+ return vmware_tdx_hypercall (cmd , in1 , in3 , in4 , in5 ,
237
+ out1 , out2 , out3 , NULL , NULL );
238
+
194
239
if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
195
240
return vmware_hypercall_slow (cmd , in1 , in3 , in4 , in5 ,
196
241
out1 , out2 , out3 , NULL , NULL );
0 commit comments