diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2017-08-24 11:59:31 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-08-30 10:21:45 +0200 |
commit | 275f3033ccf6114f3c7d4535665fcf7bdcc9f04e (patch) | |
tree | d8296f9e61f47aa7b600ea5c528a91af5911acf0 /arch/x86 | |
parent | cfb917a17d3df75243199ad8bad7e9505fd79468 (diff) | |
download | linux-stable-275f3033ccf6114f3c7d4535665fcf7bdcc9f04e.tar.gz linux-stable-275f3033ccf6114f3c7d4535665fcf7bdcc9f04e.tar.bz2 linux-stable-275f3033ccf6114f3c7d4535665fcf7bdcc9f04e.zip |
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>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/cpuid.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 649d8f2c1e40..91af75e37306 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -456,7 +456,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, entry->ecx &= kvm_cpuid_7_0_ecx_x86_features; cpuid_mask(&entry->ecx, CPUID_7_ECX); /* PKU is not yet implemented for shadow paging. */ - if (!tdp_enabled) + if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE)) entry->ecx &= ~F(PKU); } else { entry->ebx = 0; |