[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CALCETrXQB2ZuDno1E70spamt30ix3kf8gShdNCM7Ua3xqWbZdQ@mail.gmail.com>
Date: Wed, 17 Jun 2020 08:30:42 -0700
From: Andy Lutomirski <luto@...capital.net>
To: Borislav Petkov <bp@...en8.de>
Cc: x86-ml <x86@...nel.org>, jpa@...nelbug.mail.kapsi.fi,
Dave Hansen <dave.hansen@...el.com>,
"H. Peter Anvin" <hpa@...or.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86/fpu: Reset MXCSR to default in kernel_fpu_begin()
On Wed, Jun 17, 2020 at 1:33 AM Borislav Petkov <bp@...en8.de> wrote:
>
> On Tue, Jun 16, 2020 at 02:17:16PM -0700, Andy Lutomirski wrote:
> > We definitely need to sanitize MXCSR for kernel fpu if kernel fpu
> > means SSE2. If kernel fpu means x87, we need to fix the fpu control
> > word.
>
> Bah, there's no need to beat around the bush - let's just do:
>
> if (boot_cpu_has(X86_FEATURE_XMM))
> ldmxcsr(MXCSR_DEFAULT);
>
> if (boot_cpu_has(X86_FEATURE_FPU))
> asm volatile ("fninit");
>
> and be sure that kernel users get a squeaky-clean FPU.
>
> > On x86_64, I suspect the UEFI ABI technically requires a clean x87
> > control word too. If we’re willing to declare that the kernel proper
> > won’t use x87, then we could shove that into the UEFI code.
>
> Nah, we don't trust the firmware.
What I mean is: if we trust ourselves to have no x87 instructions in
the kernel, we could put the FNINIT in the UEFI stubs to save some
cycles. I don't know how slow FNINIT is.
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette
--
Andy Lutomirski
AMA Capital Management, LLC
Powered by blists - more mailing lists