All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Huaitong Han <huaitong.han@intel.com>, gleb@kernel.org
Cc: kvm@vger.kernel.org, guangrong.xiao@linux.intel.com
Subject: Re: [PATCH V5 4/9] KVM, pkeys: save/restore PKRU when guest/host switches
Date: Mon, 21 Mar 2016 11:28:09 +0100	[thread overview]
Message-ID: <56EFCCB9.80901@redhat.com> (raw)
In-Reply-To: <1458554760-4374-5-git-send-email-huaitong.han@intel.com>



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

  reply	other threads:[~2016-03-21 10:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21 10:05 [PATCH V5 0/9] KVM, pkeys: add memory protection-key support Huaitong Han
2016-03-21 10:05 ` [PATCH V5 1/9] KVM, pkeys: disable pkeys for guests in non-paging mode Huaitong Han
2016-03-21 10:05 ` [PATCH V5 2/9] KVM, pkeys: add pkeys support for xsave state Huaitong Han
2016-03-21 10:05 ` [PATCH V5 3/9] x86: pkey: introduce write_pkru() for KVM Huaitong Han
2016-03-21 10:05 ` [PATCH V5 4/9] KVM, pkeys: save/restore PKRU when guest/host switches Huaitong Han
2016-03-21 10:28   ` Paolo Bonzini [this message]
2016-03-21 10:37     ` Han, Huaitong
2016-03-21 10:05 ` [PATCH V5 5/9] KVM, pkeys: introduce pkru_mask to cache conditions Huaitong Han
2016-03-21 17:43   ` Paolo Bonzini
2016-03-21 10:05 ` [PATCH V5 6/9] KVM, pkeys: add pkeys support for permission_fault logic Huaitong Han
2016-03-21 10:55   ` Paolo Bonzini
2016-03-21 12:41     ` Han, Huaitong
2016-03-21 10:05 ` [PATCH V5 7/9] KVM, pkeys: expose CPUID/CR4 to guest Huaitong Han
2016-03-21 11:36   ` Paolo Bonzini
2016-03-21 11:56     ` Han, Huaitong
2016-03-21 12:08       ` Paolo Bonzini
2016-03-21 10:05 ` [PATCH V5 8/9] KVM, pkeys: disable PKU feature without ept Huaitong Han
2016-03-21 11:01   ` Paolo Bonzini
2016-03-21 10:06 ` [PATCH V5 9/9] Revert "KVM: MMU: precompute page fault error code" Huaitong Han

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56EFCCB9.80901@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@kernel.org \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=huaitong.han@intel.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.