kvm_para.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef __LINUX_KVM_PARA_H
  2. #define __LINUX_KVM_PARA_H
  3. /*
  4. * Guest OS interface for KVM paravirtualization
  5. *
  6. * Note: this interface is totally experimental, and is certain to change
  7. * as we make progress.
  8. */
  9. /*
  10. * Per-VCPU descriptor area shared between guest and host. Writable to
  11. * both guest and host. Registered with the host by the guest when
  12. * a guest acknowledges paravirtual mode.
  13. *
  14. * NOTE: all addresses are guest-physical addresses (gpa), to make it
  15. * easier for the hypervisor to map between the various addresses.
  16. */
  17. struct kvm_vcpu_para_state {
  18. /*
  19. * API version information for compatibility. If there's any support
  20. * mismatch (too old host trying to execute too new guest) then
  21. * the host will deny entry into paravirtual mode. Any other
  22. * combination (new host + old guest and new host + new guest)
  23. * is supposed to work - new host versions will support all old
  24. * guest API versions.
  25. */
  26. u32 guest_version;
  27. u32 host_version;
  28. u32 size;
  29. u32 ret;
  30. /*
  31. * The address of the vm exit instruction (VMCALL or VMMCALL),
  32. * which the host will patch according to the CPU model the
  33. * VM runs on:
  34. */
  35. u64 hypercall_gpa;
  36. } __attribute__ ((aligned(PAGE_SIZE)));
  37. #define KVM_PARA_API_VERSION 1
  38. /*
  39. * This is used for an RDMSR's ECX parameter to probe for a KVM host.
  40. * Hopefully no CPU vendor will use up this number. This is placed well
  41. * out of way of the typical space occupied by CPU vendors' MSR indices,
  42. * and we think (or at least hope) it wont be occupied in the future
  43. * either.
  44. */
  45. #define MSR_KVM_API_MAGIC 0x87655678
  46. #define KVM_EINVAL 1
  47. /*
  48. * Hypercall calling convention:
  49. *
  50. * Each hypercall may have 0-6 parameters.
  51. *
  52. * 64-bit hypercall index is in RAX, goes from 0 to __NR_hypercalls-1
  53. *
  54. * 64-bit parameters 1-6 are in the standard gcc x86_64 calling convention
  55. * order: RDI, RSI, RDX, RCX, R8, R9.
  56. *
  57. * 32-bit index is EBX, parameters are: EAX, ECX, EDX, ESI, EDI, EBP.
  58. * (the first 3 are according to the gcc regparm calling convention)
  59. *
  60. * No registers are clobbered by the hypercall, except that the
  61. * return value is in RAX.
  62. */
  63. #define __NR_hypercalls 0
  64. #endif