All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Mattson <jmattson@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kvm list <kvm@vger.kernel.org>,
	Wanpeng Li <wanpeng.li@hotmail.com>
Subject: Re: [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry
Date: Wed, 13 Dec 2017 11:03:31 -0800	[thread overview]
Message-ID: <CALMp9eScSH1qVczw38NxAA7UAXcNTVT6WWVUuAe=WbNGTfCe3w@mail.gmail.com> (raw)
In-Reply-To: <1513169512-28139-1-git-send-email-pbonzini@redhat.com>

Reviewed-by: Jim Mattson <jmattson@google.com>

On Wed, Dec 13, 2017 at 4:51 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> xsetbv can be expensive when running on nested virtualization, try to
> avoid it.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/x86.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 0f82e2cbf64c..daa1918031df 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -702,7 +702,8 @@ static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu)
>         if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) &&
>                         !vcpu->guest_xcr0_loaded) {
>                 /* kvm_set_xcr() also depends on this */
> -               xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
> +               if (vcpu->arch.xcr0 != host_xcr0)
> +                       xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0);
>                 vcpu->guest_xcr0_loaded = 1;
>         }
>  }
> --
> 1.8.3.1
>

  reply	other threads:[~2017-12-13 19:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 12:51 [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry Paolo Bonzini
2017-12-13 19:03 ` Jim Mattson [this message]
2017-12-14  1:05 ` Wanpeng Li
2017-12-14  3:27 ` Quan Xu

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='CALMp9eScSH1qVczw38NxAA7UAXcNTVT6WWVUuAe=WbNGTfCe3w@mail.gmail.com' \
    --to=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=wanpeng.li@hotmail.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 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.