]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
[HVM] Fix a bug in the emulation of the xchg instruction.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 31 May 2006 06:32:55 +0000 (07:32 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 31 May 2006 06:32:55 +0000 (07:32 +0100)
This bug has prevented us from booting fully virtualized SMP guests
that write to the APIC using the xchg instruction (when
CONFIG_X86_GOOD_APIC is not set). On 32 bit platforms, sles 10 kernels
are built without CONFIG_x86_GOOD_APIC not set and hence we have had
problems booting fully virtualized SMP sles 10 guests.

Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com>
xen-unstable changeset:   10179:5be9e927533d94ed1389f8926d51c65849133556
xen-unstable date:        Tue May 30 12:30:47 2006 +0100

xen/arch/x86/hvm/io.c
xen/arch/x86/hvm/platform.c

index 893dd68ce5f936eeab93d879400484f7aef42f27..336d5d9bdba618f3c884a5aa09e90683d0ccba89 100644 (file)
@@ -646,6 +646,16 @@ static void hvm_mmio_assist(struct vcpu *v, struct cpu_user_regs *regs,
             regs->eflags &= ~X86_EFLAGS_CF;
 
         break;
+
+    case INSTR_XCHG:
+       if (src & REGISTER) {
+               index = operand_index(src);
+               set_reg_value(size, index, 0, regs, p->u.data);
+       } else {
+               index = operand_index(dst);
+               set_reg_value(size, index, 0, regs, p->u.data);
+       }
+       break;
     }
 
     hvm_load_cpu_guest_regs(v, regs);
index 1206ebda968e97967358cbe8b36bb62020512fb9..20779414fac3f5e69d1f4ff755e972a8d3b34f87 100644 (file)
@@ -954,10 +954,26 @@ void handle_mmio(unsigned long va, unsigned long gpa)
         mmio_opp->instr = mmio_inst.instr;
         mmio_opp->operand[0] = mmio_inst.operand[0]; /* source */
         mmio_opp->operand[1] = mmio_inst.operand[1]; /* destination */
-
-        /* send the request and wait for the value */
-        send_mmio_req(IOREQ_TYPE_XCHG, gpa, 1,
-                      mmio_inst.op_size, 0, IOREQ_WRITE, 0);
+       if (mmio_inst.operand[0] & REGISTER) {
+               long value;
+               unsigned long operand = mmio_inst.operand[0];
+               value = get_reg_value(operand_size(operand), 
+                                     operand_index(operand), 0,
+                                     mmio_opp->inst_decoder_regs);
+               /* send the request and wait for the value */
+               send_mmio_req(IOREQ_TYPE_XCHG, gpa, 1,
+                      mmio_inst.op_size, value, IOREQ_WRITE, 0);
+       } else {
+               /* the destination is a register */
+               long value;
+               unsigned long operand = mmio_inst.operand[1];
+               value = get_reg_value(operand_size(operand), 
+                                     operand_index(operand), 0,
+                                     mmio_opp->inst_decoder_regs);
+               /* send the request and wait for the value */
+               send_mmio_req(IOREQ_TYPE_XCHG, gpa, 1,
+                      mmio_inst.op_size, value, IOREQ_WRITE, 0);
+       }
         break;
 
     default: