xref: /openbmc/linux/arch/x86/include/asm/vmware.h (revision 0889d07f)
1 /* SPDX-License-Identifier: GPL-2.0 or MIT */
2 #ifndef _ASM_X86_VMWARE_H
3 #define _ASM_X86_VMWARE_H
4 
5 #include <asm/cpufeatures.h>
6 #include <asm/alternative.h>
7 
8 /*
9  * The hypercall definitions differ in the low word of the %edx argument
10  * in the following way: the old port base interface uses the port
11  * number to distinguish between high- and low bandwidth versions.
12  *
13  * The new vmcall interface instead uses a set of flags to select
14  * bandwidth mode and transfer direction. The flags should be loaded
15  * into %dx by any user and are automatically replaced by the port
16  * number if the VMWARE_HYPERVISOR_PORT method is used.
17  *
18  * In short, new driver code should strictly use the new definition of
19  * %dx content.
20  */
21 
22 /* Old port-based version */
23 #define VMWARE_HYPERVISOR_PORT    "0x5658"
24 #define VMWARE_HYPERVISOR_PORT_HB "0x5659"
25 
26 /* Current vmcall / vmmcall version */
27 #define VMWARE_HYPERVISOR_HB   BIT(0)
28 #define VMWARE_HYPERVISOR_OUT  BIT(1)
29 
30 /* The low bandwidth call. The low word of edx is presumed clear. */
31 #define VMWARE_HYPERCALL						\
32 	ALTERNATIVE_2("movw $" VMWARE_HYPERVISOR_PORT ", %%dx; inl (%%dx)", \
33 		      "vmcall", X86_FEATURE_VMCALL,			\
34 		      "vmmcall", X86_FEATURE_VMW_VMMCALL)
35 
36 /*
37  * The high bandwidth out call. The low word of edx is presumed to have the
38  * HB and OUT bits set.
39  */
40 #define VMWARE_HYPERCALL_HB_OUT						\
41 	ALTERNATIVE_2("movw $" VMWARE_HYPERVISOR_PORT_HB ", %%dx; rep outsb", \
42 		      "vmcall", X86_FEATURE_VMCALL,			\
43 		      "vmmcall", X86_FEATURE_VMW_VMMCALL)
44 
45 /*
46  * The high bandwidth in call. The low word of edx is presumed to have the
47  * HB bit set.
48  */
49 #define VMWARE_HYPERCALL_HB_IN						\
50 	ALTERNATIVE_2("movw $" VMWARE_HYPERVISOR_PORT_HB ", %%dx; rep insb", \
51 		      "vmcall", X86_FEATURE_VMCALL,			\
52 		      "vmmcall", X86_FEATURE_VMW_VMMCALL)
53 #endif
54