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 and simplify the seg_fixup code. It only needs to ha

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fix and simplify the seg_fixup code. It only needs to handle
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Fri, 10 Jun 2005 16:15:35 +0000
Delivery-date: Sat, 18 Jun 2005 01:03:52 +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.1900, 2005/06/10 17:15:35+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Fix and simplify the seg_fixup code. It only needs to handle 
        instructions with GS override.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 seg_fixup.c |   45 ++++++++++++++++++---------------------------
 1 files changed, 18 insertions(+), 27 deletions(-)


diff -Nru a/xen/arch/x86/x86_32/seg_fixup.c b/xen/arch/x86/x86_32/seg_fixup.c
--- a/xen/arch/x86/x86_32/seg_fixup.c   2005-06-17 21:04:58 -04:00
+++ b/xen/arch/x86/x86_32/seg_fixup.c   2005-06-17 21:04:58 -04:00
@@ -292,7 +292,7 @@
     u32           disp32 = 0;
     u8            *eip;         /* ptr to instruction start */
     u8            *pb, b;       /* ptr into instr. / current instr. byte */
-    unsigned int  *pseg = NULL; /* segment for memory operand (NULL=default) */
+    int            gs_override = 0;
 
     /* WARNING: We only work for ring-3 segments. */
     if ( unlikely(VM86_MODE(regs)) || unlikely(!RING_3(regs)) )
@@ -325,30 +325,20 @@
         switch ( b )
         {
         case 0x67: /* Address-size override */
-            DPRINTK("Unhandleable prefix byte %02x\n", b);
-            goto fixme;
-        case 0x66: /* Operand-size override */
-        case 0xf0: /* LOCK */
-        case 0xf2: /* REPNE/REPNZ */
-        case 0xf3: /* REP/REPE/REPZ */
-            break;
         case 0x2e: /* CS override */
-            pseg = &regs->cs;
-            break;
         case 0x3e: /* DS override */
-            pseg = &regs->ds;
-            break;
         case 0x26: /* ES override */
-            pseg = &regs->es;
-            break;
         case 0x64: /* FS override */
-            pseg = &regs->fs;
+        case 0x36: /* SS override */
+            DPRINTK("Unhandled prefix %02x\n", b);
+            goto fail;
+        case 0x66: /* Operand-size override */
+        case 0xf0: /* LOCK */
+        case 0xf2: /* REPNE/REPNZ */
+        case 0xf3: /* REP/REPE/REPZ */
             break;
         case 0x65: /* GS override */
-            pseg = &regs->gs;
-            break;
-        case 0x36: /* SS override */
-            pseg = &regs->ss;
+            gs_override = 1;
             break;
         default: /* Not a prefix byte */
             goto done_prefix;
@@ -356,6 +346,12 @@
     }
  done_prefix:
 
+    if ( !gs_override )
+    {
+        DPRINTK("Only instructions with GS override\n");
+        goto fail;
+    }
+
     decode = insn_decode[b]; /* opcode byte */
     pb++;
     if ( decode == 0 )
@@ -366,12 +362,13 @@
     
     if ( !(decode & HAS_MODRM) )
     {
+        /* Must be a <disp32>, or bail. */
         if ( (decode & 7) != 4 )
             goto fail;
 
         if ( get_user(offset, (u32 *)pb) )
         {
-            DPRINTK("Fault while extracting <disp8>.\n");
+            DPRINTK("Fault while extracting <disp32>.\n");
             goto page_fault;
         }
         pb += 4;
@@ -409,8 +406,6 @@
     switch ( modrm >> 6 )
     {
     case 0:
-        if ( pseg == NULL )
-            pseg = &regs->ds;
         disp32 = 0;
         if ( rm == 5 ) /* disp32 rather than (EBP) */
         {
@@ -425,8 +420,6 @@
         break;
 
     case 1:
-        if ( pseg == NULL ) /* NB. EBP defaults to SS */
-            pseg = (rm == 5) ? &regs->ss : &regs->ds;
         if ( get_user(disp8, pb) )
         {
             DPRINTK("Fault while extracting <disp8>.\n");
@@ -437,8 +430,6 @@
         break;
 
     case 2:
-        if ( pseg == NULL ) /* NB. EBP defaults to SS */
-            pseg = (rm == 5) ? &regs->ss : &regs->ds;
         if ( get_user(disp32, (u32 *)pb) )
         {
             DPRINTK("Fault while extracting <disp8>.\n");
@@ -457,7 +448,7 @@
         offset += *(u32 *)memreg;
 
  skip_modrm:
-    if ( !fixup_seg((u16)(*pseg), offset) )
+    if ( !fixup_seg((u16)regs->gs, offset) )
         goto fail;
 
     /* Success! */

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

<Prev in Thread] Current Thread [Next in Thread>