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, Joerg.Roedel@amd.com
Subject: Re: [PATCH v2] kvm/fpu: Enable fully eager restore kvm FPU
Date: Wed, 05 Sep 2012 16:12:55 +0300	[thread overview]
Message-ID: <50474FD7.3020301@redhat.com> (raw)
In-Reply-To: <1346808370-28376-1-git-send-email-xudong.hao@intel.com>

On 09/05/2012 04:26 AM, Xudong Hao wrote:
> Enable KVM FPU fully eager restore, if there is other FPU state which isn't
> tracked by CR0.TS bit.
> 
> Changes from v1:
> Expand KVM_XSTATE_LAZY to 64 bits before negating it.
> 
> Signed-off-by: Xudong Hao <xudong.hao@intel.com>
> ---
>  arch/x86/include/asm/kvm.h |    4 ++++
>  arch/x86/kvm/x86.c         |   13 ++++++++++++-
>  2 files changed, 16 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
> index 521bf25..4c27056 100644
> --- a/arch/x86/include/asm/kvm.h
> +++ b/arch/x86/include/asm/kvm.h
> @@ -8,6 +8,8 @@
>  
>  #include <linux/types.h>
>  #include <linux/ioctl.h>
> +#include <asm/user.h>
> +#include <asm/xsave.h>
>  
>  /* Select x86 specific features in <linux/kvm.h> */
>  #define __KVM_HAVE_PIT
> @@ -30,6 +32,8 @@
>  /* Architectural interrupt line count. */
>  #define KVM_NR_INTERRUPTS 256
>  
> +#define KVM_XSTATE_LAZY	(XSTATE_FP | XSTATE_SSE | XSTATE_YMM)
> +
>  struct kvm_memory_alias {
>  	__u32 slot;  /* this has a different namespace than memory slots */
>  	__u32 flags;
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 20f2266..a632042 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5969,7 +5969,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
> +	 * 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);
>  }
>  

I think something is missing.  This patch prevents
KVM_REQ_DEACTIVATE_FPU, but the fpu may not be active when non-lazy bits
are added to xcr0 (or cr4.osxsave is enabled).  I think you need to
activate the fpu at that time as well.


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

  reply	other threads:[~2012-09-05 13:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05  1:26 [PATCH v2] kvm/fpu: Enable fully eager restore kvm FPU Xudong Hao
2012-09-05 13:12 ` Avi Kivity [this message]
2012-09-06  2:13   ` Hao, Xudong
2012-09-06  8:16     ` Avi Kivity
2012-09-10  3:29       ` Hao, Xudong
2012-09-10  8:07         ` Avi Kivity
2012-09-11  6:43           ` Hao, Xudong
2012-09-11  7:54             ` Avi Kivity
2012-09-11  9:20               ` 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=50474FD7.3020301@redhat.com \
    --to=avi@redhat.com \
    --cc=Joerg.Roedel@amd.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.