mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: bp@alien8.de
Subject: Re: [PATCH v2] KVM: VMX: Set VMENTER_L1D_FLUSH_NOT_REQUIRED if !X86_BUG_L1TF
Date: Fri, 27 Sep 2019 12:11:17 -0400	[thread overview]
Message-ID: <d8dc9ae5-7a97-1aed-4c22-051587795789@redhat.com> (raw)
In-Reply-To: <1569600316-35966-1-git-send-email-pbonzini@redhat.com>

On 9/27/19 12:05 PM, Paolo Bonzini wrote:
> From: Waiman Long <longman@redhat.com>
>
> The l1tf_vmx_mitigation is only set to VMENTER_L1D_FLUSH_NOT_REQUIRED
> when the ARCH_CAPABILITIES MSR indicates that L1D flush is not required.
> However, if the CPU is not affected by L1TF, l1tf_vmx_mitigation will
> still be set to VMENTER_L1D_FLUSH_AUTO. This is certainly not the best
> option for a !X86_BUG_L1TF CPU.
>
> So force l1tf_vmx_mitigation to VMENTER_L1D_FLUSH_NOT_REQUIRED to make it
> more explicit in case users are checking the vmentry_l1d_flush parameter.
>
> Signed-off-by: Waiman Long <longman@redhat.com>
> [Patch rewritten accoring to Borislav Petkov's suggestion. - Paolo]
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/vmx/vmx.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index d4575ffb3cec..e7970a2e8eae 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -209,6 +209,11 @@ static int vmx_setup_l1d_flush(enum vmx_l1d_flush_state l1tf)
>  	struct page *page;
>  	unsigned int i;
>  
> +	if (!boot_cpu_has_bug(X86_BUG_L1TF)) {
> +		l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_NOT_REQUIRED;
> +		return 0;
> +	}
> +
>  	if (!enable_ept) {
>  		l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_EPT_DISABLED;
>  		return 0;
> @@ -7995,12 +8000,10 @@ static int __init vmx_init(void)
>  	 * contain 'auto' which will be turned into the default 'cond'
>  	 * mitigation mode.
>  	 */
> -	if (boot_cpu_has(X86_BUG_L1TF)) {
> -		r = vmx_setup_l1d_flush(vmentry_l1d_flush_param);
> -		if (r) {
> -			vmx_exit();
> -			return r;
> -		}
> +	r = vmx_setup_l1d_flush(vmentry_l1d_flush_param);
> +	if (r) {
> +		vmx_exit();
> +		return r;
>  	}
>  
>  #ifdef CONFIG_KEXEC_CORE

That looks cleaner. Thanks for the suggestion and rewrite.

Cheers,
Longman


      reply	other threads:[~2019-09-27 16:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 16:05 Paolo Bonzini
2019-09-27 16:11 ` Waiman Long [this message]

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=d8dc9ae5-7a97-1aed-4c22-051587795789@redhat.com \
    --to=longman@redhat.com \
    --cc=bp@alien8.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®