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 VMX decoder for MOVZ instruction.

# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 03d51c0b054609b7c0700d09ffb4ade26f50fbad
# Parent  c31edd72086dc20ef94b7e9af8deb8c243581efc
fix VMX decoder for MOVZ instruction.

In VMX decoder, we always assume the 2 operands of x86 instructions are
in the same length, however, MOVZ is an exception.
This patch fixes MOVZ instruction handling.

Signed-off-by: Xin Li <xin.b.li@xxxxxxxxx>
Signed-off-by: Dan Xu <dan.d.xu@xxxxxxxxx>

diff -r c31edd72086d -r 03d51c0b0546 xen/arch/x86/vmx_platform.c
--- a/xen/arch/x86/vmx_platform.c       Wed Nov  2 10:18:51 2005
+++ b/xen/arch/x86/vmx_platform.c       Wed Nov  2 10:19:48 2005
@@ -303,20 +303,20 @@
     mmio_inst->flags = 0;
 }
 
-#define GET_OP_SIZE_FOR_BYTE(op_size)   \
-    do {    \
-     if (rex)   \
-     op_size = BYTE_64;  \
- else    \
-     op_size = BYTE;  \
+#define GET_OP_SIZE_FOR_BYTE(op_size)       \
+    do {                                    \
+        if (rex)                            \
+            op_size = BYTE_64;              \
+        else                                \
+            op_size = BYTE;                 \
     } while(0)
 
 #define GET_OP_SIZE_FOR_NONEBYTE(op_size)   \
-    do {    \
-     if (rex & 0x8)   \
-     op_size = QUAD;  \
- else if (op_size != WORD) \
-     op_size = LONG;  \
+    do {                                    \
+        if (rex & 0x8)                      \
+            op_size = QUAD;                 \
+        else if (op_size != WORD)           \
+            op_size = LONG;                 \
     } while(0)
 
 
@@ -398,8 +398,9 @@
 
     case 0x20: /* and r8, m8 */
         instr->instr = INSTR_AND;
-        GET_OP_SIZE_FOR_BYTE(instr->op_size);
-        return reg_mem(instr->op_size, opcode, instr, rex);
+        instr->op_size = BYTE;
+        GET_OP_SIZE_FOR_BYTE(size_reg);
+        return reg_mem(size_reg, opcode, instr, rex);
 
     case 0x21: /* and r32/16, m32/16 */
         instr->instr = INSTR_AND;
@@ -413,8 +414,9 @@
 
     case 0x30: /* xor r8, m8 */
         instr->instr = INSTR_XOR;
-        GET_OP_SIZE_FOR_BYTE(instr->op_size);
-        return reg_mem(instr->op_size, opcode, instr, rex);
+        instr->op_size = BYTE;
+        GET_OP_SIZE_FOR_BYTE(size_reg);
+        return reg_mem(size_reg, opcode, instr, rex);
 
     case 0x31: /* xor r32/16, m32/16 */
         instr->instr = INSTR_XOR;
@@ -592,7 +594,7 @@
         instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
         return DECODE_success;
 
-    case 0xB7: /* movz m16, r32 */
+    case 0xB7: /* movz m16/m32, r32/r64 */
         instr->instr = INSTR_MOVZ;
         index = get_index(opcode + 1, rex);
         if (rex & 0x8) {
@@ -689,9 +691,9 @@
                           struct mmio_op *mmio_opp, struct cpu_user_regs *regs)
 {
     unsigned long value = 0;
-    int index, size;
-
-    size = operand_size(inst->operand[0]);
+    int index, size_reg;
+
+    size_reg = operand_size(inst->operand[0]);
 
     mmio_opp->flags = inst->flags;
     mmio_opp->instr = inst->instr;
@@ -701,14 +703,17 @@
 
     if (inst->operand[0] & REGISTER) { /* dest is memory */
         index = operand_index(inst->operand[0]);
-        value = get_reg_value(size, index, 0, regs);
+        value = get_reg_value(size_reg, index, 0, regs);
         send_mmio_req(type, gpa, 1, inst->op_size, value, IOREQ_WRITE, 0);
     } else if (inst->operand[0] & IMMEDIATE) { /* dest is memory */
         value = inst->immediate;
         send_mmio_req(type, gpa, 1, inst->op_size, value, IOREQ_WRITE, 0);
     } else if (inst->operand[0] & MEMORY) { /* dest is register */
         /* send the request and wait for the value */
-        send_mmio_req(type, gpa, 1, inst->op_size, 0, IOREQ_READ, 0);
+        if (inst->instr == INSTR_MOVZ)
+            send_mmio_req(type, gpa, 1, size_reg, 0, IOREQ_READ, 0);
+        else
+            send_mmio_req(type, gpa, 1, inst->op_size, 0, IOREQ_READ, 0);
     } else {
         printf("mmio_operands: invalid operand\n");
         domain_crash_synchronous();

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] fix VMX decoder for MOVZ instruction., Xen patchbot -unstable <=