All of lore.kernel.org
 help / color / mirror / Atom feed
From: Quan Xu <quan.xu0@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: wanpeng.li@hotmail.com
Subject: Re: [PATCH] KVM: x86: avoid unnecessary XSETBV on guest entry
Date: Thu, 14 Dec 2017 11:27:27 +0800	[thread overview]
Message-ID: <f22b5190-2beb-5b2a-02ec-dbad5f0a8a7d@gmail.com> (raw)
In-Reply-To: <1513169512-28139-1-git-send-email-pbonzini@redhat.com>



On 2017/12/13 20:51, Paolo Bonzini 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;
>   	}
>   }

Reviewed-by: Quan Xu <quan.xu0@gmail.com>

      parent reply	other threads:[~2017-12-14  3:27 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
2017-12-14  1:05 ` Wanpeng Li
2017-12-14  3:27 ` Quan Xu [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=f22b5190-2beb-5b2a-02ec-dbad5f0a8a7d@gmail.com \
    --to=quan.xu0@gmail.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.