blob: 8413688b2571d760f77d918713b758345bdece0a [file] [log] [blame]
Jeremy Fitzhardinge48b5db22008-07-08 15:06:34 -07001/******************************************************************************
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
H. Peter Anvin05e4d312008-10-23 00:01:39 -07009#ifndef _ASM_X86_XEN_INTERFACE_32_H
10#define _ASM_X86_XEN_INTERFACE_32_H
Jeremy Fitzhardinge48b5db22008-07-08 15:06:34 -070011
12
13/*
14 * These flat segments are in the Xen-private section of every GDT. Since these
15 * are also present in the initial GDT, many OSes will be able to avoid
16 * installing their own GDT.
17 */
18#define FLAT_RING1_CS 0xe019 /* GDT index 259 */
19#define FLAT_RING1_DS 0xe021 /* GDT index 260 */
20#define FLAT_RING1_SS 0xe021 /* GDT index 260 */
21#define FLAT_RING3_CS 0xe02b /* GDT index 261 */
22#define FLAT_RING3_DS 0xe033 /* GDT index 262 */
23#define FLAT_RING3_SS 0xe033 /* GDT index 262 */
24
25#define FLAT_KERNEL_CS FLAT_RING1_CS
26#define FLAT_KERNEL_DS FLAT_RING1_DS
27#define FLAT_KERNEL_SS FLAT_RING1_SS
28#define FLAT_USER_CS FLAT_RING3_CS
29#define FLAT_USER_DS FLAT_RING3_DS
30#define FLAT_USER_SS FLAT_RING3_SS
31
32/* And the trap vector is... */
33#define TRAP_INSTR "int $0x82"
34
Ian Campbell7e775062010-09-30 12:37:26 +010035#define __MACH2PHYS_VIRT_START 0xF5800000
36#define __MACH2PHYS_VIRT_END 0xF6800000
37
38#define __MACH2PHYS_SHIFT 2
39
Jeremy Fitzhardinge48b5db22008-07-08 15:06:34 -070040/*
41 * Virtual addresses beyond this are not modifiable by guest OSes. The
42 * machine->physical mapping table starts at this address, read-only.
43 */
44#define __HYPERVISOR_VIRT_START 0xF5800000
45
46#ifndef __ASSEMBLY__
47
48struct cpu_user_regs {
49 uint32_t ebx;
50 uint32_t ecx;
51 uint32_t edx;
52 uint32_t esi;
53 uint32_t edi;
54 uint32_t ebp;
55 uint32_t eax;
56 uint16_t error_code; /* private */
57 uint16_t entry_vector; /* private */
58 uint32_t eip;
59 uint16_t cs;
60 uint8_t saved_upcall_mask;
61 uint8_t _pad0;
62 uint32_t eflags; /* eflags.IF == !saved_upcall_mask */
63 uint32_t esp;
64 uint16_t ss, _pad1;
65 uint16_t es, _pad2;
66 uint16_t ds, _pad3;
67 uint16_t fs, _pad4;
68 uint16_t gs, _pad5;
69};
70DEFINE_GUEST_HANDLE_STRUCT(cpu_user_regs);
71
72typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
73
74struct arch_vcpu_info {
75 unsigned long cr2;
76 unsigned long pad[5]; /* sizeof(struct vcpu_info) == 64 */
77};
78
79struct xen_callback {
80 unsigned long cs;
81 unsigned long eip;
82};
83typedef struct xen_callback xen_callback_t;
84
85#define XEN_CALLBACK(__cs, __eip) \
86 ((struct xen_callback){ .cs = (__cs), .eip = (unsigned long)(__eip) })
87#endif /* !__ASSEMBLY__ */
88
89
90/*
91 * Page-directory addresses above 4GB do not fit into architectural %cr3.
92 * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
93 * must use the following accessor macros to pack/unpack valid MFNs.
94 *
95 * Note that Xen is using the fact that the pagetable base is always
96 * page-aligned, and putting the 12 MSB of the address into the 12 LSB
97 * of cr3.
98 */
99#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
100#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
101
H. Peter Anvin05e4d312008-10-23 00:01:39 -0700102#endif /* _ASM_X86_XEN_INTERFACE_32_H */