changeset: 24171:fe80909663c1 user: Keir Fraser date: Tue Nov 22 13:00:21 2011 +0000 files: xen/common/wait.c description: x86,waitqueue: Allocate whole page for shadow stack. Signed-off-by: Keir Fraser --- xen/common/wait.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) Index: xen-4.1.2-testing/xen/common/wait.c =================================================================== --- xen-4.1.2-testing.orig/xen/common/wait.c +++ xen-4.1.2-testing/xen/common/wait.c @@ -33,7 +33,7 @@ struct waitqueue_vcpu { * hypervisor context before sleeping (descheduling), setjmp/longjmp-style. */ void *esp; - char stack[3000]; + char *stack; #endif }; @@ -41,11 +41,19 @@ int init_waitqueue_vcpu(struct vcpu *v) { struct waitqueue_vcpu *wqv; - wqv = xmalloc(struct waitqueue_vcpu); + wqv = xzalloc(struct waitqueue_vcpu); if ( wqv == NULL ) return -ENOMEM; - memset(wqv, 0, sizeof(*wqv)); +#ifdef CONFIG_X86 + wqv->stack = alloc_xenheap_page(); + if ( wqv->stack == NULL ) + { + xfree(wqv); + return -ENOMEM; + } +#endif + INIT_LIST_HEAD(&wqv->list); wqv->vcpu = v; @@ -63,6 +71,9 @@ void destroy_waitqueue_vcpu(struct vcpu return; BUG_ON(!list_empty(&wqv->list)); +#ifdef CONFIG_X86 + free_xenheap_page(wqv->stack); +#endif xfree(wqv); v->waitqueue_vcpu = NULL; @@ -115,7 +126,7 @@ static void __prepare_to_wait(struct wai : "=S" (wqv->esp) : "c" (cpu_info), "D" (wqv->stack) : "memory" ); - BUG_ON((cpu_info - (char *)wqv->esp) > sizeof(wqv->stack)); + BUG_ON((cpu_info - (char *)wqv->esp) > PAGE_SIZE); } static void __finish_wait(struct waitqueue_vcpu *wqv)