KVM: x86: simplify handling of PKRU
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 23 Aug 2017 21:14:38 +0000 (23:14 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Aug 2017 07:28:28 +0000 (09:28 +0200)
commitb9dd21e104bcd45e124acfe978a79df71259e59b
tree5a38e9036b388cee6f72f861df7adf9ddeafd158
parentc469268cd523245cc58255f6696e0c295485cb0b
KVM: x86: simplify handling of PKRU

Move it to struct kvm_arch_vcpu, replacing guest_pkru_valid with a
simple comparison against the host value of the register.  The write of
PKRU in addition can be skipped if the guest has not enabled the feature.
Once we do this, we need not test OSPKE in the host anymore, because
guest_CR4.PKE=1 implies host_CR4.PKE=1.

The static PKU test is kept to elide the code on older CPUs.

Suggested-by: Yang Zhang <zy107165@alibaba-inc.com>
Fixes: 1be0e61c1f255faaeab04a390e00c8b9b9042870
Cc: stable@vger.kernel.org
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/kvm_cache_regs.h
arch/x86/kvm/mmu.h
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c