aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2007-07-19 04:49:23 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:52 -0400
commitd7e28ffe6c74416b54345d6004fd0964c115b12c (patch)
tree844beb4f400d5400098538e0c1e5f12d20a9504a /include
parent07ad157f6e5d228be78acd5cea0291e5d0360398 (diff)
lguest: the host code
This is the code for the "lg.ko" module, which allows lguest guests to be launched. [akpm@linux-foundation.org: update for futex-new-private-futexes] [akpm@linux-foundation.org: build fix] [jmorris@namei.org: lguest: use hrtimers] [akpm@linux-foundation.org: x86_64 build fix] Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Cc: Andi Kleen <ak@suse.de> Cc: Eric Dumazet <dada1@cosmosbay.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/asm-i386/tsc.h1
-rw-r--r--include/linux/lguest.h12
-rw-r--r--include/linux/lguest_launcher.h73
3 files changed, 80 insertions, 6 deletions
diff --git a/include/asm-i386/tsc.h b/include/asm-i386/tsc.h
index 62c091ffcccc..a4d806610b7f 100644
--- a/include/asm-i386/tsc.h
+++ b/include/asm-i386/tsc.h
@@ -63,6 +63,7 @@ extern void tsc_init(void);
63extern void mark_tsc_unstable(char *reason); 63extern void mark_tsc_unstable(char *reason);
64extern int unsynchronized_tsc(void); 64extern int unsynchronized_tsc(void);
65extern void init_tsc_clocksource(void); 65extern void init_tsc_clocksource(void);
66int check_tsc_unstable(void);
66 67
67/* 68/*
68 * Boot-time check whether the TSCs are synchronized across 69 * Boot-time check whether the TSCs are synchronized across
diff --git a/include/linux/lguest.h b/include/linux/lguest.h
index f30c04fc22b7..500aace21ca7 100644
--- a/include/linux/lguest.h
+++ b/include/linux/lguest.h
@@ -3,11 +3,6 @@
3#ifndef _ASM_LGUEST_H 3#ifndef _ASM_LGUEST_H
4#define _ASM_LGUEST_H 4#define _ASM_LGUEST_H
5 5
6/* These are randomly chosen numbers which indicate we're an lguest at boot */
7#define LGUEST_MAGIC_EBP 0x4C687970
8#define LGUEST_MAGIC_EDI 0x652D4D65
9#define LGUEST_MAGIC_ESI 0xFFFFFFFF
10
11#ifndef __ASSEMBLY__ 6#ifndef __ASSEMBLY__
12#include <asm/irq.h> 7#include <asm/irq.h>
13 8
@@ -20,7 +15,7 @@
20#define LHCALL_LOAD_IDT_ENTRY 6 15#define LHCALL_LOAD_IDT_ENTRY 6
21#define LHCALL_SET_STACK 7 16#define LHCALL_SET_STACK 7
22#define LHCALL_TS 8 17#define LHCALL_TS 8
23#define LHCALL_TIMER_READ 9 18#define LHCALL_SET_CLOCKEVENT 9
24#define LHCALL_HALT 10 19#define LHCALL_HALT 10
25#define LHCALL_GET_WALLCLOCK 11 20#define LHCALL_GET_WALLCLOCK 11
26#define LHCALL_BIND_DMA 12 21#define LHCALL_BIND_DMA 12
@@ -29,6 +24,9 @@
29#define LHCALL_SET_PMD 15 24#define LHCALL_SET_PMD 15
30#define LHCALL_LOAD_TLS 16 25#define LHCALL_LOAD_TLS 16
31 26
27#define LG_CLOCK_MIN_DELTA 100UL
28#define LG_CLOCK_MAX_DELTA ULONG_MAX
29
32#define LGUEST_TRAP_ENTRY 0x1F 30#define LGUEST_TRAP_ENTRY 0x1F
33 31
34static inline unsigned long 32static inline unsigned long
@@ -75,6 +73,8 @@ struct lguest_data
75 unsigned long reserve_mem; 73 unsigned long reserve_mem;
76 /* ID of this guest (used by network driver to set ethernet address) */ 74 /* ID of this guest (used by network driver to set ethernet address) */
77 u16 guestid; 75 u16 guestid;
76 /* KHz for the TSC clock. */
77 u32 tsc_khz;
78 78
79/* Fields initialized by the guest at boot: */ 79/* Fields initialized by the guest at boot: */
80 /* Instruction range to suppress interrupts even if enabled */ 80 /* Instruction range to suppress interrupts even if enabled */
diff --git a/include/linux/lguest_launcher.h b/include/linux/lguest_launcher.h
new file mode 100644
index 000000000000..0ba414a40c80
--- /dev/null
+++ b/include/linux/lguest_launcher.h
@@ -0,0 +1,73 @@
1#ifndef _ASM_LGUEST_USER
2#define _ASM_LGUEST_USER
3/* Everything the "lguest" userspace program needs to know. */
4/* They can register up to 32 arrays of lguest_dma. */
5#define LGUEST_MAX_DMA 32
6/* At most we can dma 16 lguest_dma in one op. */
7#define LGUEST_MAX_DMA_SECTIONS 16
8
9/* How many devices? Assume each one wants up to two dma arrays per device. */
10#define LGUEST_MAX_DEVICES (LGUEST_MAX_DMA/2)
11
12struct lguest_dma
13{
14 /* 0 if free to be used, filled by hypervisor. */
15 u32 used_len;
16 unsigned long addr[LGUEST_MAX_DMA_SECTIONS];
17 u16 len[LGUEST_MAX_DMA_SECTIONS];
18};
19
20struct lguest_block_page
21{
22 /* 0 is a read, 1 is a write. */
23 int type;
24 u32 sector; /* Offset in device = sector * 512. */
25 u32 bytes; /* Length expected to be read/written in bytes */
26 /* 0 = pending, 1 = done, 2 = done, error */
27 int result;
28 u32 num_sectors; /* Disk length = num_sectors * 512 */
29};
30
31/* There is a shared page of these. */
32struct lguest_net
33{
34 /* Simply the mac address (with multicast bit meaning promisc). */
35 unsigned char mac[6];
36};
37
38/* Where the Host expects the Guest to SEND_DMA console output to. */
39#define LGUEST_CONSOLE_DMA_KEY 0
40
41/* We have a page of these descriptors in the lguest_device page. */
42struct lguest_device_desc {
43 u16 type;
44#define LGUEST_DEVICE_T_CONSOLE 1
45#define LGUEST_DEVICE_T_NET 2
46#define LGUEST_DEVICE_T_BLOCK 3
47
48 u16 features;
49#define LGUEST_NET_F_NOCSUM 0x4000 /* Don't bother checksumming */
50#define LGUEST_DEVICE_F_RANDOMNESS 0x8000 /* IRQ is fairly random */
51
52 u16 status;
53/* 256 and above are device specific. */
54#define LGUEST_DEVICE_S_ACKNOWLEDGE 1 /* We have seen device. */
55#define LGUEST_DEVICE_S_DRIVER 2 /* We have found a driver */
56#define LGUEST_DEVICE_S_DRIVER_OK 4 /* Driver says OK! */
57#define LGUEST_DEVICE_S_REMOVED 8 /* Device has gone away. */
58#define LGUEST_DEVICE_S_REMOVED_ACK 16 /* Driver has been told. */
59#define LGUEST_DEVICE_S_FAILED 128 /* Something actually failed */
60
61 u16 num_pages;
62 u32 pfn;
63};
64
65/* Write command first word is a request. */
66enum lguest_req
67{
68 LHREQ_INITIALIZE, /* + pfnlimit, pgdir, start, pageoffset */
69 LHREQ_GETDMA, /* + addr (returns &lguest_dma, irq in ->used_len) */
70 LHREQ_IRQ, /* + irq */
71 LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */
72};
73#endif /* _ASM_LGUEST_USER */