From: "H. Peter Anvin" <hpa@zytor.com>
To: linux-stable <stable@vger.kernel.org>,
stable@vger.kernel.org, hpa@linux.intel.com, hjl.tools@gmail.com
Cc: mingo@kernel.org, hpa@zytor.com, tglx@linutronix.de,
"tip-bot for H.J. Lu" <tipbot@zytor.com>,
linux-tip-commits@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [tip:x86/urgent] x86, fpu: correct the asm constraints for fxsave , unbreak mxcsr.daz
Date: Fri, 26 Jul 2013 13:19:30 -0700 [thread overview]
Message-ID: <51F2D9D2.8050405@zytor.com> (raw)
In-Reply-To: <tip-eaa5a990191d204ba0f9d35dbe5505ec2cdd1460@git.kernel.org>
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@gmail.com>
> AuthorDate: Fri, 26 Jul 2013 09:11:56 -0700
> Committer: H. Peter Anvin <hpa@linux.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@linux.intel.com>
> Cc: <stable@vger.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;
>
next parent reply other threads:[~2013-07-26 20:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <tip-eaa5a990191d204ba0f9d35dbe5505ec2cdd1460@git.kernel.org>
2013-07-26 20:19 ` H. Peter Anvin [this message]
2013-07-26 20:25 ` [tip:x86/urgent] x86, fpu: correct the asm constraints for fxsave , unbreak mxcsr.daz Greg KH
2013-07-26 21:36 ` Linus Torvalds
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=51F2D9D2.8050405@zytor.com \
--to=hpa@zytor.com \
--cc=hjl.tools@gmail.com \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tipbot@zytor.com \
--cc=torvalds@linux-foundation.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.