| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 1 | /* | 
 | 2 |  * Things the lguest guest needs to know.  Note: like all lguest interfaces, | 
 | 3 |  * this is subject to wild and random change between versions. | 
 | 4 |  */ | 
| Jes Sorensen | c37ae93 | 2007-10-22 10:56:26 +1000 | [diff] [blame] | 5 | #ifndef _LINUX_LGUEST_H | 
 | 6 | #define _LINUX_LGUEST_H | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 7 |  | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 8 | #ifndef __ASSEMBLY__ | 
| Jes Sorensen | 47aee45 | 2007-10-22 11:03:33 +1000 | [diff] [blame] | 9 | #include <linux/time.h> | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 10 | #include <asm/irq.h> | 
| Jes Sorensen | c37ae93 | 2007-10-22 10:56:26 +1000 | [diff] [blame] | 11 | #include <asm/lguest_hcall.h> | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 12 |  | 
| Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 13 | #define LG_CLOCK_MIN_DELTA	100UL | 
 | 14 | #define LG_CLOCK_MAX_DELTA	ULONG_MAX | 
 | 15 |  | 
| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 16 | /*G:031 | 
 | 17 |  * The second method of communicating with the Host is to via "struct | 
| Rusty Russell | e1e7296 | 2007-10-25 15:02:50 +1000 | [diff] [blame] | 18 |  * lguest_data".  Once the Guest's initialization hypercall tells the Host where | 
| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 19 |  * this is, the Guest and Host both publish information in it. | 
 | 20 | :*/ | 
| Rusty Russell | 1842f23 | 2009-07-30 16:03:46 -0600 | [diff] [blame] | 21 | struct lguest_data { | 
| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 22 | 	/* | 
 | 23 | 	 * 512 == enabled (same as eflags in normal hardware).  The Guest | 
 | 24 | 	 * changes interrupts so often that a hypercall is too slow. | 
 | 25 | 	 */ | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 26 | 	unsigned int irq_enabled; | 
| Rusty Russell | b2b47c2 | 2007-07-26 10:41:02 -0700 | [diff] [blame] | 27 | 	/* Fine-grained interrupt disabling by the Guest */ | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 28 | 	DECLARE_BITMAP(blocked_interrupts, LGUEST_IRQS); | 
 | 29 |  | 
| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 30 | 	/* | 
 | 31 | 	 * The Host writes the virtual address of the last page fault here, | 
| Rusty Russell | b2b47c2 | 2007-07-26 10:41:02 -0700 | [diff] [blame] | 32 | 	 * which saves the Guest a hypercall.  CR2 is the native register where | 
| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 33 | 	 * this address would normally be found. | 
 | 34 | 	 */ | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 35 | 	unsigned long cr2; | 
 | 36 |  | 
| Rusty Russell | 6c8dca5 | 2007-07-27 13:42:52 +1000 | [diff] [blame] | 37 | 	/* Wallclock time set by the Host. */ | 
 | 38 | 	struct timespec time; | 
 | 39 |  | 
| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 40 | 	/* | 
 | 41 | 	 * Interrupt pending set by the Host.  The Guest should do a hypercall | 
 | 42 | 	 * if it re-enables interrupts and sees this set (to X86_EFLAGS_IF). | 
 | 43 | 	 */ | 
| Rusty Russell | a32a881 | 2009-06-12 22:27:02 -0600 | [diff] [blame] | 44 | 	int irq_pending; | 
 | 45 |  | 
| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 46 | 	/* | 
 | 47 | 	 * Async hypercall ring.  Instead of directly making hypercalls, we can | 
| Rusty Russell | b2b47c2 | 2007-07-26 10:41:02 -0700 | [diff] [blame] | 48 | 	 * place them in here for processing the next time the Host wants. | 
| Rusty Russell | 2e04ef7 | 2009-07-30 16:03:45 -0600 | [diff] [blame] | 49 | 	 * This batching can be quite efficient. | 
 | 50 | 	 */ | 
| Rusty Russell | b2b47c2 | 2007-07-26 10:41:02 -0700 | [diff] [blame] | 51 |  | 
 | 52 | 	/* 0xFF == done (set by Host), 0 == pending (set by Guest). */ | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 53 | 	u8 hcall_status[LHCALL_RING_SIZE]; | 
| Rusty Russell | b2b47c2 | 2007-07-26 10:41:02 -0700 | [diff] [blame] | 54 | 	/* The actual registers for the hypercalls. */ | 
| Jes Sorensen | b410e7b | 2007-10-22 11:03:31 +1000 | [diff] [blame] | 55 | 	struct hcall_args hcalls[LHCALL_RING_SIZE]; | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 56 |  | 
| Rusty Russell | b2b47c2 | 2007-07-26 10:41:02 -0700 | [diff] [blame] | 57 | /* Fields initialized by the Host at boot: */ | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 58 | 	/* Memory not to try to access */ | 
 | 59 | 	unsigned long reserve_mem; | 
| Rusty Russell | d7e28ff | 2007-07-19 01:49:23 -0700 | [diff] [blame] | 60 | 	/* KHz for the TSC clock. */ | 
 | 61 | 	u32 tsc_khz; | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 62 |  | 
| Rusty Russell | b2b47c2 | 2007-07-26 10:41:02 -0700 | [diff] [blame] | 63 | /* Fields initialized by the Guest at boot: */ | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 64 | 	/* Instruction range to suppress interrupts even if enabled */ | 
 | 65 | 	unsigned long noirq_start, noirq_end; | 
| Rusty Russell | 47436aa | 2007-10-22 11:03:36 +1000 | [diff] [blame] | 66 | 	/* Address above which page tables are all identical. */ | 
 | 67 | 	unsigned long kernel_address; | 
| Rusty Russell | c18acd7 | 2007-10-22 11:03:35 +1000 | [diff] [blame] | 68 | 	/* The vector to try to use for system calls (0x40 or 0x80). */ | 
 | 69 | 	unsigned int syscall_vec; | 
| Rusty Russell | 07ad157 | 2007-07-19 01:49:22 -0700 | [diff] [blame] | 70 | }; | 
 | 71 | extern struct lguest_data lguest_data; | 
 | 72 | #endif /* __ASSEMBLY__ */ | 
| Jes Sorensen | c37ae93 | 2007-10-22 10:56:26 +1000 | [diff] [blame] | 73 | #endif	/* _LINUX_LGUEST_H */ |