On 21/03/2016 11:05, Huaitong Han wrote: > + if (vmx->guest_pkru_valid) > + write_pkru(vmx->guest_pkru); This can be __write_pkru. > atomic_switch_perf_msrs(vmx); > debugctlmsr = get_debugctlmsr(); > > @@ -8734,6 +8743,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) > vmx->exit_reason = vmcs_read32(VM_EXIT_REASON); > > /* > + * eager fpu is enabled if PKEY is supported and CR4 is switched > + * back on host, so it is safe to read guest PKRU from current > + * XSAVE. > + */ > + vmx->guest_pkru = read_pkru(); > + if (vmx->guest_pkru != vmx->host_pkru) { > + vmx->guest_pkru_valid = true; > + write_pkru(vmx->host_pkru); > + } else > + vmx->guest_pkru_valid = false; Should this code instead be enclosed in if (boot_cpu_has(X86_FEATURE_OSPKE)) and use __read_pkru/__write_pkru? Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html