KVM: x86: block guest protection keys unless the host has them enabled
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 24 Aug 2017 09:59:31 +0000 (11:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Aug 2017 08:21:45 +0000 (10:21 +0200)
commit275f3033ccf6114f3c7d4535665fcf7bdcc9f04e
treed8296f9e61f47aa7b600ea5c528a91af5911acf0
parentcfb917a17d3df75243199ad8bad7e9505fd79468
KVM: x86: block guest protection keys unless the host has them enabled

commit c469268cd523245cc58255f6696e0c295485cb0b upstream.

If the host has protection keys disabled, we cannot read and write the
guest PKRU---RDPKRU and WRPKRU fail with #GP(0) if CR4.PKE=0.  Block
the PKU cpuid bit in that case.

This ensures that guest_CR4.PKE=1 implies host_CR4.PKE=1.

Fixes: 1be0e61c1f255faaeab04a390e00c8b9b9042870
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/cpuid.c