ia64/xen-unstable

changeset 14864:b96df7a4e0a7

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@xensource.com>
author kfraser@localhost.localdomain
date Mon Apr 16 17:47:37 2007 +0100 (2007-04-16)
parents 98efd2e410ae
children 66e935c09530
files xen/arch/x86/hvm/platform.c
line diff
     1.1 --- a/xen/arch/x86/hvm/platform.c	Mon Apr 16 17:38:37 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/platform.c	Mon Apr 16 17:47:37 2007 +0100
     1.3 @@ -221,6 +221,7 @@ static inline unsigned long get_immediat
     1.4  
     1.5      inst++; //skip ModR/M byte
     1.6      if ( ad_size != WORD && mod != 3 && rm == 4 ) {
     1.7 +        rm = *inst & 7;
     1.8          inst++; //skip SIB byte
     1.9      }
    1.10  
    1.11 @@ -256,31 +257,15 @@ static inline unsigned long get_immediat
    1.12      return val;
    1.13  }
    1.14  
    1.15 -/* Some instructions, like "add $imm8, r/m16"/"MOV $imm32, r/m64" require
    1.16 - * the src immediate operand be sign-extented befere the op is executed. Here
    1.17 - * we always sign-extend the operand to a "unsigned long" variable.
    1.18 - *
    1.19 - * Note: to simplify the logic here, the sign-extension here may be performed
    1.20 - * redundantly against some instructions, like "MOV $imm16, r/m16" -- however
    1.21 - * this is harmless, since we always remember the operand's size.
    1.22 - */
    1.23 -static inline unsigned long get_immediate_sign_ext(int ad_size,
    1.24 -                                                   const unsigned char *inst,
    1.25 -                                                   int op_size)
    1.26 +static inline unsigned long get_immediate_sign_ext(
    1.27 +    int ad_size, const unsigned char *inst, int op_size)
    1.28  {
    1.29      unsigned long result = get_immediate(ad_size, inst, op_size);
    1.30 -
    1.31 -    if ( op_size == QUAD )
    1.32 -        op_size = LONG;
    1.33 -
    1.34 -    ASSERT( op_size == BYTE || op_size == WORD || op_size == LONG );
    1.35 -
    1.36 -    if ( result & (1UL << ((8*op_size) - 1)) )
    1.37 -    {
    1.38 -        unsigned long mask = ~0UL >> (8 * (sizeof(mask) - op_size));
    1.39 -        result = ~mask | (result & mask);
    1.40 -    }
    1.41 -    return result;
    1.42 +    if ( op_size == BYTE )
    1.43 +        return (int8_t)result;
    1.44 +    if ( op_size == WORD )
    1.45 +        return (int16_t)result;
    1.46 +    return (int32_t)result;
    1.47  }
    1.48  
    1.49  static inline int get_index(const unsigned char *inst, unsigned char rex)