]> git.karo-electronics.de Git - karo-tx-linux.git/commit
KVM: SVM: do not zero out segment attributes if segment is unusable or not present
authorRoman Pen <roman.penyaev@profitbricks.com>
Thu, 1 Jun 2017 08:55:03 +0000 (10:55 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 1 Jun 2017 09:21:17 +0000 (11:21 +0200)
commitd9c1b5431d5f0e07575db785a022bce91051ac1d
tree3e8b000a15b788298f7f78f8ae56d80b947faecc
parent8eae9570d1d3887487be0b355d12656b46fac226
KVM: SVM: do not zero out segment attributes if segment is unusable or not present

This is a fix for the problem [1], where VMCB.CPL was set to 0 and interrupt
was taken on userspace stack.  The root cause lies in the specific AMD CPU
behaviour which manifests itself as unusable segment attributes on SYSRET.
The corresponding work around for the kernel is the following:

61f01dd941ba ("x86_64, asm: Work around AMD SYSRET SS descriptor attribute issue")

In other turn virtualization side treated unusable segment incorrectly and
restored CPL from SS attributes, which were zeroed out few lines above.

In current patch it is assured only that P bit is cleared in VMCB.save state
and segment attributes are not zeroed out if segment is not presented or is
unusable, therefore CPL can be safely restored from DPL field.

This is only one part of the fix, since QEMU side should be fixed accordingly
not to zero out attributes on its side.  Corresponding patch will follow.

[1] Message id: CAJrWOzD6Xq==b-zYCDdFLgSRMPM-NkNuTSDFEtX=7MreT45i7Q@mail.gmail.com

Signed-off-by: Roman Pen <roman.penyaev@profitbricks.com>
Signed-off-by: Mikhail Sennikovskii <mikhail.sennikovskii@profitbricks.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim KrÄmář <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm.c