]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
KVM: x86: Update cpuid properly when CR4.OSXAVE or CR4.PKE is changed
authorWei Huang <wei@redhat.com>
Tue, 1 May 2018 14:49:54 +0000 (09:49 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 27 Aug 2018 14:40:05 +0000 (16:40 +0200)
commit00648597ec1b5fdbb5c6bb0a880ea922fdcb1ac0
tree6b0b4a81841d5185f2f6736c09960fc461809aef
parenta57e03646e7fc149731738c50797a6419affffc7
KVM: x86: Update cpuid properly when CR4.OSXAVE or CR4.PKE is changed

BugLink: http://bugs.launchpad.net/bugs/1786352
commit c4d2188206bafa177ea58e9a25b952baa0bf7712 upstream.

The CPUID bits of OSXSAVE (function=0x1) and OSPKE (func=0x7, leaf=0x0)
allows user apps to detect if OS has set CR4.OSXSAVE or CR4.PKE. KVM is
supposed to update these CPUID bits when CR4 is updated. Current KVM
code doesn't handle some special cases when updates come from emulator.
Here is one example:

  Step 1: guest boots
  Step 2: guest OS enables XSAVE ==> CR4.OSXSAVE=1 and CPUID.OSXSAVE=1
  Step 3: guest hot reboot ==> QEMU reset CR4 to 0, but CPUID.OSXAVE==1
  Step 4: guest os checks CPUID.OSXAVE, detects 1, then executes xgetbv

Step 4 above will cause an #UD and guest crash because guest OS hasn't
turned on OSXAVE yet. This patch solves the problem by comparing the the
old_cr4 with cr4. If the related bits have been changed,
kvm_update_cpuid() needs to be called.

Signed-off-by: Wei Huang <wei@redhat.com>
Reviewed-by: Bandan Das <bsd@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/x86/kvm/x86.c