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 | ||
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 */ | |
9628937d | 18 | #define TOTAL_SWITCHER_PAGES (SHARED_SWITCHER_PAGES + 2 * nr_cpu_ids) |
625efab1 | 19 | |
acdd0b62 MZ |
20 | /* We map at -4M (-2M when PAE is activated) for ease of mapping |
21 | * into the guest (one PTE page). */ | |
22 | #ifdef CONFIG_X86_PAE | |
23 | #define SWITCHER_ADDR 0xFFE00000 | |
24 | #else | |
625efab1 | 25 | #define SWITCHER_ADDR 0xFFC00000 |
acdd0b62 | 26 | #endif |
625efab1 JS |
27 | |
28 | /* Found in switcher.S */ | |
29 | extern unsigned long default_idt_entries[]; | |
30 | ||
cbc34973 HH |
31 | /* Declarations for definitions in lguest_guest.S */ |
32 | extern char lguest_noirq_start[], lguest_noirq_end[]; | |
33 | extern const char lgstart_cli[], lgend_cli[]; | |
34 | extern const char lgstart_sti[], lgend_sti[]; | |
35 | extern const char lgstart_popf[], lgend_popf[]; | |
36 | extern const char lgstart_pushf[], lgend_pushf[]; | |
37 | extern const char lgstart_iret[], lgend_iret[]; | |
38 | ||
39 | extern void lguest_iret(void); | |
40 | extern void lguest_init(void); | |
41 | ||
fb444c7b | 42 | struct lguest_regs { |
625efab1 | 43 | /* Manually saved part. */ |
4614a3a3 | 44 | unsigned long eax, ebx, ecx, edx; |
625efab1 JS |
45 | unsigned long esi, edi, ebp; |
46 | unsigned long gs; | |
625efab1 JS |
47 | unsigned long fs, ds, es; |
48 | unsigned long trapnum, errcode; | |
49 | /* Trap pushed part */ | |
50 | unsigned long eip; | |
51 | unsigned long cs; | |
52 | unsigned long eflags; | |
53 | unsigned long esp; | |
54 | unsigned long ss; | |
55 | }; | |
56 | ||
57 | /* This is a guest-specific page (mapped ro) into the guest. */ | |
fb444c7b | 58 | struct lguest_ro_state { |
625efab1 JS |
59 | /* Host information we need to restore when we switch back. */ |
60 | u32 host_cr3; | |
6b68f01b GOC |
61 | struct desc_ptr host_idt_desc; |
62 | struct desc_ptr host_gdt_desc; | |
625efab1 JS |
63 | u32 host_sp; |
64 | ||
65 | /* Fields which are used when guest is running. */ | |
6b68f01b GOC |
66 | struct desc_ptr guest_idt_desc; |
67 | struct desc_ptr guest_gdt_desc; | |
ca241c75 | 68 | struct x86_hw_tss guest_tss; |
625efab1 JS |
69 | struct desc_struct guest_idt[IDT_ENTRIES]; |
70 | struct desc_struct guest_gdt[GDT_ENTRIES]; | |
71 | }; | |
72 | ||
fb444c7b | 73 | struct lg_cpu_arch { |
625efab1 JS |
74 | /* The GDT entries copied into lguest_ro_state when running. */ |
75 | struct desc_struct gdt[GDT_ENTRIES]; | |
76 | ||
77 | /* The IDT entries: some copied into lguest_ro_state when running. */ | |
78 | struct desc_struct idt[IDT_ENTRIES]; | |
79 | ||
80 | /* The address of the last guest-visible pagefault (ie. cr2). */ | |
81 | unsigned long last_pagefault; | |
82 | }; | |
83 | ||
84 | static inline void lguest_set_ts(void) | |
85 | { | |
86 | u32 cr0; | |
87 | ||
88 | cr0 = read_cr0(); | |
89 | if (!(cr0 & 8)) | |
fb444c7b | 90 | write_cr0(cr0 | 8); |
625efab1 JS |
91 | } |
92 | ||
93 | /* Full 4G segment descriptors, suitable for CS and DS. */ | |
6842ef0e GOC |
94 | #define FULL_EXEC_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9b00} } }) |
95 | #define FULL_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9300} } }) | |
625efab1 JS |
96 | |
97 | #endif /* __ASSEMBLY__ */ | |
98 | ||
1965aae3 | 99 | #endif /* _ASM_X86_LGUEST_H */ |