Skip to contentSkip to conversation

ARM: VFP: Fix emulation of multiply accumulate instructions

PATCH In review Jay Foad 2 participants 3 messages Mar 26, 2014 – Apr 14, 2014

Subsystems (2)
lore
Share & tools
lore

Jay Foad

author
#0 lore raw

PATCH 1/1 ARM: VFP: Fix emulation of multiply accumulate instructions

The emulation for single and double precision multiply accumulate instructions correctly normalised any denormal values in the operand registers, but failed to normalise the destination (accumulator) register.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=70501

---
 arch/arm/vfp/vfpdouble.c | 2 ++
 arch/arm/vfp/vfpsingle.c | 2 ++
 2 files changed, 4 insertions(+)
arch/arm/vfp/vfpdouble.c +2 -0
index 6cac43bd1d86..423f56dd4028 100644
@@ -866,6 +866,8 @@ vfp_double_multiply_accumulate(int dd, int dn, int dm, u32 fpscr, u32 negate, ch
 		vdp.sign = vfp_sign_negate(vdp.sign);
 
 	vfp_double_unpack(&vdn, vfp_get_double(dd));
+	if (vdn.exponent == 0 && vdn.significand)
+		vfp_double_normalise_denormal(&vdn);
 	if (negate & NEG_SUBTRACT)
 		vdn.sign = vfp_sign_negate(vdn.sign);
 
arch/arm/vfp/vfpsingle.c +2 -0
index b252631b406b..4f96c1617aae 100644
@@ -915,6 +915,8 @@ vfp_single_multiply_accumulate(int sd, int sn, s32 m, u32 fpscr, u32 negate, cha
 	v = vfp_get_float(sd);
 	pr_debug("VFP: s%u = %08x\n", sd, v);
 	vfp_single_unpack(&vsn, v);
+	if (vsn.exponent == 0 && vsn.significand)
+		vfp_single_normalise_denormal(&vsn);
 	if (negate & NEG_SUBTRACT)
 		vsn.sign = vfp_sign_negate(vsn.sign);
 
Signature · 1 line
1.8.3.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jay Foad

The emulation for single and double precision multiply accumulate instructions correctly normalised any denormal values in the operand registers, but failed to normalise the destination (accumulator) register.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=70501

This appears to be clean and straightforward, so if nobody else has commented on this by the time -rc1 comes out, I suggest you rebase it and send it to the patch system. (See
http://www.arm.linux.org.uk/developer/patches/info.php for details -- make sure you read it carefully.)

Has this issue been hitting real-world users of the kernel, or is this fixing a latent bug?

Cheers
---Dave

Quoted 39 lines
---
 arch/arm/vfp/vfpdouble.c | 2 ++
 arch/arm/vfp/vfpsingle.c | 2 ++
 2 files changed, 4 insertions(+)
arch/arm/vfp/vfpdouble.c +2 -0
index 6cac43bd1d86..423f56dd4028 100644
@@ -866,6 +866,8 @@ vfp_double_multiply_accumulate(int dd, int dn, int dm, u32 fpscr, u32 negate, ch
 		vdp.sign = vfp_sign_negate(vdp.sign);
 
 	vfp_double_unpack(&vdn, vfp_get_double(dd));
+	if (vdn.exponent == 0 && vdn.significand)
+		vfp_double_normalise_denormal(&vdn);
 	if (negate & NEG_SUBTRACT)
 		vdn.sign = vfp_sign_negate(vdn.sign);
 
arch/arm/vfp/vfpsingle.c +2 -0
index b252631b406b..4f96c1617aae 100644
@@ -915,6 +915,8 @@ vfp_single_multiply_accumulate(int sd, int sn, s32 m, u32 fpscr, u32 negate, cha
 	v = vfp_get_float(sd);
 	pr_debug("VFP: s%u = %08x\n", sd, v);
 	vfp_single_unpack(&vsn, v);
+	if (vsn.exponent == 0 && vsn.significand)
+		vfp_single_normalise_denormal(&vsn);
 	if (negate & NEG_SUBTRACT)
 		vsn.sign = vfp_sign_negate(vsn.sign);
 
Signature · 7 lines
1.8.3.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#2 lore raw
Quoted 10 lines · Dave Martin
Quoted 8 lines · Jay Foad

The emulation for single and double precision multiply accumulate instructions correctly normalised any denormal values in the operand registers, but failed to normalise the destination (accumulator) register.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=70501

Quoted 7 lines

This appears to be clean and straightforward, so if nobody else has commented on this by the time -rc1 comes out, I suggest you rebase it and send it to the patch system. (See
http://www.arm.linux.org.uk/developer/patches/info.php for details -- make sure you read it carefully.)

Done.

Quoted 2 lines

Has this issue been hitting real-world users of the kernel, or is this fixing a latent bug?

Real world: it was causing failures in the test suite for an APL interpreter running on the Raspberry Pi.

Thanks,
Jay.