On 13/07/2017 11:18, Yang Zhang wrote: > On 2017/7/13 17:02, Paolo Bonzini wrote: >> On 13/07/2017 10:53, Yang Zhang wrote: >>>> >>>> Even if it is restored correctly, you will have the wrong PKRU on the >>>> host between kvm_load_guest_fpu and entering the guest. >>> >>> Before kvm_load_guest_fpu or after? kvm_load_guest_fpu will load the >>> right pkru. >> >> It's the right pkru for the guest, but the wrong for the host. And if >> vmx->guest_pkru_valid is true for whatever reason, it will be >> overwritten in vmx_vcpu_run. > > ok, i see. You want to load guest pkru just before vmentry to avoid the > potential conflicts. Yes, and perhaps more important, you're relying on !vmx->guest_pkru_valid when you do the KVM_SET_XSAVE on the destination. Thanks, Paolo