interface_32.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. #define __MACH2PHYS_VIRT_START 0xF5800000
  30. #define __MACH2PHYS_VIRT_END 0xF6800000
  31. #define __MACH2PHYS_SHIFT 2
  32. /*
  33. * Virtual addresses beyond this are not modifiable by guest OSes. The
  34. * machine->physical mapping table starts at this address, read-only.
  35. */
  36. #define __HYPERVISOR_VIRT_START 0xF5800000
  37. #ifndef __ASSEMBLY__
  38. struct cpu_user_regs {
  39. uint32_t ebx;
  40. uint32_t ecx;
  41. uint32_t edx;
  42. uint32_t esi;
  43. uint32_t edi;
  44. uint32_t ebp;
  45. uint32_t eax;
  46. uint16_t error_code; /* private */
  47. uint16_t entry_vector; /* private */
  48. uint32_t eip;
  49. uint16_t cs;
  50. uint8_t saved_upcall_mask;
  51. uint8_t _pad0;
  52. uint32_t eflags; /* eflags.IF == !saved_upcall_mask */
  53. uint32_t esp;
  54. uint16_t ss, _pad1;
  55. uint16_t es, _pad2;
  56. uint16_t ds, _pad3;
  57. uint16_t fs, _pad4;
  58. uint16_t gs, _pad5;
  59. };
  60. DEFINE_GUEST_HANDLE_STRUCT(cpu_user_regs);
  61. typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
  62. struct arch_vcpu_info {
  63. unsigned long cr2;
  64. unsigned long pad[5]; /* sizeof(struct vcpu_info) == 64 */
  65. };
  66. struct xen_callback {
  67. unsigned long cs;
  68. unsigned long eip;
  69. };
  70. typedef struct xen_callback xen_callback_t;
  71. #define XEN_CALLBACK(__cs, __eip) \
  72. ((struct xen_callback){ .cs = (__cs), .eip = (unsigned long)(__eip) })
  73. #endif /* !__ASSEMBLY__ */
  74. /*
  75. * Page-directory addresses above 4GB do not fit into architectural %cr3.
  76. * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
  77. * must use the following accessor macros to pack/unpack valid MFNs.
  78. *
  79. * Note that Xen is using the fact that the pagetable base is always
  80. * page-aligned, and putting the 12 MSB of the address into the 12 LSB
  81. * of cr3.
  82. */
  83. #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
  84. #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
  85. #endif /* _ASM_X86_XEN_INTERFACE_32_H */