vmware.h 1.9 KB

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