aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2007-10-21 21:03:28 -0400
committerRusty Russell <rusty@rustcorp.com.au>2007-10-23 01:49:51 -0400
commit625efab1cd3d4da4634dfe26df6b4005385397e2 (patch)
treee08cd714edece430ae8a8aef894adfadbccc064a /include
parent56adbe9ddc935600c64635d6a55c260a63c67e4a (diff)
Move i386 part of core.c to x86/core.c.
Separate i386 architecture specific from core.c and move it to x86/core.c and add x86/lguest.h header file to match. Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include')
-rw-r--r--include/asm-x86/lguest.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/include/asm-x86/lguest.h b/include/asm-x86/lguest.h
new file mode 100644
index 000000000000..f10f1c6cc3d1
--- /dev/null
+++ b/include/asm-x86/lguest.h
@@ -0,0 +1,87 @@
1#ifndef _X86_LGUEST_H
2#define _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 */
24extern unsigned long default_idt_entries[];
25
26struct lguest_regs
27{
28 /* Manually saved part. */
29 unsigned long ebx, ecx, edx;
30 unsigned long esi, edi, ebp;
31 unsigned long gs;
32 unsigned long eax;
33 unsigned long fs, ds, es;
34 unsigned long trapnum, errcode;
35 /* Trap pushed part */
36 unsigned long eip;
37 unsigned long cs;
38 unsigned long eflags;
39 unsigned long esp;
40 unsigned long ss;
41};
42
43/* This is a guest-specific page (mapped ro) into the guest. */
44struct lguest_ro_state
45{
46 /* Host information we need to restore when we switch back. */
47 u32 host_cr3;
48 struct Xgt_desc_struct host_idt_desc;
49 struct Xgt_desc_struct host_gdt_desc;
50 u32 host_sp;
51
52 /* Fields which are used when guest is running. */
53 struct Xgt_desc_struct guest_idt_desc;
54 struct Xgt_desc_struct guest_gdt_desc;
55 struct i386_hw_tss guest_tss;
56 struct desc_struct guest_idt[IDT_ENTRIES];
57 struct desc_struct guest_gdt[GDT_ENTRIES];
58};
59
60struct lguest_arch
61{
62 /* The GDT entries copied into lguest_ro_state when running. */
63 struct desc_struct gdt[GDT_ENTRIES];
64
65 /* The IDT entries: some copied into lguest_ro_state when running. */
66 struct desc_struct idt[IDT_ENTRIES];
67
68 /* The address of the last guest-visible pagefault (ie. cr2). */
69 unsigned long last_pagefault;
70};
71
72static inline void lguest_set_ts(void)
73{
74 u32 cr0;
75
76 cr0 = read_cr0();
77 if (!(cr0 & 8))
78 write_cr0(cr0|8);
79}
80
81/* Full 4G segment descriptors, suitable for CS and DS. */
82#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00})
83#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300})
84
85#endif /* __ASSEMBLY__ */
86
87#endif