ia64/xen-unstable

changeset 7777:eaee11008e68

Add MOVSX instr support to VMX MMIO decoder.

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Nov 11 10:41:25 2005 +0100 (2005-11-11)
parents 778394bb27f3
children 0b4596caf761
files xen/arch/x86/vmx_io.c xen/arch/x86/vmx_platform.c xen/arch/x86/vmx_vlapic.c xen/include/asm-x86/vmx_platform.h
line diff
     1.1 --- a/xen/arch/x86/vmx_io.c	Fri Nov 11 10:39:20 2005 +0100
     1.2 +++ b/xen/arch/x86/vmx_io.c	Fri Nov 11 10:41:25 2005 +0100
     1.3 @@ -459,14 +459,56 @@ static void vmx_mmio_assist(struct cpu_u
     1.4          }
     1.5          break;
     1.6  
     1.7 -    case INSTR_MOVZ:
     1.8 +    case INSTR_MOVZX:
     1.9          if (dst & REGISTER) {
    1.10 -            index = operand_index(dst);
    1.11              switch (size) {
    1.12 -            case BYTE: p->u.data = p->u.data & 0xFFULL; break;
    1.13 -            case WORD: p->u.data = p->u.data & 0xFFFFULL; break;
    1.14 -            case LONG: p->u.data = p->u.data & 0xFFFFFFFFULL; break;
    1.15 +            case BYTE:
    1.16 +                p->u.data &= 0xFFULL;
    1.17 +                break;
    1.18 +
    1.19 +            case WORD:
    1.20 +                p->u.data &= 0xFFFFULL;
    1.21 +                break;
    1.22 +
    1.23 +            case LONG:
    1.24 +                p->u.data &= 0xFFFFFFFFULL;
    1.25 +                break;
    1.26 +
    1.27 +            default:
    1.28 +                printk("Impossible source operand size of movzx instr: %d\n", size);
    1.29 +                domain_crash_synchronous();
    1.30              }
    1.31 +            index = operand_index(dst);
    1.32 +            set_reg_value(operand_size(dst), index, 0, regs, p->u.data);
    1.33 +        }
    1.34 +        break;
    1.35 +
    1.36 +    case INSTR_MOVSX:
    1.37 +        if (dst & REGISTER) {
    1.38 +            switch (size) {
    1.39 +            case BYTE:
    1.40 +                p->u.data &= 0xFFULL;
    1.41 +                if ( p->u.data & 0x80ULL )
    1.42 +                    p->u.data |= 0xFFFFFFFFFFFFFF00ULL;
    1.43 +                break;
    1.44 +
    1.45 +            case WORD:
    1.46 +                p->u.data &= 0xFFFFULL;
    1.47 +                if ( p->u.data & 0x8000ULL )
    1.48 +                    p->u.data |= 0xFFFFFFFFFFFF0000ULL;
    1.49 +                break;
    1.50 +
    1.51 +            case LONG:
    1.52 +                p->u.data &= 0xFFFFFFFFULL;
    1.53 +                if ( p->u.data & 0x80000000ULL )
    1.54 +                    p->u.data |= 0xFFFFFFFF00000000ULL;
    1.55 +                break;
    1.56 +
    1.57 +            default:
    1.58 +                printk("Impossible source operand size of movsx instr: %d\n", size);
    1.59 +                domain_crash_synchronous();
    1.60 +            }
    1.61 +            index = operand_index(dst);
    1.62              set_reg_value(operand_size(dst), index, 0, regs, p->u.data);
    1.63          }
    1.64          break;
     2.1 --- a/xen/arch/x86/vmx_platform.c	Fri Nov 11 10:39:20 2005 +0100
     2.2 +++ b/xen/arch/x86/vmx_platform.c	Fri Nov 11 10:41:25 2005 +0100
     2.3 @@ -581,25 +581,39 @@ static int vmx_decode(int vm86, unsigned
     2.4      }
     2.5  
     2.6      switch (*++opcode) {
     2.7 -    case 0xB6: /* movz m8, r16/r32 */
     2.8 -        instr->instr = INSTR_MOVZ;
     2.9 +    case 0xB6: /* movzx m8, r16/r32/r64 */
    2.10 +        instr->instr = INSTR_MOVZX;
    2.11          GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
    2.12          index = get_index(opcode + 1, rex);
    2.13          instr->operand[0] = mk_operand(BYTE, 0, 0, MEMORY);
    2.14          instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
    2.15          return DECODE_success;
    2.16  
    2.17 -    case 0xB7: /* movz m16/m32, r32/r64 */
    2.18 -        instr->instr = INSTR_MOVZ;
    2.19 +    case 0xB7: /* movzx m16/m32, r32/r64 */
    2.20 +        instr->instr = INSTR_MOVZX;
    2.21 +        GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
    2.22          index = get_index(opcode + 1, rex);
    2.23 -        if (rex & 0x8) {
    2.24 -            instr->op_size = LONG;
    2.25 -            instr->operand[1] = mk_operand(QUAD, index, 0, REGISTER);
    2.26 -        } else {
    2.27 -            instr->op_size = WORD;
    2.28 -            instr->operand[1] = mk_operand(LONG, index, 0, REGISTER);
    2.29 -        }
    2.30 -        instr->operand[0] = mk_operand(instr->op_size, 0, 0, MEMORY);
    2.31 +        if (rex & 0x8)
    2.32 +            instr->operand[0] = mk_operand(LONG, 0, 0, MEMORY);
    2.33 +        else
    2.34 +            instr->operand[0] = mk_operand(WORD, 0, 0, MEMORY);
    2.35 +        instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
    2.36 +        return DECODE_success;
    2.37 +
    2.38 +    case 0xBE: /* movsx m8, r16/r32/r64 */
    2.39 +        instr->instr = INSTR_MOVSX;
    2.40 +        GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
    2.41 +        index = get_index(opcode + 1, rex);
    2.42 +        instr->operand[0] = mk_operand(BYTE, 0, 0, MEMORY);
    2.43 +        instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
    2.44 +        return DECODE_success;
    2.45 +
    2.46 +    case 0xBF: /* movsx m16, r32/r64 */
    2.47 +        instr->instr = INSTR_MOVSX;
    2.48 +        GET_OP_SIZE_FOR_NONEBYTE(instr->op_size);
    2.49 +        index = get_index(opcode + 1, rex);
    2.50 +        instr->operand[0] = mk_operand(WORD, 0, 0, MEMORY);
    2.51 +        instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
    2.52          return DECODE_success;
    2.53  
    2.54      case 0xA3: /* bt r32, m32 */
    2.55 @@ -702,7 +716,7 @@ static void mmio_operands(int type, unsi
    2.56          send_mmio_req(type, gpa, 1, inst->op_size, value, IOREQ_WRITE, 0);
    2.57      } else if (inst->operand[0] & MEMORY) { /* dest is register */
    2.58          /* send the request and wait for the value */
    2.59 -        if (inst->instr == INSTR_MOVZ)
    2.60 +        if ( (inst->instr == INSTR_MOVZX) || (inst->instr == INSTR_MOVSX) )
    2.61              send_mmio_req(type, gpa, 1, size_reg, 0, IOREQ_READ, 0);
    2.62          else
    2.63              send_mmio_req(type, gpa, 1, inst->op_size, 0, IOREQ_READ, 0);
    2.64 @@ -827,7 +841,8 @@ void handle_mmio(unsigned long va, unsig
    2.65          break;
    2.66      }
    2.67  
    2.68 -    case INSTR_MOVZ:
    2.69 +    case INSTR_MOVZX:
    2.70 +    case INSTR_MOVSX:
    2.71          mmio_operands(IOREQ_TYPE_COPY, gpa, &mmio_inst, mmio_opp, regs);
    2.72          break;
    2.73  
     3.1 --- a/xen/arch/x86/vmx_vlapic.c	Fri Nov 11 10:39:20 2005 +0100
     3.2 +++ b/xen/arch/x86/vmx_vlapic.c	Fri Nov 11 10:41:25 2005 +0100
     3.3 @@ -567,7 +567,9 @@ static unsigned long vlapic_read(struct 
     3.4  
     3.5      if ( len != 4) {
     3.6          /* some bugs on kernel cause read this with byte*/
     3.7 -        printk("Local APIC read with len = %lx, should be 4 instead\n", len);
     3.8 +        VMX_DBG_LOG(DBG_LEVEL_VLAPIC,
     3.9 +                    "Local APIC read with len = %lx, should be 4 instead\n",
    3.10 +                    len);
    3.11      }
    3.12  
    3.13      alignment = offset & 0x3;
     4.1 --- a/xen/include/asm-x86/vmx_platform.h	Fri Nov 11 10:39:20 2005 +0100
     4.2 +++ b/xen/include/asm-x86/vmx_platform.h	Fri Nov 11 10:41:25 2005 +0100
     4.3 @@ -55,17 +55,18 @@
     4.4  #define REPNZ   0x2
     4.5  #define OVERLAP 0x4
     4.6  
     4.7 -#define INSTR_PIO 1
     4.8 -#define INSTR_OR 2
     4.9 -#define INSTR_AND 3
    4.10 -#define INSTR_XOR 4
    4.11 -#define INSTR_CMP 5
    4.12 -#define INSTR_MOV 6
    4.13 -#define INSTR_MOVS 7
    4.14 -#define INSTR_MOVZ 8
    4.15 -#define INSTR_STOS 9
    4.16 -#define INSTR_TEST 10
    4.17 -#define INSTR_BT 11
    4.18 +#define INSTR_PIO   1
    4.19 +#define INSTR_OR    2
    4.20 +#define INSTR_AND   3
    4.21 +#define INSTR_XOR   4
    4.22 +#define INSTR_CMP   5
    4.23 +#define INSTR_MOV   6
    4.24 +#define INSTR_MOVS  7
    4.25 +#define INSTR_MOVZX 8
    4.26 +#define INSTR_MOVSX 9
    4.27 +#define INSTR_STOS  10
    4.28 +#define INSTR_TEST  11
    4.29 +#define INSTR_BT    12
    4.30  
    4.31  struct instruction {
    4.32      __s8    instr; /* instruction type */