diff options
Diffstat (limited to 'drivers/lguest/interrupts_and_traps.c')
-rw-r--r-- | drivers/lguest/interrupts_and_traps.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c index 9c1c479e8c62..b87d9d6c36a4 100644 --- a/drivers/lguest/interrupts_and_traps.c +++ b/drivers/lguest/interrupts_and_traps.c | |||
@@ -73,8 +73,8 @@ static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi, int has_err) | |||
73 | if ((cpu->regs->ss&0x3) != GUEST_PL) { | 73 | if ((cpu->regs->ss&0x3) != GUEST_PL) { |
74 | /* The Guest told us their kernel stack with the SET_STACK | 74 | /* The Guest told us their kernel stack with the SET_STACK |
75 | * hypercall: both the virtual address and the segment */ | 75 | * hypercall: both the virtual address and the segment */ |
76 | virtstack = lg->esp1; | 76 | virtstack = cpu->esp1; |
77 | ss = lg->ss1; | 77 | ss = cpu->ss1; |
78 | 78 | ||
79 | origstack = gstack = guest_pa(lg, virtstack); | 79 | origstack = gstack = guest_pa(lg, virtstack); |
80 | /* We push the old stack segment and pointer onto the new | 80 | /* We push the old stack segment and pointer onto the new |
@@ -311,10 +311,11 @@ static int direct_trap(unsigned int num) | |||
311 | * the Guest. | 311 | * the Guest. |
312 | * | 312 | * |
313 | * Which is deeply unfair, because (literally!) it wasn't the Guests' fault. */ | 313 | * Which is deeply unfair, because (literally!) it wasn't the Guests' fault. */ |
314 | void pin_stack_pages(struct lguest *lg) | 314 | void pin_stack_pages(struct lg_cpu *cpu) |
315 | { | 315 | { |
316 | unsigned int i; | 316 | unsigned int i; |
317 | 317 | ||
318 | struct lguest *lg = cpu->lg; | ||
318 | /* Depending on the CONFIG_4KSTACKS option, the Guest can have one or | 319 | /* Depending on the CONFIG_4KSTACKS option, the Guest can have one or |
319 | * two pages of stack space. */ | 320 | * two pages of stack space. */ |
320 | for (i = 0; i < lg->stack_pages; i++) | 321 | for (i = 0; i < lg->stack_pages; i++) |
@@ -322,7 +323,7 @@ void pin_stack_pages(struct lguest *lg) | |||
322 | * start of the page after the kernel stack. Subtract one to | 323 | * start of the page after the kernel stack. Subtract one to |
323 | * get back onto the first stack page, and keep subtracting to | 324 | * get back onto the first stack page, and keep subtracting to |
324 | * get to the rest of the stack pages. */ | 325 | * get to the rest of the stack pages. */ |
325 | pin_page(lg, lg->esp1 - 1 - i * PAGE_SIZE); | 326 | pin_page(lg, cpu->esp1 - 1 - i * PAGE_SIZE); |
326 | } | 327 | } |
327 | 328 | ||
328 | /* Direct traps also mean that we need to know whenever the Guest wants to use | 329 | /* Direct traps also mean that we need to know whenever the Guest wants to use |
@@ -333,21 +334,21 @@ void pin_stack_pages(struct lguest *lg) | |||
333 | * | 334 | * |
334 | * In Linux each process has its own kernel stack, so this happens a lot: we | 335 | * In Linux each process has its own kernel stack, so this happens a lot: we |
335 | * change stacks on each context switch. */ | 336 | * change stacks on each context switch. */ |
336 | void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) | 337 | void guest_set_stack(struct lg_cpu *cpu, u32 seg, u32 esp, unsigned int pages) |
337 | { | 338 | { |
338 | /* You are not allowed have a stack segment with privilege level 0: bad | 339 | /* You are not allowed have a stack segment with privilege level 0: bad |
339 | * Guest! */ | 340 | * Guest! */ |
340 | if ((seg & 0x3) != GUEST_PL) | 341 | if ((seg & 0x3) != GUEST_PL) |
341 | kill_guest(lg, "bad stack segment %i", seg); | 342 | kill_guest(cpu->lg, "bad stack segment %i", seg); |
342 | /* We only expect one or two stack pages. */ | 343 | /* We only expect one or two stack pages. */ |
343 | if (pages > 2) | 344 | if (pages > 2) |
344 | kill_guest(lg, "bad stack pages %u", pages); | 345 | kill_guest(cpu->lg, "bad stack pages %u", pages); |
345 | /* Save where the stack is, and how many pages */ | 346 | /* Save where the stack is, and how many pages */ |
346 | lg->ss1 = seg; | 347 | cpu->ss1 = seg; |
347 | lg->esp1 = esp; | 348 | cpu->esp1 = esp; |
348 | lg->stack_pages = pages; | 349 | cpu->lg->stack_pages = pages; |
349 | /* Make sure the new stack pages are mapped */ | 350 | /* Make sure the new stack pages are mapped */ |
350 | pin_stack_pages(lg); | 351 | pin_stack_pages(cpu); |
351 | } | 352 | } |
352 | 353 | ||
353 | /* All this reference to mapping stacks leads us neatly into the other complex | 354 | /* All this reference to mapping stacks leads us neatly into the other complex |