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
15#define SHARED_SWITCHER_PAGES \
16 DIV_ROUND_UP(end_switcher_text - start_switcher_text, PAGE_SIZE)
17
18#define TOTAL_SWITCHER_PAGES (SHARED_SWITCHER_PAGES + 2 * nr_cpu_ids)
19
20
21#ifdef CONFIG_X86_PAE
22#define SWITCHER_ADDR 0xFFE00000
23#else
24#define SWITCHER_ADDR 0xFFC00000
25#endif
26
27
28extern unsigned long default_idt_entries[];
29
30
31extern char lguest_noirq_start[], lguest_noirq_end[];
32extern const char lgstart_cli[], lgend_cli[];
33extern const char lgstart_sti[], lgend_sti[];
34extern const char lgstart_popf[], lgend_popf[];
35extern const char lgstart_pushf[], lgend_pushf[];
36extern const char lgstart_iret[], lgend_iret[];
37
38extern void lguest_iret(void);
39extern void lguest_init(void);
40
41struct lguest_regs {
42
43 unsigned long eax, ebx, ecx, edx;
44 unsigned long esi, edi, ebp;
45 unsigned long gs;
46 unsigned long fs, ds, es;
47 unsigned long trapnum, errcode;
48
49 unsigned long eip;
50 unsigned long cs;
51 unsigned long eflags;
52 unsigned long esp;
53 unsigned long ss;
54};
55
56
57struct lguest_ro_state {
58
59 u32 host_cr3;
60 struct desc_ptr host_idt_desc;
61 struct desc_ptr host_gdt_desc;
62 u32 host_sp;
63
64
65 struct desc_ptr guest_idt_desc;
66 struct desc_ptr guest_gdt_desc;
67 struct x86_hw_tss guest_tss;
68 struct desc_struct guest_idt[IDT_ENTRIES];
69 struct desc_struct guest_gdt[GDT_ENTRIES];
70};
71
72struct lg_cpu_arch {
73
74 struct desc_struct gdt[GDT_ENTRIES];
75
76
77 struct desc_struct idt[IDT_ENTRIES];
78
79
80 unsigned long last_pagefault;
81};
82
83static inline void lguest_set_ts(void)
84{
85 u32 cr0;
86
87 cr0 = read_cr0();
88 if (!(cr0 & 8))
89 write_cr0(cr0 | 8);
90}
91
92
93#define FULL_EXEC_SEGMENT \
94 ((struct desc_struct)GDT_ENTRY_INIT(0xc09b, 0, 0xfffff))
95#define FULL_SEGMENT ((struct desc_struct)GDT_ENTRY_INIT(0xc093, 0, 0xfffff))
96
97#endif
98
99#endif
100