blob: 0a3a11afd64b3a8d8bfe1b4a6b314ce18bffc971 [file] [log] [blame]
Rusty Russell2e04ef72009-07-30 16:03:45 -06001/*
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 Sorensenc37ae932007-10-22 10:56:26 +10005#ifndef _LINUX_LGUEST_H
6#define _LINUX_LGUEST_H
Rusty Russell07ad1572007-07-19 01:49:22 -07007
Rusty Russell07ad1572007-07-19 01:49:22 -07008#ifndef __ASSEMBLY__
Jes Sorensen47aee452007-10-22 11:03:33 +10009#include <linux/time.h>
Rusty Russell07ad1572007-07-19 01:49:22 -070010#include <asm/irq.h>
Jes Sorensenc37ae932007-10-22 10:56:26 +100011#include <asm/lguest_hcall.h>
Rusty Russell07ad1572007-07-19 01:49:22 -070012
Rusty Russelld7e28ff2007-07-19 01:49:23 -070013#define LG_CLOCK_MIN_DELTA 100UL
14#define LG_CLOCK_MAX_DELTA ULONG_MAX
15
Rusty Russell2e04ef72009-07-30 16:03:45 -060016/*G:031
17 * The second method of communicating with the Host is to via "struct
Rusty Russelle1e72962007-10-25 15:02:50 +100018 * lguest_data". Once the Guest's initialization hypercall tells the Host where
Rusty Russell2e04ef72009-07-30 16:03:45 -060019 * this is, the Guest and Host both publish information in it.
20:*/
Rusty Russell07ad1572007-07-19 01:49:22 -070021struct lguest_data
22{
Rusty Russell2e04ef72009-07-30 16:03:45 -060023 /*
24 * 512 == enabled (same as eflags in normal hardware). The Guest
25 * changes interrupts so often that a hypercall is too slow.
26 */
Rusty Russell07ad1572007-07-19 01:49:22 -070027 unsigned int irq_enabled;
Rusty Russellb2b47c22007-07-26 10:41:02 -070028 /* Fine-grained interrupt disabling by the Guest */
Rusty Russell07ad1572007-07-19 01:49:22 -070029 DECLARE_BITMAP(blocked_interrupts, LGUEST_IRQS);
30
Rusty Russell2e04ef72009-07-30 16:03:45 -060031 /*
32 * The Host writes the virtual address of the last page fault here,
Rusty Russellb2b47c22007-07-26 10:41:02 -070033 * which saves the Guest a hypercall. CR2 is the native register where
Rusty Russell2e04ef72009-07-30 16:03:45 -060034 * this address would normally be found.
35 */
Rusty Russell07ad1572007-07-19 01:49:22 -070036 unsigned long cr2;
37
Rusty Russell6c8dca52007-07-27 13:42:52 +100038 /* Wallclock time set by the Host. */
39 struct timespec time;
40
Rusty Russell2e04ef72009-07-30 16:03:45 -060041 /*
42 * Interrupt pending set by the Host. The Guest should do a hypercall
43 * if it re-enables interrupts and sees this set (to X86_EFLAGS_IF).
44 */
Rusty Russella32a88132009-06-12 22:27:02 -060045 int irq_pending;
46
Rusty Russell2e04ef72009-07-30 16:03:45 -060047 /*
48 * Async hypercall ring. Instead of directly making hypercalls, we can
Rusty Russellb2b47c22007-07-26 10:41:02 -070049 * place them in here for processing the next time the Host wants.
Rusty Russell2e04ef72009-07-30 16:03:45 -060050 * This batching can be quite efficient.
51 */
Rusty Russellb2b47c22007-07-26 10:41:02 -070052
53 /* 0xFF == done (set by Host), 0 == pending (set by Guest). */
Rusty Russell07ad1572007-07-19 01:49:22 -070054 u8 hcall_status[LHCALL_RING_SIZE];
Rusty Russellb2b47c22007-07-26 10:41:02 -070055 /* The actual registers for the hypercalls. */
Jes Sorensenb410e7b2007-10-22 11:03:31 +100056 struct hcall_args hcalls[LHCALL_RING_SIZE];
Rusty Russell07ad1572007-07-19 01:49:22 -070057
Rusty Russellb2b47c22007-07-26 10:41:02 -070058/* Fields initialized by the Host at boot: */
Rusty Russell07ad1572007-07-19 01:49:22 -070059 /* Memory not to try to access */
60 unsigned long reserve_mem;
Rusty Russelld7e28ff2007-07-19 01:49:23 -070061 /* KHz for the TSC clock. */
62 u32 tsc_khz;
Rusty Russell47436aa2007-10-22 11:03:36 +100063 /* Page where the top-level pagetable is */
64 unsigned long pgdir;
Rusty Russell07ad1572007-07-19 01:49:22 -070065
Rusty Russellb2b47c22007-07-26 10:41:02 -070066/* Fields initialized by the Guest at boot: */
Rusty Russell07ad1572007-07-19 01:49:22 -070067 /* Instruction range to suppress interrupts even if enabled */
68 unsigned long noirq_start, noirq_end;
Rusty Russell47436aa2007-10-22 11:03:36 +100069 /* Address above which page tables are all identical. */
70 unsigned long kernel_address;
Rusty Russellc18acd72007-10-22 11:03:35 +100071 /* The vector to try to use for system calls (0x40 or 0x80). */
72 unsigned int syscall_vec;
Rusty Russell07ad1572007-07-19 01:49:22 -070073};
74extern struct lguest_data lguest_data;
75#endif /* __ASSEMBLY__ */
Jes Sorensenc37ae932007-10-22 10:56:26 +100076#endif /* _LINUX_LGUEST_H */