Messages in this thread | | | Subject | Re: [PATCH 2/2] KVM: SVM: Add support for MPK feature on AMD | From | Paolo Bonzini <> | Date | Thu, 7 May 2020 10:07:46 +0200 |
| |
On 07/05/20 00:26, Sean Christopherson wrote: >> + /* Load the guest pkru state */ >> + if (static_cpu_has(X86_FEATURE_PKU) && >> + kvm_read_cr4_bits(vcpu, X86_CR4_PKE) && >> + vcpu->arch.pkru != svm->host_pkru) >> + __write_pkru(vcpu->arch.pkru); > This and the restoration should be moved to common x86 helpers, at a glance > they look identical. > > In short, pretty much all of this belongs in common x86. >
We could stick this in kvm_load_guest_xsave_state kvm_load_host_xsave_state. It's not a perfect match, after all the code itself proves that PKRU can be loaded without XSAVE; but it's close enough and it's exactly in the right point of vmx_vcpu_run and svm_vcpu_run.
Paolo
| |