diff options
Diffstat (limited to 'drivers/lguest/lg.h')
-rw-r--r-- | drivers/lguest/lg.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h index 3e2ddfbc816e..3b9dc123a7df 100644 --- a/drivers/lguest/lg.h +++ b/drivers/lguest/lg.h | |||
@@ -244,6 +244,30 @@ unsigned long get_dma_buffer(struct lguest *lg, unsigned long key, | |||
244 | /* hypercalls.c: */ | 244 | /* hypercalls.c: */ |
245 | void do_hypercalls(struct lguest *lg); | 245 | void do_hypercalls(struct lguest *lg); |
246 | 246 | ||
247 | /*L:035 | ||
248 | * Let's step aside for the moment, to study one important routine that's used | ||
249 | * widely in the Host code. | ||
250 | * | ||
251 | * There are many cases where the Guest does something invalid, like pass crap | ||
252 | * to a hypercall. Since only the Guest kernel can make hypercalls, it's quite | ||
253 | * acceptable to simply terminate the Guest and give the Launcher a nicely | ||
254 | * formatted reason. It's also simpler for the Guest itself, which doesn't | ||
255 | * need to check most hypercalls for "success"; if you're still running, it | ||
256 | * succeeded. | ||
257 | * | ||
258 | * Once this is called, the Guest will never run again, so most Host code can | ||
259 | * call this then continue as if nothing had happened. This means many | ||
260 | * functions don't have to explicitly return an error code, which keeps the | ||
261 | * code simple. | ||
262 | * | ||
263 | * It also means that this can be called more than once: only the first one is | ||
264 | * remembered. The only trick is that we still need to kill the Guest even if | ||
265 | * we can't allocate memory to store the reason. Linux has a neat way of | ||
266 | * packing error codes into invalid pointers, so we use that here. | ||
267 | * | ||
268 | * Like any macro which uses an "if", it is safely wrapped in a run-once "do { | ||
269 | * } while(0)". | ||
270 | */ | ||
247 | #define kill_guest(lg, fmt...) \ | 271 | #define kill_guest(lg, fmt...) \ |
248 | do { \ | 272 | do { \ |
249 | if (!(lg)->dead) { \ | 273 | if (!(lg)->dead) { \ |
@@ -252,6 +276,7 @@ do { \ | |||
252 | (lg)->dead = ERR_PTR(-ENOMEM); \ | 276 | (lg)->dead = ERR_PTR(-ENOMEM); \ |
253 | } \ | 277 | } \ |
254 | } while(0) | 278 | } while(0) |
279 | /* (End of aside) :*/ | ||
255 | 280 | ||
256 | static inline unsigned long guest_pa(struct lguest *lg, unsigned long vaddr) | 281 | static inline unsigned long guest_pa(struct lguest *lg, unsigned long vaddr) |
257 | { | 282 | { |