]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: x86 emulator: fix hypercall return value on AMD
authorAvi Kivity <avi@qumranet.com>
Wed, 21 May 2008 12:34:25 +0000 (15:34 +0300)
committerAvi Kivity <avi@qumranet.com>
Fri, 6 Jun 2008 18:08:25 +0000 (21:08 +0300)
The hypercall instructions on Intel and AMD are different.  KVM allows the
guest to choose one or the other (the default is Intel), and if the guest
chooses incorrectly, KVM will patch it at runtime to select the correct
instruction.  This allows live migration between Intel and AMD machines.

This patching occurs in the x86 emulator.  The current code also executes
the hypercall.  Unfortunately, the tail end of the x86 emulator code also
executes, overwriting the return value of the hypercall with the original
contents of rax (which happens to be the hypercall number).

Fix not by executing the hypercall in the emulator context; instead let the
guest reissue the patched instruction and execute the hypercall via the
normal path.

Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/x86_emulate.c

index 8a96320ab071b06f1d3102518b55877d297517b8..932f216d890c343bc5ca4ebfd8a15e1955334969 100644 (file)
@@ -1727,7 +1727,8 @@ twobyte_insn:
                        if (rc)
                                goto done;
 
-                       kvm_emulate_hypercall(ctxt->vcpu);
+                       /* Let the processor re-execute the fixed hypercall */
+                       c->eip = ctxt->vcpu->arch.rip;
                        /* Disable writeback. */
                        c->dst.type = OP_NONE;
                        break;