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