From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Liu, Jinsong" <jinsong.liu@intel.com>
Cc: Jan Beulich <JBeulich@suse.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH] X86: Fix vcpu xsave bug
Date: Fri, 15 Nov 2013 17:51:56 +0000 [thread overview]
Message-ID: <52865F3C.6030003@citrix.com> (raw)
In-Reply-To: <DE8DF0795D48FD4CA783C40EC8292335013CA23D@SHSMSX101.ccr.corp.intel.com>
[-- Attachment #1.1: Type: text/plain, Size: 2542 bytes --]
On 15/11/13 16:55, Liu, Jinsong wrote:
> commit 420bacd209e31917fd732ef3c1aeae03d6d14d18
> Author: Liu Jinsong <jinsong.liu@intel.com>
> Date: Sat Nov 16 06:15:11 2013 +0800
>
> X86: Fix vcpu xsave bug
>
> When nonlazy xstates used, it should be xsaved though lazy xstates are not dirty.
>
> Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
Do you mean "...xsaved as though lazy...", are you stating that
currently, lazy states are not actually dirty?
Furthermore, can you describe why, and what goes wrong if you dont? It
is not obvious why this change is needed.
>
> diff --git a/xen/arch/x86/i387.c b/xen/arch/x86/i387.c
> index 7649274..f1d2ccc 100644
> --- a/xen/arch/x86/i387.c
> +++ b/xen/arch/x86/i387.c
> @@ -134,7 +134,7 @@ static inline void fpu_frstor(struct vcpu *v)
> /* FPU Save Functions */
> /*******************************/
> /* Save x87 extended state */
> -static inline void fpu_xsave(struct vcpu *v)
> +static inline void fpu_xsave(struct vcpu *v, uint64_t mask)
> {
> bool_t ok;
>
> @@ -145,7 +145,7 @@ static inline void fpu_xsave(struct vcpu *v)
> */
> ok = set_xcr0(v->arch.xcr0_accum | XSTATE_FP_SSE);
> ASSERT(ok);
> - xsave(v, v->arch.nonlazy_xstate_used ? XSTATE_ALL : XSTATE_LAZY);
> + xsave(v, mask);
> ok = set_xcr0(v->arch.xcr0 ?: XSTATE_FP_SSE);
> ASSERT(ok);
> }
> @@ -257,22 +257,29 @@ void vcpu_restore_fpu_lazy(struct vcpu *v)
> */
> void vcpu_save_fpu(struct vcpu *v)
> {
> - if ( !v->fpu_dirtied )
> - return;
> -
> ASSERT(!is_idle_vcpu(v));
>
> - /* This can happen, if a paravirtualised guest OS has set its CR0.TS. */
> + /* Avoid recursion */
Why are you changing this comment?
~Andrew
> clts();
> -
> - if ( cpu_has_xsave )
> - fpu_xsave(v);
> - else if ( cpu_has_fxsr )
> - fpu_fxsave(v);
> + if ( !v->fpu_dirtied )
> + {
> + if ( v->arch.nonlazy_xstate_used )
> + {
> + ASSERT(cpu_has_xsave);
> + fpu_xsave(v, XSTATE_NONLAZY);
> + }
> + }
> else
> - fpu_fsave(v);
> + {
> + if ( cpu_has_xsave )
> + fpu_xsave(v, XSTATE_ALL);
> + else if ( cpu_has_fxsr )
> + fpu_fxsave(v);
> + else
> + fpu_fsave(v);
>
> - v->fpu_dirtied = 0;
> + v->fpu_dirtied = 0;
> + }
> stts();
> }
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 3623 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-11-15 17:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 16:55 [PATCH] X86: Fix vcpu xsave bug Liu, Jinsong
2013-11-15 17:51 ` Andrew Cooper [this message]
2013-11-15 18:52 ` Liu, Jinsong
2013-11-18 9:04 ` Jan Beulich
2013-11-18 10:30 ` Liu, Jinsong
2013-11-18 9:06 ` Jan Beulich
2013-11-18 10:35 ` Liu, Jinsong
2013-11-18 11:02 ` Jan Beulich
2013-11-18 12:24 ` Liu, Jinsong
2013-11-18 12:49 ` Jan Beulich
2013-11-18 13:57 ` Liu, Jinsong
2013-11-18 14:18 ` Liu, Jinsong
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=52865F3C.6030003@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=jinsong.liu@intel.com \
--cc=xen-devel@lists.xen.org \
/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;
as well as URLs for NNTP newsgroup(s).