ia64/xen-unstable
changeset 4612:319e2634476d
bitkeeper revision 1.1351 (42677d3b7Caqgw-mG40oawn1nybJ4A)
Fix segment save/restore during context switching on x86/64.
Signed-off-by: Keir Fraser <keir@xensource.com>
Fix segment save/restore during context switching on x86/64.
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Thu Apr 21 10:15:23 2005 +0000 (2005-04-21) |
parents | ebeac8efe955 |
children | a7a5ecbdd584 |
files | xen/arch/x86/domain.c xen/include/asm-x86/x86_32/regs.h xen/include/asm-x86/x86_64/regs.h |
line diff
1.1 --- a/xen/arch/x86/domain.c Thu Apr 21 09:14:12 2005 +0000 1.2 +++ b/xen/arch/x86/domain.c Thu Apr 21 10:15:23 2005 +0000 1.3 @@ -632,17 +632,17 @@ static void load_segments(struct exec_do 1.4 else 1.5 regs->cs &= ~3; 1.6 1.7 - if ( put_user(regs->ss, rsp- 1) | 1.8 - put_user(regs->rsp, rsp- 2) | 1.9 - put_user(regs->rflags, rsp- 3) | 1.10 - put_user(regs->cs, rsp- 4) | 1.11 - put_user(regs->rip, rsp- 5) | 1.12 - put_user(regs->gs, rsp- 6) | 1.13 - put_user(regs->fs, rsp- 7) | 1.14 - put_user(regs->es, rsp- 8) | 1.15 - put_user(regs->ds, rsp- 9) | 1.16 - put_user(regs->r11, rsp-10) | 1.17 - put_user(regs->rcx, rsp-11) ) 1.18 + if ( put_user(regs->ss, rsp- 1) | 1.19 + put_user(regs->rsp, rsp- 2) | 1.20 + put_user(regs->rflags, rsp- 3) | 1.21 + put_user(regs->cs, rsp- 4) | 1.22 + put_user(regs->rip, rsp- 5) | 1.23 + put_user(n->arch.user_ctxt.gs, rsp- 6) | 1.24 + put_user(n->arch.user_ctxt.fs, rsp- 7) | 1.25 + put_user(n->arch.user_ctxt.es, rsp- 8) | 1.26 + put_user(n->arch.user_ctxt.ds, rsp- 9) | 1.27 + put_user(regs->r11, rsp-10) | 1.28 + put_user(regs->rcx, rsp-11) ) 1.29 { 1.30 DPRINTK("Error while creating failsafe callback frame.\n"); 1.31 domain_crash(); 1.32 @@ -737,7 +737,7 @@ static void __context_switch(void) 1.33 { 1.34 memcpy(&p->arch.user_ctxt, 1.35 stack_ec, 1.36 - sizeof(*stack_ec)); 1.37 + CTXT_SWITCH_STACK_BYTES); 1.38 unlazy_fpu(p); 1.39 CLEAR_FAST_TRAP(&p->arch); 1.40 save_segments(p); 1.41 @@ -747,7 +747,7 @@ static void __context_switch(void) 1.42 { 1.43 memcpy(stack_ec, 1.44 &n->arch.user_ctxt, 1.45 - sizeof(*stack_ec)); 1.46 + CTXT_SWITCH_STACK_BYTES); 1.47 1.48 /* Maybe switch the debug registers. */ 1.49 if ( unlikely(n->arch.debugreg[7]) )
2.1 --- a/xen/include/asm-x86/x86_32/regs.h Thu Apr 21 09:14:12 2005 +0000 2.2 +++ b/xen/include/asm-x86/x86_32/regs.h Thu Apr 21 10:15:23 2005 +0000 2.3 @@ -15,4 +15,7 @@ 2.4 #define PERMIT_SOFTINT(_dpl, _e, _r) \ 2.5 ((_dpl) >= (VM86_MODE(_r) ? 3 : ((_r)->cs & 3))) 2.6 2.7 +/* Number of bytes of on-stack execution state to be context-switched. */ 2.8 +#define CTXT_SWITCH_STACK_BYTES (sizeof(execution_context_t)) 2.9 + 2.10 #endif
3.1 --- a/xen/include/asm-x86/x86_64/regs.h Thu Apr 21 09:14:12 2005 +0000 3.2 +++ b/xen/include/asm-x86/x86_64/regs.h Thu Apr 21 10:15:23 2005 +0000 3.3 @@ -15,4 +15,8 @@ 3.4 #define PERMIT_SOFTINT(_dpl, _e, _r) \ 3.5 ((_dpl) >= (KERNEL_MODE(_e, _r) ? 1 : 3)) 3.6 3.7 +/* Number of bytes of on-stack execution state to be context-switched. */ 3.8 +/* NB. Segment registers and bases are not saved/restored on x86/64 stack. */ 3.9 +#define CTXT_SWITCH_STACK_BYTES (offsetof(execution_context_t, es)) 3.10 + 3.11 #endif