All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/HVM: XSA-267 follow-ups
@ 2018-06-15  8:47 Jan Beulich
  2018-06-15  8:58 ` [PATCH 1/2] x86/HVM: account for fully eager FPU mode in emulation Jan Beulich
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jan Beulich @ 2018-06-15  8:47 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Andrew Cooper, Paul Durrant

As both XenRT and osstest have found, the XSA-267 patches overlooked a
special case in HVM insn emulation. While looking into this I've also noticed
an omission in the sibling function to the one needing to be changed. At
least patch 1 should be strongly considered for 4.11; patch 2 will need
backporting as well, but doesn't look as urgent.

1: account for fully eager FPU mode in emulation
2: attempts to emulate FPU insns need to set fpu_initialised

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] x86/HVM: account for fully eager FPU mode in emulation
  2018-06-15  8:47 [PATCH 0/2] x86/HVM: XSA-267 follow-ups Jan Beulich
@ 2018-06-15  8:58 ` Jan Beulich
  2018-06-15  8:58 ` [PATCH 2/2] x86/HVM: attempts to emulate FPU insns need to set fpu_initialised Jan Beulich
  2018-06-15  9:27 ` [PATCH 0/2] x86/HVM: XSA-267 follow-ups Andrew Cooper
  2 siblings, 0 replies; 7+ messages in thread
From: Jan Beulich @ 2018-06-15  8:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Andrew Cooper, Paul Durrant

In fully eager mode we must not clear fpu_dirtied, set CR0.TS, or invoke
the fpu_leave() hook. Instead do what the mode's name says: Restore
state right away.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -2139,13 +2139,20 @@ static void hvmemul_put_fpu(
     if ( backout == X86EMUL_FPU_fpu )
     {
         /*
-         * To back out changes to the register file simply adjust state such
-         * that upon next FPU insn use by the guest we'll reload the state
-         * saved (or freshly loaded) by hvmemul_get_fpu().
+         * To back out changes to the register file
+         * - in fully eager mode, restore original state immediately,
+         * - in lazy mode, simply adjust state such that upon next FPU insn
+         *   use by the guest we'll reload the state saved (or freshly loaded)
+         *   by hvmemul_get_fpu().
          */
-        curr->fpu_dirtied = false;
-        stts();
-        hvm_funcs.fpu_leave(curr);
+        if ( curr->arch.fully_eager_fpu )
+            vcpu_restore_fpu_eager(curr);
+        else
+        {
+            curr->fpu_dirtied = false;
+            stts();
+            hvm_funcs.fpu_leave(curr);
+        }
     }
 }
 





_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] x86/HVM: attempts to emulate FPU insns need to set fpu_initialised
  2018-06-15  8:47 [PATCH 0/2] x86/HVM: XSA-267 follow-ups Jan Beulich
  2018-06-15  8:58 ` [PATCH 1/2] x86/HVM: account for fully eager FPU mode in emulation Jan Beulich
@ 2018-06-15  8:58 ` Jan Beulich
  2018-06-22 10:52   ` Ping: " Jan Beulich
  2018-06-15  9:27 ` [PATCH 0/2] x86/HVM: XSA-267 follow-ups Andrew Cooper
  2 siblings, 1 reply; 7+ messages in thread
From: Jan Beulich @ 2018-06-15  8:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Andrew Cooper, Paul Durrant

My original way of thinking here was that this would be set anyway at
the point state gets reloaded after the adjustments hvmemul_put_fpu()
does, but the flag should already be set before that - after all the
guest may never again touch the FPU before e.g. getting migrated/saved.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -2053,6 +2053,7 @@ static int hvmemul_get_fpu(
          * masking of all exceptions by FNSTENV.)
          */
         save_fpu_enable();
+        curr->fpu_initialised = true;
         curr->fpu_dirtied = true;
         if ( (fpu_ctxt->fcw & 0x3f) != 0x3f )
         {



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] x86/HVM: XSA-267 follow-ups
  2018-06-15  8:47 [PATCH 0/2] x86/HVM: XSA-267 follow-ups Jan Beulich
  2018-06-15  8:58 ` [PATCH 1/2] x86/HVM: account for fully eager FPU mode in emulation Jan Beulich
  2018-06-15  8:58 ` [PATCH 2/2] x86/HVM: attempts to emulate FPU insns need to set fpu_initialised Jan Beulich
@ 2018-06-15  9:27 ` Andrew Cooper
  2018-06-15  9:55   ` Jan Beulich
  2 siblings, 1 reply; 7+ messages in thread
From: Andrew Cooper @ 2018-06-15  9:27 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Juergen Gross, Paul Durrant

On 15/06/18 09:47, Jan Beulich wrote:
> As both XenRT and osstest have found, the XSA-267 patches overlooked a
> special case in HVM insn emulation. While looking into this I've also noticed
> an omission in the sibling function to the one needing to be changed. At
> least patch 1 should be strongly considered for 4.11; patch 2 will need
> backporting as well, but doesn't look as urgent.
>
> 1: account for fully eager FPU mode in emulation
> 2: attempts to emulate FPU insns need to set fpu_initialised

Both Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

At this point, I'm tempted to suggest that we reissue the XSA-267
advisory to include patch 1.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] x86/HVM: XSA-267 follow-ups
  2018-06-15  9:27 ` [PATCH 0/2] x86/HVM: XSA-267 follow-ups Andrew Cooper
@ 2018-06-15  9:55   ` Jan Beulich
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Beulich @ 2018-06-15  9:55 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Juergen Gross, xen-devel, Paul Durrant

>>> On 15.06.18 at 11:27, <andrew.cooper3@citrix.com> wrote:
> On 15/06/18 09:47, Jan Beulich wrote:
>> As both XenRT and osstest have found, the XSA-267 patches overlooked a
>> special case in HVM insn emulation. While looking into this I've also 
> noticed
>> an omission in the sibling function to the one needing to be changed. At
>> least patch 1 should be strongly considered for 4.11; patch 2 will need
>> backporting as well, but doesn't look as urgent.
>>
>> 1: account for fully eager FPU mode in emulation
>> 2: attempts to emulate FPU insns need to set fpu_initialised
> 
> Both Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> At this point, I'm tempted to suggest that we reissue the XSA-267
> advisory to include patch 1.

Yes, I think we should do this. But let me first see how far this change
is needed, and whether on older versions nothing else is needed in its
stead.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Ping: [PATCH 2/2] x86/HVM: attempts to emulate FPU insns need to set fpu_initialised
  2018-06-15  8:58 ` [PATCH 2/2] x86/HVM: attempts to emulate FPU insns need to set fpu_initialised Jan Beulich
@ 2018-06-22 10:52   ` Jan Beulich
  2018-06-25  7:20     ` Paul Durrant
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Beulich @ 2018-06-22 10:52 UTC (permalink / raw)
  To: Paul Durrant; +Cc: Juergen Gross, Andrew Cooper, xen-devel

>>> On 15.06.18 at 10:58, <JBeulich@suse.com> wrote:
> My original way of thinking here was that this would be set anyway at
> the point state gets reloaded after the adjustments hvmemul_put_fpu()
> does, but the flag should already be set before that - after all the
> guest may never again touch the FPU before e.g. getting migrated/saved.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -2053,6 +2053,7 @@ static int hvmemul_get_fpu(
>           * masking of all exceptions by FNSTENV.)
>           */
>          save_fpu_enable();
> +        curr->fpu_initialised = true;
>          curr->fpu_dirtied = true;
>          if ( (fpu_ctxt->fcw & 0x3f) != 0x3f )
>          {



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Ping: [PATCH 2/2] x86/HVM: attempts to emulate FPU insns need to set fpu_initialised
  2018-06-22 10:52   ` Ping: " Jan Beulich
@ 2018-06-25  7:20     ` Paul Durrant
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Durrant @ 2018-06-25  7:20 UTC (permalink / raw)
  To: 'Jan Beulich'; +Cc: Juergen Gross, Andrew Cooper, xen-devel

> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 22 June 2018 11:53
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>; xen-devel <xen-
> devel@lists.xenproject.org>; Juergen Gross <jgross@suse.com>
> Subject: Ping: [PATCH 2/2] x86/HVM: attempts to emulate FPU insns need to
> set fpu_initialised
> 
> >>> On 15.06.18 at 10:58, <JBeulich@suse.com> wrote:
> > My original way of thinking here was that this would be set anyway at
> > the point state gets reloaded after the adjustments hvmemul_put_fpu()
> > does, but the flag should already be set before that - after all the
> > guest may never again touch the FPU before e.g. getting migrated/saved.
> >
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >
> > --- a/xen/arch/x86/hvm/emulate.c
> > +++ b/xen/arch/x86/hvm/emulate.c
> > @@ -2053,6 +2053,7 @@ static int hvmemul_get_fpu(
> >           * masking of all exceptions by FNSTENV.)
> >           */
> >          save_fpu_enable();
> > +        curr->fpu_initialised = true;
> >          curr->fpu_dirtied = true;
> >          if ( (fpu_ctxt->fcw & 0x3f) != 0x3f )
> >          {
> 

Apologies for the delay...

Acked-by: Paul Durrant <paul.durrant@citrix.com>


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-25  7:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-15  8:47 [PATCH 0/2] x86/HVM: XSA-267 follow-ups Jan Beulich
2018-06-15  8:58 ` [PATCH 1/2] x86/HVM: account for fully eager FPU mode in emulation Jan Beulich
2018-06-15  8:58 ` [PATCH 2/2] x86/HVM: attempts to emulate FPU insns need to set fpu_initialised Jan Beulich
2018-06-22 10:52   ` Ping: " Jan Beulich
2018-06-25  7:20     ` Paul Durrant
2018-06-15  9:27 ` [PATCH 0/2] x86/HVM: XSA-267 follow-ups Andrew Cooper
2018-06-15  9:55   ` Jan Beulich

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.