KVM: VMX: Save/restore rflags.vm correctly in real mode
authorAvi Kivity <avi@redhat.com>
Thu, 8 Apr 2010 15:19:35 +0000 (18:19 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 26 Apr 2010 14:41:37 +0000 (07:41 -0700)
commita6c57001ec58dd0d54ca13a5001a5ee63abf3b03
tree3d3ebca67c4920136708378f0c4f20777b918861
parent6abddbe74fac81296e4d3cee3ba7327c27a96dde
KVM: VMX: Save/restore rflags.vm correctly in real mode

(Cherry-picked from commit 78ac8b47c566dd6177a3b9b291b756ccb70670b7)

Currently we set eflags.vm unconditionally when entering real mode emulation
through virtual-8086 mode, and clear it unconditionally when we enter protected
mode.  The means that the following sequence

  KVM_SET_REGS  (rflags.vm=1)
  KVM_SET_SREGS (cr0.pe=1)

Ends up with rflags.vm clear due to KVM_SET_SREGS triggering enter_pmode().

Fix by shadowing rflags.vm (and rflags.iopl) correctly while in real mode:
reads and writes to those bits access a shadow register instead of the actual
register.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/vmx.c