diff options
Diffstat (limited to 'arch/x86/include/asm/lguest.h')
-rw-r--r-- | arch/x86/include/asm/lguest.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/arch/x86/include/asm/lguest.h b/arch/x86/include/asm/lguest.h new file mode 100644 index 000000000000..7505e947ed27 --- /dev/null +++ b/arch/x86/include/asm/lguest.h | |||
@@ -0,0 +1,94 @@ | |||
1 | #ifndef ASM_X86__LGUEST_H | ||
2 | #define ASM_X86__LGUEST_H | ||
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 | |||
14 | /* Every guest maps the core switcher code. */ | ||
15 | #define SHARED_SWITCHER_PAGES \ | ||
16 | DIV_ROUND_UP(end_switcher_text - start_switcher_text, PAGE_SIZE) | ||
17 | /* Pages for switcher itself, then two pages per cpu */ | ||
18 | #define TOTAL_SWITCHER_PAGES (SHARED_SWITCHER_PAGES + 2 * NR_CPUS) | ||
19 | |||
20 | /* We map at -4M for ease of mapping into the guest (one PTE page). */ | ||
21 | #define SWITCHER_ADDR 0xFFC00000 | ||
22 | |||
23 | /* Found in switcher.S */ | ||
24 | extern unsigned long default_idt_entries[]; | ||
25 | |||
26 | /* Declarations for definitions in lguest_guest.S */ | ||
27 | extern char lguest_noirq_start[], lguest_noirq_end[]; | ||
28 | extern const char lgstart_cli[], lgend_cli[]; | ||
29 | extern const char lgstart_sti[], lgend_sti[]; | ||
30 | extern const char lgstart_popf[], lgend_popf[]; | ||
31 | extern const char lgstart_pushf[], lgend_pushf[]; | ||
32 | extern const char lgstart_iret[], lgend_iret[]; | ||
33 | |||
34 | extern void lguest_iret(void); | ||
35 | extern void lguest_init(void); | ||
36 | |||
37 | struct lguest_regs { | ||
38 | /* Manually saved part. */ | ||
39 | unsigned long eax, ebx, ecx, edx; | ||
40 | unsigned long esi, edi, ebp; | ||
41 | unsigned long gs; | ||
42 | unsigned long fs, ds, es; | ||
43 | unsigned long trapnum, errcode; | ||
44 | /* Trap pushed part */ | ||
45 | unsigned long eip; | ||
46 | unsigned long cs; | ||
47 | unsigned long eflags; | ||
48 | unsigned long esp; | ||
49 | unsigned long ss; | ||
50 | }; | ||
51 | |||
52 | /* This is a guest-specific page (mapped ro) into the guest. */ | ||
53 | struct lguest_ro_state { | ||
54 | /* Host information we need to restore when we switch back. */ | ||
55 | u32 host_cr3; | ||
56 | struct desc_ptr host_idt_desc; | ||
57 | struct desc_ptr host_gdt_desc; | ||
58 | u32 host_sp; | ||
59 | |||
60 | /* Fields which are used when guest is running. */ | ||
61 | struct desc_ptr guest_idt_desc; | ||
62 | struct desc_ptr guest_gdt_desc; | ||
63 | struct x86_hw_tss guest_tss; | ||
64 | struct desc_struct guest_idt[IDT_ENTRIES]; | ||
65 | struct desc_struct guest_gdt[GDT_ENTRIES]; | ||
66 | }; | ||
67 | |||
68 | struct lg_cpu_arch { | ||
69 | /* The GDT entries copied into lguest_ro_state when running. */ | ||
70 | struct desc_struct gdt[GDT_ENTRIES]; | ||
71 | |||
72 | /* The IDT entries: some copied into lguest_ro_state when running. */ | ||
73 | struct desc_struct idt[IDT_ENTRIES]; | ||
74 | |||
75 | /* The address of the last guest-visible pagefault (ie. cr2). */ | ||
76 | unsigned long last_pagefault; | ||
77 | }; | ||
78 | |||
79 | static inline void lguest_set_ts(void) | ||
80 | { | ||
81 | u32 cr0; | ||
82 | |||
83 | cr0 = read_cr0(); | ||
84 | if (!(cr0 & 8)) | ||
85 | write_cr0(cr0 | 8); | ||
86 | } | ||
87 | |||
88 | /* Full 4G segment descriptors, suitable for CS and DS. */ | ||
89 | #define FULL_EXEC_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9b00} } }) | ||
90 | #define FULL_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9300} } }) | ||
91 | |||
92 | #endif /* __ASSEMBLY__ */ | ||
93 | |||
94 | #endif /* ASM_X86__LGUEST_H */ | ||