1818 * arg2 - Hypercall command
1919 * arg3 bits [15:0] - Port number, LB and direction flags
2020 *
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+ *
2127 * - High bandwidth (HB) hypercalls are I/O port based only. They have
2228 * up to 7 input and 7 output arguments passed and returned using
2329 * registers: %eax (arg0), %ebx (arg1), %ecx (arg2), %edx (arg3),
5460#define VMWARE_CMD_GETHZ 45
5561#define VMWARE_CMD_GETVCPU_INFO 68
5662#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
5769
5870#define CPUID_VMWARE_FEATURES_ECX_VMMCALL BIT(0)
5971#define CPUID_VMWARE_FEATURES_ECX_VMCALL BIT(1)
@@ -64,6 +76,15 @@ extern unsigned long vmware_hypercall_slow(unsigned long cmd,
6476 u32 * out1 , u32 * out2 , u32 * out3 ,
6577 u32 * out4 , u32 * out5 );
6678
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+
6788/*
6889 * The low bandwidth call. The low word of %edx is presumed to have OUT bit
6990 * 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)
79100{
80101 unsigned long out0 ;
81102
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+
82107 if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
83108 return vmware_hypercall_slow (cmd , in1 , 0 , 0 , 0 ,
84109 NULL , NULL , NULL , NULL , NULL );
@@ -100,6 +125,10 @@ unsigned long vmware_hypercall3(unsigned long cmd, unsigned long in1,
100125{
101126 unsigned long out0 ;
102127
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+
103132 if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
104133 return vmware_hypercall_slow (cmd , in1 , 0 , 0 , 0 ,
105134 out1 , out2 , NULL , NULL , NULL );
@@ -121,6 +150,10 @@ unsigned long vmware_hypercall4(unsigned long cmd, unsigned long in1,
121150{
122151 unsigned long out0 ;
123152
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+
124157 if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
125158 return vmware_hypercall_slow (cmd , in1 , 0 , 0 , 0 ,
126159 out1 , out2 , out3 , NULL , NULL );
@@ -143,6 +176,10 @@ unsigned long vmware_hypercall5(unsigned long cmd, unsigned long in1,
143176{
144177 unsigned long out0 ;
145178
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+
146183 if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
147184 return vmware_hypercall_slow (cmd , in1 , in3 , in4 , in5 ,
148185 NULL , out2 , NULL , NULL , NULL );
@@ -167,6 +204,10 @@ unsigned long vmware_hypercall6(unsigned long cmd, unsigned long in1,
167204{
168205 unsigned long out0 ;
169206
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+
170211 if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
171212 return vmware_hypercall_slow (cmd , in1 , in3 , 0 , 0 ,
172213 NULL , out2 , out3 , out4 , out5 );
@@ -191,6 +232,10 @@ unsigned long vmware_hypercall7(unsigned long cmd, unsigned long in1,
191232{
192233 unsigned long out0 ;
193234
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+
194239 if (unlikely (!alternatives_patched ) && !__is_defined (MODULE ))
195240 return vmware_hypercall_slow (cmd , in1 , in3 , in4 , in5 ,
196241 out1 , out2 , out3 , NULL , NULL );
0 commit comments