All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Xudong Hao <xudong.hao@intel.com>
Cc: kvm@vger.kernel.org, xiantao.zhang@intel.com
Subject: Re: [PATCH v3] kvm/fpu: Enable fully eager restore kvm FPU
Date: Thu, 13 Sep 2012 19:38:40 +0300	[thread overview]
Message-ID: <50520C10.9010805@redhat.com> (raw)
In-Reply-To: <1347437424-3006-1-git-send-email-xudong.hao@intel.com>

On 09/12/2012 11:10 AM, Xudong Hao wrote:
> Enable KVM FPU fully eager restore, if there is other FPU state which isn't
> tracked by CR0.TS bit.
> 
> v3 changes from v2:
> - Make fpu active explicitly while guest xsave is enabling and non-lazy xstate bit
> exist.
> 
> v2 changes from v1:
> - Expand KVM_XSTATE_LAZY to 64 bits before negating it.
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 248c2b4..853e875 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3028,6 +3028,8 @@ static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
>  
>  	if (!vcpu->fpu_active)
>  		hw_cr0 |= X86_CR0_TS | X86_CR0_MP;
> +	else
> +		hw_cr0 &= ~(X86_CR0_TS | X86_CR0_MP);
>  

Why?  The guest may wish to receive #NM faults.

>  	vmcs_writel(CR0_READ_SHADOW, cr0);
>  	vmcs_writel(GUEST_CR0, hw_cr0);
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 20f2266..183cf60 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -560,6 +560,8 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
>  		return 1;
>  	if (xcr0 & ~host_xcr0)
>  		return 1;
> +	if (xcr0 & ~((u64)KVM_XSTATE_LAZY))
> +		vcpu->fpu_active = 1;
>  	vcpu->arch.xcr0 = xcr0;
>  	vcpu->guest_xcr0_loaded = 0;
>  	return 0;
> @@ -5969,7 +5971,18 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
>  	vcpu->guest_fpu_loaded = 0;
>  	fpu_save_init(&vcpu->arch.guest_fpu);
>  	++vcpu->stat.fpu_reload;
> -	kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu);
> +	/*
> +	 * Currently KVM trigger FPU restore by #NM (via CR0.TS),
> +	 * till now only XCR0.bit0, XCR0.bit1, XCR0.bit2 is tracked

"currently", "till now", don't tell someone reading the code in six
months anything.  Just say how the code works.

> +	 * by TS bit, there might be other FPU state is not tracked
> +	 * by TS bit. Here it only make FPU deactivate request and do 
> +	 * FPU lazy restore for these cases: 1)xsave isn't enabled 
> +	 * in guest, 2)all guest FPU states can be tracked by TS bit.
> +	 * For others, doing fully FPU eager restore.
> +	 */
> +	if (!kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) ||
> +		!(vcpu->arch.xcr0 & ~((u64)KVM_XSTATE_LAZY)))
> +		kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu);
>  	trace_kvm_fpu(0);
>  }
>  
> 


-- 
error compiling committee.c: too many arguments to function

  parent reply	other threads:[~2012-09-13 16:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12  8:10 [PATCH v3] kvm/fpu: Enable fully eager restore kvm FPU Xudong Hao
2012-09-13 16:26 ` Marcelo Tosatti
2012-09-13 16:29   ` Marcelo Tosatti
2012-09-13 16:40     ` Avi Kivity
2012-09-17  2:07       ` Hao, Xudong
2012-09-17 13:30         ` Marcelo Tosatti
2012-09-18  1:08           ` Hao, Xudong
2012-09-19 10:23             ` Avi Kivity
2012-09-20  1:43               ` Hao, Xudong
2012-09-20  9:19                 ` Avi Kivity
2012-09-21  8:47                   ` Hao, Xudong
2012-09-23  9:03                     ` Avi Kivity
2012-09-14  8:54     ` Hao, Xudong
2012-09-14  9:35       ` Marcelo Tosatti
2012-09-13 16:38 ` Avi Kivity [this message]
2012-09-14  8:52   ` Hao, Xudong

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=50520C10.9010805@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=xiantao.zhang@intel.com \
    --cc=xudong.hao@intel.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.