hvm_vcpu.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright (c) 2015, Roger Pau Monne <[email protected]>
  4. */
  5. #ifndef __XEN_PUBLIC_HVM_HVM_VCPU_H__
  6. #define __XEN_PUBLIC_HVM_HVM_VCPU_H__
  7. #include "../xen.h"
  8. struct vcpu_hvm_x86_32 {
  9. uint32_t eax;
  10. uint32_t ecx;
  11. uint32_t edx;
  12. uint32_t ebx;
  13. uint32_t esp;
  14. uint32_t ebp;
  15. uint32_t esi;
  16. uint32_t edi;
  17. uint32_t eip;
  18. uint32_t eflags;
  19. uint32_t cr0;
  20. uint32_t cr3;
  21. uint32_t cr4;
  22. uint32_t pad1;
  23. /*
  24. * EFER should only be used to set the NXE bit (if required)
  25. * when starting a vCPU in 32bit mode with paging enabled or
  26. * to set the LME/LMA bits in order to start the vCPU in
  27. * compatibility mode.
  28. */
  29. uint64_t efer;
  30. uint32_t cs_base;
  31. uint32_t ds_base;
  32. uint32_t ss_base;
  33. uint32_t es_base;
  34. uint32_t tr_base;
  35. uint32_t cs_limit;
  36. uint32_t ds_limit;
  37. uint32_t ss_limit;
  38. uint32_t es_limit;
  39. uint32_t tr_limit;
  40. uint16_t cs_ar;
  41. uint16_t ds_ar;
  42. uint16_t ss_ar;
  43. uint16_t es_ar;
  44. uint16_t tr_ar;
  45. uint16_t pad2[3];
  46. };
  47. /*
  48. * The layout of the _ar fields of the segment registers is the
  49. * following:
  50. *
  51. * Bits [0,3]: type (bits 40-43).
  52. * Bit 4: s (descriptor type, bit 44).
  53. * Bit [5,6]: dpl (descriptor privilege level, bits 45-46).
  54. * Bit 7: p (segment-present, bit 47).
  55. * Bit 8: avl (available for system software, bit 52).
  56. * Bit 9: l (64-bit code segment, bit 53).
  57. * Bit 10: db (meaning depends on the segment, bit 54).
  58. * Bit 11: g (granularity, bit 55)
  59. * Bits [12,15]: unused, must be blank.
  60. *
  61. * A more complete description of the meaning of this fields can be
  62. * obtained from the Intel SDM, Volume 3, section 3.4.5.
  63. */
  64. struct vcpu_hvm_x86_64 {
  65. uint64_t rax;
  66. uint64_t rcx;
  67. uint64_t rdx;
  68. uint64_t rbx;
  69. uint64_t rsp;
  70. uint64_t rbp;
  71. uint64_t rsi;
  72. uint64_t rdi;
  73. uint64_t rip;
  74. uint64_t rflags;
  75. uint64_t cr0;
  76. uint64_t cr3;
  77. uint64_t cr4;
  78. uint64_t efer;
  79. /*
  80. * Using VCPU_HVM_MODE_64B implies that the vCPU is launched
  81. * directly in long mode, so the cached parts of the segment
  82. * registers get set to match that environment.
  83. *
  84. * If the user wants to launch the vCPU in compatibility mode
  85. * the 32-bit structure should be used instead.
  86. */
  87. };
  88. struct vcpu_hvm_context {
  89. #define VCPU_HVM_MODE_32B 0 /* 32bit fields of the structure will be used. */
  90. #define VCPU_HVM_MODE_64B 1 /* 64bit fields of the structure will be used. */
  91. uint32_t mode;
  92. uint32_t pad;
  93. /* CPU registers. */
  94. union {
  95. struct vcpu_hvm_x86_32 x86_32;
  96. struct vcpu_hvm_x86_64 x86_64;
  97. } cpu_regs;
  98. };
  99. typedef struct vcpu_hvm_context vcpu_hvm_context_t;
  100. #endif /* __XEN_PUBLIC_HVM_HVM_VCPU_H__ */