[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <51F2D9D2.8050405@zytor.com>
Date: Fri, 26 Jul 2013 13:19:30 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: linux-stable <stable@...r.kernel.org>, stable@...r.kernel.org,
hpa@...ux.intel.com, hjl.tools@...il.com
CC: mingo@...nel.org, hpa@...or.com, tglx@...utronix.de,
"tip-bot for H.J. Lu" <tipbot@...or.com>,
linux-tip-commits@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [tip:x86/urgent] x86, fpu: correct the asm constraints for fxsave
, unbreak mxcsr.daz
Hi everyone,
I have tagged this one for -stable, but it is a definite "maybe", so I
wanted to:
a) qualify that tagging, and
b) perhaps use it as a boundary case for policy clarification.
This patch is an old bug, an incorrect assembly constraint, but as
happens with this type of bug it is being exposed by a change in gcc.
Therefore, although this is neither a regression per se in the kernel
nor in gcc, it is a regression in the combined output.
The bug is obvious; the fix at the very least *should* be obvious; the
main source of risk would appear that it might trigger bugs in very old
versions of gcc.
The gain is less inherently obvious: currently the only MXCSR bit
affected is DAZ, although this also affects any future MXCSR bits. Most
users do not care about DAZ, but the ones that do generally care *a lot*
about it as their applications may suffer very bad performance otherwise.
There is a kernel bugzilla for this:
https://bugzilla.kernel.org/show_bug.cgi?id=60633
... but it doesn't really add any additional information.
-hpa
On 07/26/2013 09:19 AM, tip-bot for H.J. Lu wrote:
> Commit-ID: eaa5a990191d204ba0f9d35dbe5505ec2cdd1460
> Gitweb: http://git.kernel.org/tip/eaa5a990191d204ba0f9d35dbe5505ec2cdd1460
> Author: H.J. Lu <hjl.tools@...il.com>
> AuthorDate: Fri, 26 Jul 2013 09:11:56 -0700
> Committer: H. Peter Anvin <hpa@...ux.intel.com>
> CommitDate: Fri, 26 Jul 2013 09:11:56 -0700
>
> x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz
>
> GCC will optimize mxcsr_feature_mask_init in arch/x86/kernel/i387.c:
>
> memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
> asm volatile("fxsave %0" : : "m" (fx_scratch));
> mask = fx_scratch.mxcsr_mask;
> if (mask == 0)
> mask = 0x0000ffbf;
>
> to
>
> memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
> asm volatile("fxsave %0" : : "m" (fx_scratch));
> mask = 0x0000ffbf;
>
> since asm statement doesn’t say it will update fx_scratch. As the
> result, the DAZ bit will be cleared. This patch fixes it. This bug
> dates back to at least kernel 2.6.12.
>
> Signed-off-by: H. Peter Anvin <hpa@...ux.intel.com>
> Cc: <stable@...r.kernel.org>
> ---
> arch/x86/kernel/i387.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
> index 202d24f..5d576ab 100644
> --- a/arch/x86/kernel/i387.c
> +++ b/arch/x86/kernel/i387.c
> @@ -116,7 +116,7 @@ static void mxcsr_feature_mask_init(void)
>
> if (cpu_has_fxsr) {
> memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
> - asm volatile("fxsave %0" : : "m" (fx_scratch));
> + asm volatile("fxsave %0" : "+m" (fx_scratch));
> mask = fx_scratch.mxcsr_mask;
> if (mask == 0)
> mask = 0x0000ffbf;
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists