From: Keir Fraser <keir.xen@gmail.com>
To: Jan Beulich <JBeulich@suse.com>, xen-devel <xen-devel@lists.xen.org>
Cc: Ben Guthro <ben.guthro@gmail.com>
Subject: Re: [PATCH] x86: refine FPU selector handling code for XSAVEOPT
Date: Mon, 05 Aug 2013 17:03:38 +0100 [thread overview]
Message-ID: <CE258B6A.2F342%keir.xen@gmail.com> (raw)
In-Reply-To: <51FFBF2902000078000E9492@nat28.tlf.novell.com>
On 05/08/2013 14:05, "Jan Beulich" <JBeulich@suse.com> wrote:
> Some extra tweaks are necessary to deal with the situation of XSAVEOPT
> not writing the FPU portion of the save image (due to it detecting that
> the register state did not get modified since the last XRSTOR).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Tested-by: Ben Guthro <ben.guthro@gmail.com>
Acked-by: Keir Fraser <keir@xen.org>
> --- a/xen/arch/x86/xstate.c
> +++ b/xen/arch/x86/xstate.c
> @@ -71,10 +71,28 @@ void xsave(struct vcpu *v, uint64_t mask
>
> if ( word_size <= 0 || !is_pv_32bit_vcpu(v) )
> {
> + typeof(ptr->fpu_sse.fip.sel) fcs = ptr->fpu_sse.fip.sel;
> + typeof(ptr->fpu_sse.fdp.sel) fds = ptr->fpu_sse.fdp.sel;
> +
> if ( cpu_has_xsaveopt )
> + {
> + /*
> + * xsaveopt may not write the FPU portion even when the
> respective
> + * mask bit is set. For the check further down to work we hence
> + * need to put the save image back into the state that it was in
> + * right after the previous xsaveopt.
> + */
> + if ( word_size > 0 &&
> + (ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET] == 4 ||
> + ptr->fpu_sse.x[FPU_WORD_SIZE_OFFSET] == 2) )
> + {
> + ptr->fpu_sse.fip.sel = 0;
> + ptr->fpu_sse.fdp.sel = 0;
> + }
> asm volatile ( ".byte 0x48,0x0f,0xae,0x37"
> : "=m" (*ptr)
> : "a" (lmask), "d" (hmask), "D" (ptr) );
> + }
> else
> asm volatile ( ".byte 0x48,0x0f,0xae,0x27"
> : "=m" (*ptr)
> @@ -87,7 +105,14 @@ void xsave(struct vcpu *v, uint64_t mask
> */
> (!(ptr->fpu_sse.fsw & 0x0080) &&
> boot_cpu_data.x86_vendor == X86_VENDOR_AMD) )
> + {
> + if ( cpu_has_xsaveopt && word_size > 0 )
> + {
> + ptr->fpu_sse.fip.sel = fcs;
> + ptr->fpu_sse.fdp.sel = fds;
> + }
> return;
> + }
>
> if ( word_size > 0 &&
> !((ptr->fpu_sse.fip.addr | ptr->fpu_sse.fdp.addr) >> 32) )
>
>
>
next prev parent reply other threads:[~2013-08-05 16:03 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 14:02 XSAVE/XRSTOR crash resurgence in 4.3 Ben Guthro
2013-07-04 13:21 ` Jan Beulich
2013-07-04 13:24 ` Ben Guthro
2013-07-04 18:19 ` Mark Roddy
2013-07-05 6:42 ` Jan Beulich
2013-07-05 10:30 ` Jan Beulich
2013-07-05 12:10 ` Ben Guthro
2013-07-05 12:15 ` Jan Beulich
2013-07-05 12:58 ` Ben Guthro
2013-07-08 14:13 ` Ben Guthro
2013-07-08 14:24 ` Jan Beulich
2013-07-08 14:31 ` Ben Guthro
2013-07-08 14:40 ` Jan Beulich
2013-07-08 14:42 ` Ben Guthro
2013-07-08 14:47 ` Jan Beulich
2013-07-08 15:10 ` Ben Guthro
2013-07-12 13:11 ` Ben Guthro
2013-07-12 13:38 ` Jan Beulich
2013-07-12 13:49 ` Ben Guthro
2013-07-12 14:34 ` Jan Beulich
2013-07-12 14:49 ` Ben Guthro
2013-07-12 14:55 ` Jan Beulich
2013-07-12 15:14 ` Ben Guthro
2013-07-15 6:41 ` Jan Beulich
2013-07-15 12:33 ` Jan Beulich
2013-07-15 12:43 ` Ben Guthro
2013-07-15 13:49 ` Ben Guthro
2013-07-15 14:06 ` Jan Beulich
2013-07-16 16:23 ` Jan Beulich
2013-07-16 16:57 ` Ben Guthro
2013-07-17 6:38 ` Jan Beulich
2013-07-17 13:07 ` Ben Guthro
2013-07-22 12:25 ` Ben Guthro
2013-08-05 13:05 ` [PATCH] x86: refine FPU selector handling code for XSAVEOPT Jan Beulich
2013-08-05 16:03 ` Keir Fraser [this message]
2013-07-08 14:44 ` XSAVE/XRSTOR crash resurgence in 4.3 Andrew Cooper
2013-07-08 14:52 ` Jan Beulich
2013-07-08 14:55 ` Andrew Cooper
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=CE258B6A.2F342%keir.xen@gmail.com \
--to=keir.xen@gmail.com \
--cc=JBeulich@suse.com \
--cc=ben.guthro@gmail.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 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.