diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-21 21:03:26 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-23 01:49:50 -0400 |
commit | 3c6b5bfa3cf3b4057788e08482a468cc3bc00780 (patch) | |
tree | f0d67890f6f8c9d0840c9b19a483ec06cbf822ef /drivers/lguest/hypercalls.c | |
parent | 6649bb7af6a819b675bfcf22ab704737e905645a (diff) |
Introduce guest mem offset, static link example launcher
In order to avoid problematic special linking of the Launcher, we give
the Host an offset: this means we can use any memory region in the
Launcher as Guest memory rather than insisting on mmap() at 0.
The result is quite pleasing: a number of casts are replaced with
simple additions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest/hypercalls.c')
-rw-r--r-- | drivers/lguest/hypercalls.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c index 5ecd60b54201..02e67b49ea4f 100644 --- a/drivers/lguest/hypercalls.c +++ b/drivers/lguest/hypercalls.c | |||
@@ -205,16 +205,19 @@ static void initialize(struct lguest *lg) | |||
205 | tsc_speed = 0; | 205 | tsc_speed = 0; |
206 | 206 | ||
207 | /* The pointer to the Guest's "struct lguest_data" is the only | 207 | /* The pointer to the Guest's "struct lguest_data" is the only |
208 | * argument. */ | 208 | * argument. We check that address now. */ |
209 | lg->lguest_data = (struct lguest_data __user *)lg->regs->edx; | ||
210 | /* If we check the address they gave is OK now, we can simply | ||
211 | * copy_to_user/from_user from now on rather than using lgread/lgwrite. | ||
212 | * I put this in to show that I'm not immune to writing stupid | ||
213 | * optimizations. */ | ||
214 | if (!lguest_address_ok(lg, lg->regs->edx, sizeof(*lg->lguest_data))) { | 209 | if (!lguest_address_ok(lg, lg->regs->edx, sizeof(*lg->lguest_data))) { |
215 | kill_guest(lg, "bad guest page %p", lg->lguest_data); | 210 | kill_guest(lg, "bad guest page %p", lg->lguest_data); |
216 | return; | 211 | return; |
217 | } | 212 | } |
213 | |||
214 | /* Having checked it, we simply set lg->lguest_data to point straight | ||
215 | * into the Launcher's memory at the right place and then use | ||
216 | * copy_to_user/from_user from now on, instead of lgread/write. I put | ||
217 | * this in to show that I'm not immune to writing stupid | ||
218 | * optimizations. */ | ||
219 | lg->lguest_data = lg->mem_base + lg->regs->edx; | ||
220 | |||
218 | /* The Guest tells us where we're not to deliver interrupts by putting | 221 | /* The Guest tells us where we're not to deliver interrupts by putting |
219 | * the range of addresses into "struct lguest_data". */ | 222 | * the range of addresses into "struct lguest_data". */ |
220 | if (get_user(lg->noirq_start, &lg->lguest_data->noirq_start) | 223 | if (get_user(lg->noirq_start, &lg->lguest_data->noirq_start) |