Commit | Line | Data |
---|---|---|
1965aae3 PA |
1 | #ifndef _ASM_X86_LGUEST_H |
2 | #define _ASM_X86_LGUEST_H | |
625efab1 JS |
3 | |
4 | #define GDT_ENTRY_LGUEST_CS 10 | |
5 | #define GDT_ENTRY_LGUEST_DS 11 | |
6 | #define LGUEST_CS (GDT_ENTRY_LGUEST_CS * 8) | |
7 | #define LGUEST_DS (GDT_ENTRY_LGUEST_DS * 8) | |
8 | ||
9 | #ifndef __ASSEMBLY__ | |
10 | #include <asm/desc.h> | |
11 | ||
12 | #define GUEST_PL 1 | |
13 | ||
93a2cdff | 14 | /* Page for Switcher text itself, then two pages per cpu */ |
e27d90e8 RR |
15 | #define SWITCHER_TEXT_PAGES (1) |
16 | #define SWITCHER_STACK_PAGES (2 * nr_cpu_ids) | |
17 | #define TOTAL_SWITCHER_PAGES (SWITCHER_TEXT_PAGES + SWITCHER_STACK_PAGES) | |
625efab1 | 18 | |
406a590b RR |
19 | /* Where we map the Switcher, in both Host and Guest. */ |
20 | extern unsigned long switcher_addr; | |
625efab1 JS |
21 | |
22 | /* Found in switcher.S */ | |
23 | extern unsigned long default_idt_entries[]; | |
24 | ||
2f921b5b RR |
25 | /* Declarations for definitions in arch/x86/lguest/head_32.S */ |
26 | extern char lguest_noirq_iret[]; | |
cbc34973 | 27 | extern const char lgstart_cli[], lgend_cli[]; |
cbc34973 | 28 | extern const char lgstart_pushf[], lgend_pushf[]; |
cbc34973 HH |
29 | |
30 | extern void lguest_iret(void); | |
31 | extern void lguest_init(void); | |
32 | ||
fb444c7b | 33 | struct lguest_regs { |
625efab1 | 34 | /* Manually saved part. */ |
4614a3a3 | 35 | unsigned long eax, ebx, ecx, edx; |
625efab1 JS |
36 | unsigned long esi, edi, ebp; |
37 | unsigned long gs; | |
625efab1 JS |
38 | unsigned long fs, ds, es; |
39 | unsigned long trapnum, errcode; | |
40 | /* Trap pushed part */ | |
41 | unsigned long eip; | |
42 | unsigned long cs; | |
43 | unsigned long eflags; | |
44 | unsigned long esp; | |
45 | unsigned long ss; | |
46 | }; | |
47 | ||
48 | /* This is a guest-specific page (mapped ro) into the guest. */ | |
fb444c7b | 49 | struct lguest_ro_state { |
625efab1 JS |
50 | /* Host information we need to restore when we switch back. */ |
51 | u32 host_cr3; | |
6b68f01b GOC |
52 | struct desc_ptr host_idt_desc; |
53 | struct desc_ptr host_gdt_desc; | |
625efab1 JS |
54 | u32 host_sp; |
55 | ||
56 | /* Fields which are used when guest is running. */ | |
6b68f01b GOC |
57 | struct desc_ptr guest_idt_desc; |
58 | struct desc_ptr guest_gdt_desc; | |
ca241c75 | 59 | struct x86_hw_tss guest_tss; |
625efab1 JS |
60 | struct desc_struct guest_idt[IDT_ENTRIES]; |
61 | struct desc_struct guest_gdt[GDT_ENTRIES]; | |
62 | }; | |
63 | ||
fb444c7b | 64 | struct lg_cpu_arch { |
625efab1 JS |
65 | /* The GDT entries copied into lguest_ro_state when running. */ |
66 | struct desc_struct gdt[GDT_ENTRIES]; | |
67 | ||
68 | /* The IDT entries: some copied into lguest_ro_state when running. */ | |
69 | struct desc_struct idt[IDT_ENTRIES]; | |
70 | ||
71 | /* The address of the last guest-visible pagefault (ie. cr2). */ | |
72 | unsigned long last_pagefault; | |
73 | }; | |
74 | ||
75 | static inline void lguest_set_ts(void) | |
76 | { | |
77 | u32 cr0; | |
78 | ||
79 | cr0 = read_cr0(); | |
80 | if (!(cr0 & 8)) | |
fb444c7b | 81 | write_cr0(cr0 | 8); |
625efab1 JS |
82 | } |
83 | ||
84 | /* Full 4G segment descriptors, suitable for CS and DS. */ | |
1e5de182 AM |
85 | #define FULL_EXEC_SEGMENT \ |
86 | ((struct desc_struct)GDT_ENTRY_INIT(0xc09b, 0, 0xfffff)) | |
87 | #define FULL_SEGMENT ((struct desc_struct)GDT_ENTRY_INIT(0xc093, 0, 0xfffff)) | |
625efab1 JS |
88 | |
89 | #endif /* __ASSEMBLY__ */ | |
90 | ||
1965aae3 | 91 | #endif /* _ASM_X86_LGUEST_H */ |