Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1356443

Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines
Date 2016-03-12 16:20 +0100
Message-ID <rbTuG-847-9@gated-at.bofh.it> (permalink)
References (5 earlier) <rbt7d-5b2-47@gated-at.bofh.it> <rbtqx-5pl-1@gated-at.bofh.it> <rbtAe-5vz-15@gated-at.bofh.it> <rbA8G-1R9-25@gated-at.bofh.it> <rbTl0-7Va-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Ingo Molnar <mingo@kernel.org> wrote:

> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
> 
> > On Fri, Mar 11, 2016 at 3:32 AM, Borislav Petkov <bp@alien8.de> wrote:
> > > 486 cores like Intel Quark support only the very old, legacy x87 FPU
> > > (FSAVE/FRSTOR, CPUID bit FXSR is not set). And our FPU code wasn't
> > > handling the saving and restoring there properly. First, Andy Shevchenko
> > > reported a splat:
> > >
> > >   WARNING: CPU: 0 PID: 823 at arch/x86/include/asm/fpu/internal.h:163 fpu__clear+0x8c/0x160
> > >
> > > which was us trying to execute FXRSTOR on those machines even though
> > > they don't support it.
> > >
> > > After taking care of that, Bryan O'Donoghue reported that a simple FPU
> > > test still failed because we weren't initializing the FPU state properly
> > > on those machines.
> > 
> > Obvious Ack to the patch, along with a "how did this ever work
> > before?" comment..
> 
> So the window for 'real' breakage was relatively short: this is an older bug but 
> only became a serious bug with the following upcoming commit:
> 
>   58122bf1d856 x86/fpu: Default eagerfpu=on on all CPUs

And the reason for that is:

void fpu__clear(struct fpu *fpu)
{
        WARN_ON_FPU(fpu != &current->thread.fpu); /* Almost certainly an anomaly */

        if (!use_eager_fpu() || !static_cpu_has(X86_FEATURE_FPU)) {
                /* FPU state will be reallocated lazily at the first use. */
                fpu__drop(fpu);
        } else {
                if (!fpu->fpstate_active) {
                        fpu__activate_curr(fpu);
                        user_fpu_begin();
                }
                copy_init_fpstate_to_fpregs();
        }
}

i.e. we only execute the buggy sequence in the !eager_fpu case - and old FPUs were 
not eager-FPU, which hid the bug.

The other bug:

@@ -134,7 +134,7 @@ static void __init fpu__init_system_gene
         * Set up the legacy init FPU context. (xstate init might overwrite this
         * with a more modern format, if the CPU supports it.)
         */
-       fpstate_init_fxstate(&init_fpstate.fxsave);
+       fpstate_init(&init_fpstate);
 
was also hidden by the fact that it only affects eagerfpu case - but all previous 
eagerfpu bootups were for post-XSAVE CPUs.

Thanks,

	Ingo

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Got FPU related warning on Intel Quark during boot Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-03-10 11:50 +0100
  Re: Got FPU related warning on Intel Quark during boot Ingo Molnar <mingo@kernel.org> - 2016-03-10 12:20 +0100
    Re: Got FPU related warning on Intel Quark during boot Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-03-10 13:50 +0100
      Re: Got FPU related warning on Intel Quark during boot Borislav Petkov <bp@alien8.de> - 2016-03-10 14:00 +0100
        Re: Got FPU related warning on Intel Quark during boot Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-03-10 14:40 +0100
          Re: Got FPU related warning on Intel Quark during boot Borislav Petkov <bp@alien8.de> - 2016-03-10 16:10 +0100
            Re: Got FPU related warning on Intel Quark during boot Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-03-10 16:30 +0100
              Re: Got FPU related warning on Intel Quark during boot Bryan O'Donoghue <pure.logic@nexus-software.ie> - 2016-03-10 16:50 +0100
                Re: Got FPU related warning on Intel Quark during boot Borislav Petkov <bp@alien8.de> - 2016-03-10 17:50 +0100
                Re: Got FPU related warning on Intel Quark during boot Bryan O'Donoghue <pure.logic@nexus-software.ie> - 2016-03-10 18:20 +0100
                Re: Got FPU related warning on Intel Quark during boot Borislav Petkov <bp@alien8.de> - 2016-03-10 20:10 +0100
                Re: Got FPU related warning on Intel Quark during boot Andy Lutomirski <luto@amacapital.net> - 2016-03-11 02:40 +0100
                Re: Got FPU related warning on Intel Quark during boot Bryan O'Donoghue <pure.logic@nexus-software.ie> - 2016-03-11 12:00 +0100
            Re: Got FPU related warning on Intel Quark during boot Andy Lutomirski <luto@amacapital.net> - 2016-03-11 02:50 +0100
              Re: Got FPU related warning on Intel Quark during boot Ingo Molnar <mingo@kernel.org> - 2016-03-11 10:10 +0100
                Re: Got FPU related warning on Intel Quark during boot Borislav Petkov <bp@alien8.de> - 2016-03-11 10:50 +0100
                Re: Got FPU related warning on Intel Quark during boot Bryan O'Donoghue <pure.logic@nexus-software.ie> - 2016-03-11 12:10 +0100
                Re: Got FPU related warning on Intel Quark during boot Borislav Petkov <bp@alien8.de> - 2016-03-11 12:30 +0100
                [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Borislav Petkov <bp@alien8.de> - 2016-03-11 12:40 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Linus Torvalds <torvalds@linux-foundation.org> - 2016-03-11 19:40 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Dave Hansen <dave.hansen@linux.intel.com> - 2016-03-11 23:10 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Borislav Petkov <bp@alien8.de> - 2016-03-11 23:30 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Andy Lutomirski <luto@amacapital.net> - 2016-03-12 18:30 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Borislav Petkov <bp@alien8.de> - 2016-03-12 18:50 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Borislav Petkov <bp@alien8.de> - 2016-03-11 23:10 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Bryan O'Donoghue <pure.logic@nexus-software.ie> - 2016-03-12 13:10 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Borislav Petkov <bp@alien8.de> - 2016-03-12 13:30 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Ingo Molnar <mingo@kernel.org> - 2016-03-12 16:20 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Ingo Molnar <mingo@kernel.org> - 2016-03-12 16:10 +0100
                Re: [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Ingo Molnar <mingo@kernel.org> - 2016-03-12 16:20 +0100
                [tip:x86/urgent] x86/fpu: Fix eager-FPU handling on legacy FPU  machines tip-bot for Borislav Petkov <tipbot@zytor.com> - 2016-03-12 16:20 +0100

csiph-web