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