| 
									
										
										
										
											2008-10-22 22:26:29 -07:00
										 |  |  | #ifndef _ASM_X86_LGUEST_H
 | 
					
						
							|  |  |  | #define _ASM_X86_LGUEST_H
 | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define GDT_ENTRY_LGUEST_CS	10
 | 
					
						
							|  |  |  | #define GDT_ENTRY_LGUEST_DS	11
 | 
					
						
							|  |  |  | #define LGUEST_CS		(GDT_ENTRY_LGUEST_CS * 8)
 | 
					
						
							|  |  |  | #define LGUEST_DS		(GDT_ENTRY_LGUEST_DS * 8)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __ASSEMBLY__
 | 
					
						
							|  |  |  | #include <asm/desc.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define GUEST_PL 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-22 14:10:38 +09:30
										 |  |  | /* Page for Switcher text itself, then two pages per cpu */ | 
					
						
							|  |  |  | #define TOTAL_SWITCHER_PAGES (1 + 2 * nr_cpu_ids)
 | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-22 14:10:37 +09:30
										 |  |  | /* Where we map the Switcher, in both Host and Guest. */ | 
					
						
							|  |  |  | extern unsigned long switcher_addr; | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Found in switcher.S */ | 
					
						
							|  |  |  | extern unsigned long default_idt_entries[]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-13 13:14:35 -08:00
										 |  |  | /* Declarations for definitions in lguest_guest.S */ | 
					
						
							|  |  |  | extern char lguest_noirq_start[], lguest_noirq_end[]; | 
					
						
							|  |  |  | extern const char lgstart_cli[], lgend_cli[]; | 
					
						
							|  |  |  | extern const char lgstart_sti[], lgend_sti[]; | 
					
						
							|  |  |  | extern const char lgstart_popf[], lgend_popf[]; | 
					
						
							|  |  |  | extern const char lgstart_pushf[], lgend_pushf[]; | 
					
						
							|  |  |  | extern const char lgstart_iret[], lgend_iret[]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern void lguest_iret(void); | 
					
						
							|  |  |  | extern void lguest_init(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-23 01:02:37 -07:00
										 |  |  | struct lguest_regs { | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 	/* Manually saved part. */ | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:29 +10:00
										 |  |  | 	unsigned long eax, ebx, ecx, edx; | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 	unsigned long esi, edi, ebp; | 
					
						
							|  |  |  | 	unsigned long gs; | 
					
						
							|  |  |  | 	unsigned long fs, ds, es; | 
					
						
							|  |  |  | 	unsigned long trapnum, errcode; | 
					
						
							|  |  |  | 	/* Trap pushed part */ | 
					
						
							|  |  |  | 	unsigned long eip; | 
					
						
							|  |  |  | 	unsigned long cs; | 
					
						
							|  |  |  | 	unsigned long eflags; | 
					
						
							|  |  |  | 	unsigned long esp; | 
					
						
							|  |  |  | 	unsigned long ss; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* This is a guest-specific page (mapped ro) into the guest. */ | 
					
						
							| 
									
										
										
										
											2008-03-23 01:02:37 -07:00
										 |  |  | struct lguest_ro_state { | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 	/* Host information we need to restore when we switch back. */ | 
					
						
							|  |  |  | 	u32 host_cr3; | 
					
						
							| 
									
										
										
										
											2008-01-30 13:31:12 +01:00
										 |  |  | 	struct desc_ptr host_idt_desc; | 
					
						
							|  |  |  | 	struct desc_ptr host_gdt_desc; | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 	u32 host_sp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Fields which are used when guest is running. */ | 
					
						
							| 
									
										
										
										
											2008-01-30 13:31:12 +01:00
										 |  |  | 	struct desc_ptr guest_idt_desc; | 
					
						
							|  |  |  | 	struct desc_ptr guest_gdt_desc; | 
					
						
							| 
									
										
										
										
											2008-01-30 13:31:31 +01:00
										 |  |  | 	struct x86_hw_tss guest_tss; | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 	struct desc_struct guest_idt[IDT_ENTRIES]; | 
					
						
							|  |  |  | 	struct desc_struct guest_gdt[GDT_ENTRIES]; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-23 01:02:37 -07:00
										 |  |  | struct lg_cpu_arch { | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 	/* The GDT entries copied into lguest_ro_state when running. */ | 
					
						
							|  |  |  | 	struct desc_struct gdt[GDT_ENTRIES]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* The IDT entries: some copied into lguest_ro_state when running. */ | 
					
						
							|  |  |  | 	struct desc_struct idt[IDT_ENTRIES]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* The address of the last guest-visible pagefault (ie. cr2). */ | 
					
						
							|  |  |  | 	unsigned long last_pagefault; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void lguest_set_ts(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u32 cr0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	cr0 = read_cr0(); | 
					
						
							|  |  |  | 	if (!(cr0 & 8)) | 
					
						
							| 
									
										
										
										
											2008-03-23 01:02:37 -07:00
										 |  |  | 		write_cr0(cr0 | 8); | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Full 4G segment descriptors, suitable for CS and DS. */ | 
					
						
							| 
									
										
										
										
											2009-07-19 00:12:20 +09:00
										 |  |  | #define FULL_EXEC_SEGMENT \
 | 
					
						
							|  |  |  | 	((struct desc_struct)GDT_ENTRY_INIT(0xc09b, 0, 0xfffff)) | 
					
						
							|  |  |  | #define FULL_SEGMENT ((struct desc_struct)GDT_ENTRY_INIT(0xc093, 0, 0xfffff))
 | 
					
						
							| 
									
										
										
										
											2007-10-22 11:03:28 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif /* __ASSEMBLY__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-22 22:26:29 -07:00
										 |  |  | #endif /* _ASM_X86_LGUEST_H */
 |