interface_32.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /******************************************************************************
  2. * arch-x86_32.h
  3. *
  4. * Guest OS interface to x86 32-bit Xen.
  5. *
  6. * Copyright (c) 2004, K A Fraser
  7. */
  8. #ifndef _ASM_X86_XEN_INTERFACE_32_H
  9. #define _ASM_X86_XEN_INTERFACE_32_H
  10. /*
  11. * These flat segments are in the Xen-private section of every GDT. Since these
  12. * are also present in the initial GDT, many OSes will be able to avoid
  13. * installing their own GDT.
  14. */
  15. #define FLAT_RING1_CS 0xe019 /* GDT index 259 */
  16. #define FLAT_RING1_DS 0xe021 /* GDT index 260 */
  17. #define FLAT_RING1_SS 0xe021 /* GDT index 260 */
  18. #define FLAT_RING3_CS 0xe02b /* GDT index 261 */
  19. #define FLAT_RING3_DS 0xe033 /* GDT index 262 */
  20. #define FLAT_RING3_SS 0xe033 /* GDT index 262 */
  21. #define FLAT_KERNEL_CS FLAT_RING1_CS
  22. #define FLAT_KERNEL_DS FLAT_RING1_DS
  23. #define FLAT_KERNEL_SS FLAT_RING1_SS
  24. #define FLAT_USER_CS FLAT_RING3_CS
  25. #define FLAT_USER_DS FLAT_RING3_DS
  26. #define FLAT_USER_SS FLAT_RING3_SS
  27. /* And the trap vector is... */
  28. #define TRAP_INSTR "int $0x82"
  29. /*
  30. * Virtual addresses beyond this are not modifiable by guest OSes. The
  31. * machine->physical mapping table starts at this address, read-only.
  32. */
  33. #define __HYPERVISOR_VIRT_START 0xF5800000
  34. #ifndef __ASSEMBLY__
  35. struct cpu_user_regs {
  36. uint32_t ebx;
  37. uint32_t ecx;
  38. uint32_t edx;
  39. uint32_t esi;
  40. uint32_t edi;
  41. uint32_t ebp;
  42. uint32_t eax;
  43. uint16_t error_code; /* private */
  44. uint16_t entry_vector; /* private */
  45. uint32_t eip;
  46. uint16_t cs;
  47. uint8_t saved_upcall_mask;
  48. uint8_t _pad0;
  49. uint32_t eflags; /* eflags.IF == !saved_upcall_mask */
  50. uint32_t esp;
  51. uint16_t ss, _pad1;
  52. uint16_t es, _pad2;
  53. uint16_t ds, _pad3;
  54. uint16_t fs, _pad4;
  55. uint16_t gs, _pad5;
  56. };
  57. DEFINE_GUEST_HANDLE_STRUCT(cpu_user_regs);
  58. typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
  59. struct arch_vcpu_info {
  60. unsigned long cr2;
  61. unsigned long pad[5]; /* sizeof(struct vcpu_info) == 64 */
  62. };
  63. struct xen_callback {
  64. unsigned long cs;
  65. unsigned long eip;
  66. };
  67. typedef struct xen_callback xen_callback_t;
  68. #define XEN_CALLBACK(__cs, __eip) \
  69. ((struct xen_callback){ .cs = (__cs), .eip = (unsigned long)(__eip) })
  70. #endif /* !__ASSEMBLY__ */
  71. /*
  72. * Page-directory addresses above 4GB do not fit into architectural %cr3.
  73. * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
  74. * must use the following accessor macros to pack/unpack valid MFNs.
  75. *
  76. * Note that Xen is using the fact that the pagetable base is always
  77. * page-aligned, and putting the 12 MSB of the address into the 12 LSB
  78. * of cr3.
  79. */
  80. #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
  81. #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
  82. #endif /* _ASM_X86_XEN_INTERFACE_32_H */