Skip to contentSkip to conversation

: Fixing the xchg emulation bug

PATCH RESEND In review Ky Srinivasan 2 participants 2 messages Jun 1, 2006 x86

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 : Fixing the xchg emulation bug

The following patch fixes a bug in the emulation of the xchg instruction. 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.

Please apply to testing as well as unstable tree.

Signed- off- by K. Y. Srinivasan <[email protected]>

arch/x86/hvm/io.c +10 -0
diff -Nur xen/arch/x86/hvm/io.c xen-new/arch/x86/hvm/io.c
@@ -646,6 +646,16 @@
             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);
arch/x86/hvm/platform.c +20 -4
diff -Nur xen/arch/x86/hvm/platform.c xen-new/arch/x86/hvm/platform.c
@@ -954,10 +954,26 @@
         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:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 6 lines · Ky Srinivasan

The following patch fixes a bug in the emulation of the xchg instruction. 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.

This and the SMP patch are both already applied to both -unstable and -testing.

K.