WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

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

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fix segment save/restore during context switching on x86/64.
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Thu, 21 Apr 2005 10:15:23 +0000
Delivery-date: Thu, 21 Apr 2005 11:02:18 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Fix segment save/restore during context switching on x86/64., BitKeeper Bot <=