blob: 9962c6bb1311f199ce91600d22724fd7599020dd [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 Russell1842f232009-07-30 16:03:46 -060021struct lguest_data {
Rusty Russell2e04ef72009-07-30 16:03:45 -060022 /*
23 * 512 == enabled (same as eflags in normal hardware). The Guest
24 * changes interrupts so often that a hypercall is too slow.
25 */
Rusty Russell07ad1572007-07-19 01:49:22 -070026 unsigned int irq_enabled;
Rusty Russellb2b47c22007-07-26 10:41:02 -070027 /* Fine-grained interrupt disabling by the Guest */
Rusty Russell07ad1572007-07-19 01:49:22 -070028 DECLARE_BITMAP(blocked_interrupts, LGUEST_IRQS);
29
Rusty Russell2e04ef72009-07-30 16:03:45 -060030 /*
31 * The Host writes the virtual address of the last page fault here,
Rusty Russellb2b47c22007-07-26 10:41:02 -070032 * which saves the Guest a hypercall. CR2 is the native register where
Rusty Russell2e04ef72009-07-30 16:03:45 -060033 * this address would normally be found.
34 */
Rusty Russell07ad1572007-07-19 01:49:22 -070035 unsigned long cr2;
36
Rusty Russell6c8dca52007-07-27 13:42:52 +100037 /* Wallclock time set by the Host. */
38 struct timespec time;
39
Rusty Russell2e04ef72009-07-30 16:03:45 -060040 /*
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 Russella32a8812009-06-12 22:27:02 -060044 int irq_pending;
45
Rusty Russell2e04ef72009-07-30 16:03:45 -060046 /*
47 * Async hypercall ring. Instead of directly making hypercalls, we can
Rusty Russellb2b47c22007-07-26 10:41:02 -070048 * place them in here for processing the next time the Host wants.
Rusty Russell2e04ef72009-07-30 16:03:45 -060049 * This batching can be quite efficient.
50 */
Rusty Russellb2b47c22007-07-26 10:41:02 -070051
52 /* 0xFF == done (set by Host), 0 == pending (set by Guest). */
Rusty Russell07ad1572007-07-19 01:49:22 -070053 u8 hcall_status[LHCALL_RING_SIZE];
Rusty Russellb2b47c22007-07-26 10:41:02 -070054 /* The actual registers for the hypercalls. */
Jes Sorensenb410e7b2007-10-22 11:03:31 +100055 struct hcall_args hcalls[LHCALL_RING_SIZE];
Rusty Russell07ad1572007-07-19 01:49:22 -070056
Rusty Russellb2b47c22007-07-26 10:41:02 -070057/* Fields initialized by the Host at boot: */
Rusty Russell07ad1572007-07-19 01:49:22 -070058 /* Memory not to try to access */
59 unsigned long reserve_mem;
Rusty Russelld7e28ff2007-07-19 01:49:23 -070060 /* KHz for the TSC clock. */
61 u32 tsc_khz;
Rusty Russell07ad1572007-07-19 01:49:22 -070062
Rusty Russellb2b47c22007-07-26 10:41:02 -070063/* Fields initialized by the Guest at boot: */
Rusty Russell07ad1572007-07-19 01:49:22 -070064 /* Instruction range to suppress interrupts even if enabled */
65 unsigned long noirq_start, noirq_end;
Rusty Russell47436aa2007-10-22 11:03:36 +100066 /* Address above which page tables are all identical. */
67 unsigned long kernel_address;
Rusty Russellc18acd72007-10-22 11:03:35 +100068 /* The vector to try to use for system calls (0x40 or 0x80). */
69 unsigned int syscall_vec;
Rusty Russell07ad1572007-07-19 01:49:22 -070070};
71extern struct lguest_data lguest_data;
72#endif /* __ASSEMBLY__ */
Jes Sorensenc37ae932007-10-22 10:56:26 +100073#endif /* _LINUX_LGUEST_H */