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] [xen-unstable] hvm: Fix get_immediate() in mmio decoder

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] hvm: Fix get_immediate() in mmio decoder by reverting Dexuan Cui's
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Apr 2007 07:30:16 -0700
Delivery-date: Wed, 18 Apr 2007 07:31:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1176742057 -3600
# Node ID b96df7a4e0a7c875cf9f78b228c5134f0b47de90
# Parent  98efd2e410ae683b56469b2e5a47813d1766086b
hvm: Fix get_immediate() in mmio decoder by reverting Dexuan Cui's
change that breaks the case mod==0, rm==4, sib&7==5. That is,
disp32(scaled-index).
Also simplify get_immediate with sign extension.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/hvm/platform.c |   31 ++++++++-----------------------
 1 files changed, 8 insertions(+), 23 deletions(-)

diff -r 98efd2e410ae -r b96df7a4e0a7 xen/arch/x86/hvm/platform.c
--- a/xen/arch/x86/hvm/platform.c       Mon Apr 16 17:38:37 2007 +0100
+++ b/xen/arch/x86/hvm/platform.c       Mon Apr 16 17:47:37 2007 +0100
@@ -221,6 +221,7 @@ static inline unsigned long get_immediat
 
     inst++; //skip ModR/M byte
     if ( ad_size != WORD && mod != 3 && rm == 4 ) {
+        rm = *inst & 7;
         inst++; //skip SIB byte
     }
 
@@ -256,31 +257,15 @@ static inline unsigned long get_immediat
     return val;
 }
 
-/* Some instructions, like "add $imm8, r/m16"/"MOV $imm32, r/m64" require
- * the src immediate operand be sign-extented befere the op is executed. Here
- * we always sign-extend the operand to a "unsigned long" variable.
- *
- * Note: to simplify the logic here, the sign-extension here may be performed
- * redundantly against some instructions, like "MOV $imm16, r/m16" -- however
- * this is harmless, since we always remember the operand's size.
- */
-static inline unsigned long get_immediate_sign_ext(int ad_size,
-                                                   const unsigned char *inst,
-                                                   int op_size)
+static inline unsigned long get_immediate_sign_ext(
+    int ad_size, const unsigned char *inst, int op_size)
 {
     unsigned long result = get_immediate(ad_size, inst, op_size);
-
-    if ( op_size == QUAD )
-        op_size = LONG;
-
-    ASSERT( op_size == BYTE || op_size == WORD || op_size == LONG );
-
-    if ( result & (1UL << ((8*op_size) - 1)) )
-    {
-        unsigned long mask = ~0UL >> (8 * (sizeof(mask) - op_size));
-        result = ~mask | (result & mask);
-    }
-    return result;
+    if ( op_size == BYTE )
+        return (int8_t)result;
+    if ( op_size == WORD )
+        return (int16_t)result;
+    return (int32_t)result;
 }
 
 static inline int get_index(const unsigned char *inst, unsigned char rex)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] hvm: Fix get_immediate() in mmio decoder by reverting Dexuan Cui's, Xen patchbot-unstable <=