KVM: SVM: Restore correct registers after sel_cr0 intercept emulation
authorJoerg Roedel <joerg.roedel@amd.com>
Thu, 2 Sep 2010 15:29:46 +0000 (17:29 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 22 Nov 2010 19:03:06 +0000 (11:03 -0800)
commitad1faa8d564bc3910adbf3c5446d08ae43e37bb8
tree6d9d42c0498605ebda5fbaeff47ec2ef2505e401
parent0fca4221cc16a72598dbb8b7d3f281c695886027
KVM: SVM: Restore correct registers after sel_cr0 intercept emulation

commit cda0008299a06f0d7218c6037c3c02d7a865e954 upstream.

This patch implements restoring of the correct rip, rsp, and
rax after the svm emulation in KVM injected a selective_cr0
write intercept into the guest hypervisor. The problem was
that the vmexit is emulated in the instruction emulation
which later commits the registers right after the write-cr0
instruction. So the l1 guest will continue to run with the
l2 rip, rsp and rax resulting in unpredictable behavior.

This patch is not the final word, it is just an easy patch
to fix the issue. The real fix will be done when the
instruction emulator is made aware of nested virtualization.
Until this is done this patch fixes the issue and provides
an easy way to fix this in -stable too.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/svm.c