hvm_vcpu.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3. * of this software and associated documentation files (the "Software"), to
  4. * deal in the Software without restriction, including without limitation the
  5. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  6. * sell copies of the Software, and to permit persons to whom the Software is
  7. * furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in
  10. * all copies or substantial portions of the Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  17. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  18. * DEALINGS IN THE SOFTWARE.
  19. *
  20. * Copyright (c) 2015, Roger Pau Monne <roger.pau@citrix.com>
  21. */
  22. #ifndef __XEN_PUBLIC_HVM_HVM_VCPU_H__
  23. #define __XEN_PUBLIC_HVM_HVM_VCPU_H__
  24. #include "../xen.h"
  25. struct vcpu_hvm_x86_32 {
  26. uint32_t eax;
  27. uint32_t ecx;
  28. uint32_t edx;
  29. uint32_t ebx;
  30. uint32_t esp;
  31. uint32_t ebp;
  32. uint32_t esi;
  33. uint32_t edi;
  34. uint32_t eip;
  35. uint32_t eflags;
  36. uint32_t cr0;
  37. uint32_t cr3;
  38. uint32_t cr4;
  39. uint32_t pad1;
  40. /*
  41. * EFER should only be used to set the NXE bit (if required)
  42. * when starting a vCPU in 32bit mode with paging enabled or
  43. * to set the LME/LMA bits in order to start the vCPU in
  44. * compatibility mode.
  45. */
  46. uint64_t efer;
  47. uint32_t cs_base;
  48. uint32_t ds_base;
  49. uint32_t ss_base;
  50. uint32_t es_base;
  51. uint32_t tr_base;
  52. uint32_t cs_limit;
  53. uint32_t ds_limit;
  54. uint32_t ss_limit;
  55. uint32_t es_limit;
  56. uint32_t tr_limit;
  57. uint16_t cs_ar;
  58. uint16_t ds_ar;
  59. uint16_t ss_ar;
  60. uint16_t es_ar;
  61. uint16_t tr_ar;
  62. uint16_t pad2[3];
  63. };
  64. /*
  65. * The layout of the _ar fields of the segment registers is the
  66. * following:
  67. *
  68. * Bits [0,3]: type (bits 40-43).
  69. * Bit 4: s (descriptor type, bit 44).
  70. * Bit [5,6]: dpl (descriptor privilege level, bits 45-46).
  71. * Bit 7: p (segment-present, bit 47).
  72. * Bit 8: avl (available for system software, bit 52).
  73. * Bit 9: l (64-bit code segment, bit 53).
  74. * Bit 10: db (meaning depends on the segment, bit 54).
  75. * Bit 11: g (granularity, bit 55)
  76. * Bits [12,15]: unused, must be blank.
  77. *
  78. * A more complete description of the meaning of this fields can be
  79. * obtained from the Intel SDM, Volume 3, section 3.4.5.
  80. */
  81. struct vcpu_hvm_x86_64 {
  82. uint64_t rax;
  83. uint64_t rcx;
  84. uint64_t rdx;
  85. uint64_t rbx;
  86. uint64_t rsp;
  87. uint64_t rbp;
  88. uint64_t rsi;
  89. uint64_t rdi;
  90. uint64_t rip;
  91. uint64_t rflags;
  92. uint64_t cr0;
  93. uint64_t cr3;
  94. uint64_t cr4;
  95. uint64_t efer;
  96. /*
  97. * Using VCPU_HVM_MODE_64B implies that the vCPU is launched
  98. * directly in long mode, so the cached parts of the segment
  99. * registers get set to match that environment.
  100. *
  101. * If the user wants to launch the vCPU in compatibility mode
  102. * the 32-bit structure should be used instead.
  103. */
  104. };
  105. struct vcpu_hvm_context {
  106. #define VCPU_HVM_MODE_32B 0 /* 32bit fields of the structure will be used. */
  107. #define VCPU_HVM_MODE_64B 1 /* 64bit fields of the structure will be used. */
  108. uint32_t mode;
  109. uint32_t pad;
  110. /* CPU registers. */
  111. union {
  112. struct vcpu_hvm_x86_32 x86_32;
  113. struct vcpu_hvm_x86_64 x86_64;
  114. } cpu_regs;
  115. };
  116. typedef struct vcpu_hvm_context vcpu_hvm_context_t;
  117. #endif /* __XEN_PUBLIC_HVM_HVM_VCPU_H__ */
  118. /*
  119. * Local variables:
  120. * mode: C
  121. * c-file-style: "BSD"
  122. * c-basic-offset: 4
  123. * tab-width: 4
  124. * indent-tabs-mode: nil
  125. * End:
  126. */