[HVM] Add support for 'add r8,m8' instruction to memory-mapped I/O.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 31 Oct 2006 16:22:39 +0000 (16:22 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 31 Oct 2006 16:22:39 +0000 (16:22 +0000)
Signed-off-by: Kevin Tronkowski <ktronkowski@virtualiron.com>
Signed-off-by: Ben Thomas <bthomas@virtualiron.com>
tools/ioemu/target-i386-dm/helper2.c
xen/arch/x86/hvm/intercept.c
xen/arch/x86/hvm/io.c
xen/arch/x86/hvm/platform.c
xen/include/asm-x86/hvm/io.h
xen/include/public/hvm/ioreq.h

index 83fc5e8f005aa10865d4fa698b849b9fe130c1c5..22ea8b56e3f67303eb2ed9f350711fb13591299f 100644 (file)
@@ -393,6 +393,21 @@ void cpu_ioreq_and(CPUState *env, ioreq_t *req)
     req->u.data = tmp1;
 }
 
+void cpu_ioreq_add(CPUState *env, ioreq_t *req)
+{
+    unsigned long tmp1, tmp2;
+
+    if (req->pdata_valid != 0)
+        hw_error("expected scalar value");
+
+    read_physical(req->addr, req->size, &tmp1);
+    if (req->dir == IOREQ_WRITE) {
+        tmp2 = tmp1 + (unsigned long) req->u.data;
+        write_physical(req->addr, req->size, &tmp2);
+    }
+    req->u.data = tmp1;
+}
+
 void cpu_ioreq_or(CPUState *env, ioreq_t *req)
 {
     unsigned long tmp1, tmp2;
@@ -438,6 +453,9 @@ void __handle_ioreq(CPUState *env, ioreq_t *req)
     case IOREQ_TYPE_AND:
         cpu_ioreq_and(env, req);
         break;
+    case IOREQ_TYPE_ADD:
+        cpu_ioreq_add(env, req);
+        break;
     case IOREQ_TYPE_OR:
         cpu_ioreq_or(env, req);
         break;
index ea6f73a51dd9eb0fb1068d73e8add3f10fbb592b..8c20d9f23c70c006e229ec37c5d80da870605fe2 100644 (file)
@@ -109,6 +109,15 @@ static inline void hvm_mmio_access(struct vcpu *v,
         p->u.data = tmp1;
         break;
 
+    case IOREQ_TYPE_ADD:
+        tmp1 = read_handler(v, p->addr, p->size);
+        if (p->dir == IOREQ_WRITE) {
+            tmp2 = tmp1 + (unsigned long) p->u.data;
+            write_handler(v, p->addr, p->size, tmp2);
+        }
+        p->u.data = tmp1;
+        break;
+
     case IOREQ_TYPE_OR:
         tmp1 = read_handler(v, p->addr, p->size);
         if ( p->dir == IOREQ_WRITE ) {
index 28f06e66a0999f09ebe4ed625addca492d35b9aa..8bf9afc470f0ce595e4d6592c2bfb620da1c0b67 100644 (file)
@@ -532,6 +532,21 @@ static void hvm_mmio_assist(struct cpu_user_regs *regs, ioreq_t *p,
             set_reg_value(size, index, 0, regs, diff);
         }
 
+    case INSTR_ADD:
+        if (src & REGISTER) {
+            index = operand_index(src);
+            value = get_reg_value(size, index, 0, regs);
+            diff = (unsigned long) p->u.data + value;
+        } else if (src & IMMEDIATE) {
+            value = mmio_opp->immediate;
+            diff = (unsigned long) p->u.data + value;
+        } else if (src & MEMORY) {
+            index = operand_index(dst);
+            value = get_reg_value(size, index, 0, regs);
+            diff = (unsigned long) p->u.data + value;
+            set_reg_value(size, index, 0, regs, diff);
+        }
+
         /*
          * The OF and CF flags are cleared; the SF, ZF, and PF
          * flags are set according to the result. The state of
index 21b757be46cd421c55789a8b21b29f107e7c5679..e26b3e96d091a66b95fd74df2c12a14e7a78e230 100644 (file)
@@ -370,6 +370,13 @@ static int hvm_decode(int realmode, unsigned char *opcode,
     /* the operands order in comments conforms to AT&T convention */
 
     switch ( *opcode ) {
+
+    case 0x00: /* add r8, m8 */
+        mmio_op->instr = INSTR_ADD;
+        *op_size = BYTE;
+        GET_OP_SIZE_FOR_BYTE(size_reg);
+        return reg_mem(size_reg, opcode, mmio_op, rex);
+
     case 0x0A: /* or m8, r8 */
         mmio_op->instr = INSTR_OR;
         *op_size = BYTE;
@@ -1040,6 +1047,10 @@ void handle_mmio(unsigned long gpa)
         mmio_operands(IOREQ_TYPE_AND, gpa, mmio_op, op_size);
         break;
 
+    case INSTR_ADD:
+        mmio_operands(IOREQ_TYPE_ADD, gpa, mmio_op, op_size);
+        break;
+
     case INSTR_XOR:
         mmio_operands(IOREQ_TYPE_XOR, gpa, mmio_op, op_size);
         break;
index 2e35ef79d9f19f34d359324828a81e7da146e925..98441ee260a1c9bed92e12997b0c1682476416e1 100644 (file)
@@ -64,6 +64,7 @@
 #define INSTR_BT    13
 #define INSTR_XCHG  14
 #define INSTR_SUB   15
+#define INSTR_ADD   16
 
 #define MAX_INST_LEN      15 /* Maximum instruction length = 15 bytes */
 
index 992505e1c53b29c4574c467f860e6faa5e5be3cf..b7f68c1282f280256d36306a95c26af8c1a9bd06 100644 (file)
@@ -34,6 +34,7 @@
 #define IOREQ_TYPE_OR           3
 #define IOREQ_TYPE_XOR          4
 #define IOREQ_TYPE_XCHG         5
+#define IOREQ_TYPE_ADD          6
 
 /*
  * VMExit dispatcher should cooperate with instruction decoder to