[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Fix segment save/restore during context switching on x86/64.



ChangeSet 1.1351, 2005/04/21 11:15:23+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Fix segment save/restore during context switching on x86/64.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 arch/x86/domain.c             |   26 +++++++++++++-------------
 include/asm-x86/x86_32/regs.h |    3 +++
 include/asm-x86/x86_64/regs.h |    4 ++++
 3 files changed, 20 insertions(+), 13 deletions(-)


diff -Nru a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     2005-04-21 07:02:34 -04:00
+++ b/xen/arch/x86/domain.c     2005-04-21 07:02:34 -04:00
@@ -632,17 +632,17 @@
         else
             regs->cs &= ~3;
 
-        if ( put_user(regs->ss,     rsp- 1) |
-             put_user(regs->rsp,    rsp- 2) |
-             put_user(regs->rflags, rsp- 3) |
-             put_user(regs->cs,     rsp- 4) |
-             put_user(regs->rip,    rsp- 5) |
-             put_user(regs->gs,     rsp- 6) |
-             put_user(regs->fs,     rsp- 7) |
-             put_user(regs->es,     rsp- 8) |
-             put_user(regs->ds,     rsp- 9) |
-             put_user(regs->r11,    rsp-10) |
-             put_user(regs->rcx,    rsp-11) )
+        if ( put_user(regs->ss,             rsp- 1) |
+             put_user(regs->rsp,            rsp- 2) |
+             put_user(regs->rflags,         rsp- 3) |
+             put_user(regs->cs,             rsp- 4) |
+             put_user(regs->rip,            rsp- 5) |
+             put_user(n->arch.user_ctxt.gs, rsp- 6) |
+             put_user(n->arch.user_ctxt.fs, rsp- 7) |
+             put_user(n->arch.user_ctxt.es, rsp- 8) |
+             put_user(n->arch.user_ctxt.ds, rsp- 9) |
+             put_user(regs->r11,            rsp-10) |
+             put_user(regs->rcx,            rsp-11) )
         {
             DPRINTK("Error while creating failsafe callback frame.\n");
             domain_crash();
@@ -737,7 +737,7 @@
     {
         memcpy(&p->arch.user_ctxt,
                stack_ec, 
-               sizeof(*stack_ec));
+               CTXT_SWITCH_STACK_BYTES);
         unlazy_fpu(p);
         CLEAR_FAST_TRAP(&p->arch);
         save_segments(p);
@@ -747,7 +747,7 @@
     {
         memcpy(stack_ec,
                &n->arch.user_ctxt,
-               sizeof(*stack_ec));
+               CTXT_SWITCH_STACK_BYTES);
 
         /* Maybe switch the debug registers. */
         if ( unlikely(n->arch.debugreg[7]) )
diff -Nru a/xen/include/asm-x86/x86_32/regs.h 
b/xen/include/asm-x86/x86_32/regs.h
--- a/xen/include/asm-x86/x86_32/regs.h 2005-04-21 07:02:34 -04:00
+++ b/xen/include/asm-x86/x86_32/regs.h 2005-04-21 07:02:34 -04:00
@@ -15,4 +15,7 @@
 #define PERMIT_SOFTINT(_dpl, _e, _r) \
     ((_dpl) >= (VM86_MODE(_r) ? 3 : ((_r)->cs & 3)))
 
+/* Number of bytes of on-stack execution state to be context-switched. */
+#define CTXT_SWITCH_STACK_BYTES (sizeof(execution_context_t))
+
 #endif
diff -Nru a/xen/include/asm-x86/x86_64/regs.h 
b/xen/include/asm-x86/x86_64/regs.h
--- a/xen/include/asm-x86/x86_64/regs.h 2005-04-21 07:02:34 -04:00
+++ b/xen/include/asm-x86/x86_64/regs.h 2005-04-21 07:02:34 -04:00
@@ -15,4 +15,8 @@
 #define PERMIT_SOFTINT(_dpl, _e, _r) \
     ((_dpl) >= (KERNEL_MODE(_e, _r) ? 1 : 3))
 
+/* Number of bytes of on-stack execution state to be context-switched. */
+/* NB. Segment registers and bases are not saved/restored on x86/64 stack. */
+#define CTXT_SWITCH_STACK_BYTES (offsetof(execution_context_t, es))
+
 #endif

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.