Skip to content
Commit 37486135 authored by Babu Moger's avatar Babu Moger Committed by Paolo Bonzini
Browse files

KVM: x86: Fix pkru save/restore when guest CR4.PKE=0, move it to x86.c



Though rdpkru and wrpkru are contingent upon CR4.PKE, the PKRU
resource isn't. It can be read with XSAVE and written with XRSTOR.
So, if we don't set the guest PKRU value here(kvm_load_guest_xsave_state),
the guest can read the host value.

In case of kvm_load_host_xsave_state, guest with CR4.PKE clear could
potentially use XRSTOR to change the host PKRU value.

While at it, move pkru state save/restore to common code and the
host_pkru field to kvm_vcpu_arch.  This will let SVM support protection keys.

Cc: stable@vger.kernel.org
Reported-by: default avatarJim Mattson <jmattson@google.com>
Signed-off-by: default avatarBabu Moger <babu.moger@amd.com>
Message-Id: <158932794619.44260.14508381096663848853.stgit@naples-babu.amd.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 7d611233
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment