You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xen-x86_32.h 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /******************************************************************************
  2. * xen-x86_32.h
  3. *
  4. * Guest OS interface to x86 32-bit Xen.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to
  8. * deal in the Software without restriction, including without limitation the
  9. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10. * sell copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. *
  24. * Copyright (c) 2004-2007, K A Fraser
  25. */
  26. #ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
  27. #define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
  28. FILE_LICENCE ( MIT );
  29. /*
  30. * Hypercall interface:
  31. * Input: %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6)
  32. * Output: %eax
  33. * Access is via hypercall page (set up by guest loader or via a Xen MSR):
  34. * call hypercall_page + hypercall-number * 32
  35. * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx)
  36. */
  37. /*
  38. * These flat segments are in the Xen-private section of every GDT. Since these
  39. * are also present in the initial GDT, many OSes will be able to avoid
  40. * installing their own GDT.
  41. */
  42. #define FLAT_RING1_CS 0xe019 /* GDT index 259 */
  43. #define FLAT_RING1_DS 0xe021 /* GDT index 260 */
  44. #define FLAT_RING1_SS 0xe021 /* GDT index 260 */
  45. #define FLAT_RING3_CS 0xe02b /* GDT index 261 */
  46. #define FLAT_RING3_DS 0xe033 /* GDT index 262 */
  47. #define FLAT_RING3_SS 0xe033 /* GDT index 262 */
  48. #define FLAT_KERNEL_CS FLAT_RING1_CS
  49. #define FLAT_KERNEL_DS FLAT_RING1_DS
  50. #define FLAT_KERNEL_SS FLAT_RING1_SS
  51. #define FLAT_USER_CS FLAT_RING3_CS
  52. #define FLAT_USER_DS FLAT_RING3_DS
  53. #define FLAT_USER_SS FLAT_RING3_SS
  54. #define __HYPERVISOR_VIRT_START_PAE 0xF5800000
  55. #define __MACH2PHYS_VIRT_START_PAE 0xF5800000
  56. #define __MACH2PHYS_VIRT_END_PAE 0xF6800000
  57. #define HYPERVISOR_VIRT_START_PAE \
  58. mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE)
  59. #define MACH2PHYS_VIRT_START_PAE \
  60. mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE)
  61. #define MACH2PHYS_VIRT_END_PAE \
  62. mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE)
  63. /* Non-PAE bounds are obsolete. */
  64. #define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000
  65. #define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000
  66. #define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000
  67. #define HYPERVISOR_VIRT_START_NONPAE \
  68. mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE)
  69. #define MACH2PHYS_VIRT_START_NONPAE \
  70. mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE)
  71. #define MACH2PHYS_VIRT_END_NONPAE \
  72. mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE)
  73. #define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE
  74. #define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE
  75. #define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE
  76. #ifndef HYPERVISOR_VIRT_START
  77. #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
  78. #endif
  79. #define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
  80. #define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
  81. #define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
  82. #ifndef machine_to_phys_mapping
  83. #define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
  84. #endif
  85. /* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
  86. #if defined(__XEN__) || defined(__XEN_TOOLS__)
  87. #undef ___DEFINE_XEN_GUEST_HANDLE
  88. #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
  89. typedef struct { type *p; } \
  90. __guest_handle_ ## name; \
  91. typedef struct { union { type *p; uint64_aligned_t q; }; } \
  92. __guest_handle_64_ ## name
  93. #undef set_xen_guest_handle_raw
  94. #define set_xen_guest_handle_raw(hnd, val) \
  95. do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \
  96. (hnd).p = val; \
  97. } while ( 0 )
  98. #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
  99. #define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
  100. #define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name)
  101. #endif
  102. #ifndef __ASSEMBLY__
  103. struct cpu_user_regs {
  104. uint32_t ebx;
  105. uint32_t ecx;
  106. uint32_t edx;
  107. uint32_t esi;
  108. uint32_t edi;
  109. uint32_t ebp;
  110. uint32_t eax;
  111. uint16_t error_code; /* private */
  112. uint16_t entry_vector; /* private */
  113. uint32_t eip;
  114. uint16_t cs;
  115. uint8_t saved_upcall_mask;
  116. uint8_t _pad0;
  117. uint32_t eflags; /* eflags.IF == !saved_upcall_mask */
  118. uint32_t esp;
  119. uint16_t ss, _pad1;
  120. uint16_t es, _pad2;
  121. uint16_t ds, _pad3;
  122. uint16_t fs, _pad4;
  123. uint16_t gs, _pad5;
  124. };
  125. typedef struct cpu_user_regs cpu_user_regs_t;
  126. DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
  127. /*
  128. * Page-directory addresses above 4GB do not fit into architectural %cr3.
  129. * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
  130. * must use the following accessor macros to pack/unpack valid MFNs.
  131. */
  132. #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
  133. #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
  134. struct arch_vcpu_info {
  135. unsigned long cr2;
  136. unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
  137. };
  138. typedef struct arch_vcpu_info arch_vcpu_info_t;
  139. struct xen_callback {
  140. unsigned long cs;
  141. unsigned long eip;
  142. };
  143. typedef struct xen_callback xen_callback_t;
  144. #endif /* !__ASSEMBLY__ */
  145. #endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */
  146. /*
  147. * Local variables:
  148. * mode: C
  149. * c-file-style: "BSD"
  150. * c-basic-offset: 4
  151. * tab-width: 4
  152. * indent-tabs-mode: nil
  153. * End:
  154. */