diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-08-29 16:35:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-08-30 12:58:22 -0400 |
commit | 8057d763ed7a7365dc3402db0aed7c87d8531ecb (patch) | |
tree | 5a04fee7709eeed4babb70296302b1d49e64b37c | |
parent | b07d68b5ca4d55a16fab223d63d5fb36f89ff42f (diff) |
Fix lguest page-pinning logic ("lguest: bad stack page 0xc057a000")
If the stack pointer is 0xc057a000, then the first stack page is at
0xc0579000 (the stack pointer is decremented before use). Not
calculating this correctly caused guests with CONFIG_DEBUG_PAGEALLOC=y
to be killed with a "bad stack page" message: the initial kernel stack
was just proceeding the .smp_locks section which
CONFIG_DEBUG_PAGEALLOC marks read-only when freeing.
Thanks to Frederik Deweerdt for the bug report!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/lguest/interrupts_and_traps.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c index 49aa55577d0d..39731232d827 100644 --- a/drivers/lguest/interrupts_and_traps.c +++ b/drivers/lguest/interrupts_and_traps.c | |||
@@ -270,8 +270,11 @@ void pin_stack_pages(struct lguest *lg) | |||
270 | /* Depending on the CONFIG_4KSTACKS option, the Guest can have one or | 270 | /* Depending on the CONFIG_4KSTACKS option, the Guest can have one or |
271 | * two pages of stack space. */ | 271 | * two pages of stack space. */ |
272 | for (i = 0; i < lg->stack_pages; i++) | 272 | for (i = 0; i < lg->stack_pages; i++) |
273 | /* The stack grows *upwards*, hence the subtraction */ | 273 | /* The stack grows *upwards*, so the address we're given is the |
274 | pin_page(lg, lg->esp1 - i * PAGE_SIZE); | 274 | * start of the page after the kernel stack. Subtract one to |
275 | * get back onto the first stack page, and keep subtracting to | ||
276 | * get to the rest of the stack pages. */ | ||
277 | pin_page(lg, lg->esp1 - 1 - i * PAGE_SIZE); | ||
275 | } | 278 | } |
276 | 279 | ||
277 | /* Direct traps also mean that we need to know whenever the Guest wants to use | 280 | /* Direct traps also mean that we need to know whenever the Guest wants to use |