From: Imre Kaloz <kaloz@kernel.org>
To: Andreas Larsson <andreas@gaisler.com>, sparclinux@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH] math-emu: fix wrong word index in _FP_FRAC_CLZ_4
Date: Sun, 27 Sep 2026 02:56:30 +0200 [thread overview]
Message-ID: <20260927005630.8202-1-kaloz@kernel.org> (raw)
_FP_FRAC_CLZ_4 picks a word by testing X##_f[3], X##_f[2] and X##_f[1]
in turn and counts the leading zeros of the first non-zero one. The
X##_f[1] branch passes X##_f[2] to __FP_CLZ, a word already known to be
zero, so the result is 3 * _FP_W_TYPE_SIZE - 1 whatever X##_f[1] holds.
Normalizing a quad then shifts by up to a word too much whenever the
leading set bit falls in word 1. sparc traps every quad operation to
do_mathemu(), so hex floats parsed by strtod() and scanf() in ordinary
user code come back wrong.
With this, the affected float-parse tests pass on a SPARCstation 20.
The wrong index has been there since 2.1.97.
Cc: stable@vger.kernel.org
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
---
Notes:
- _FP_FRAC_CLZ_4 is the generic 4-word helper in include/math-emu/op-4.h,
which is why LKML is on Cc.
- The checkpatch error "space required after that ','" is the
surrounding soft-fp idiom: every neighbouring line in op-4.h is
written __FP_CLZ(R,X##_f[N]).
- No Fixes: tag: this has been broken since 2.1.97, before the git
history. checkpatch asks for one to go with the stable@ Cc, but
there is no commit to name.
include/math-emu/op-4.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/math-emu/op-4.h b/include/math-emu/op-4.h
index ba226f8237a6..429c8f5cbf8a 100644
--- a/include/math-emu/op-4.h
+++ b/include/math-emu/op-4.h
@@ -170,7 +170,7 @@
} \
else if (X##_f[1]) \
{ \
- __FP_CLZ(R,X##_f[2]); \
+ __FP_CLZ(R,X##_f[1]); \
R += _FP_W_TYPE_SIZE*2; \
} \
else \
base-commit: 62f4c998b297cf233997a2b4cd6fc2d2df0319c9
--
2.47.3
reply other threads:[~2026-09-27 0:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260927005630.8202-1-kaloz@kernel.org \
--to=kaloz@kernel.org \
--cc=andreas@gaisler.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®