]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.52/mips-math-emu-mina.-d-s-fix-some-cases-of-infinity-and-zero-inputs.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.52 / mips-math-emu-mina.-d-s-fix-some-cases-of-infinity-and-zero-inputs.patch
1 From 304bfe473e70523e591fb1c9223289d355e0bdcb Mon Sep 17 00:00:00 2001
2 From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
3 Date: Thu, 27 Jul 2017 18:08:53 +0200
4 Subject: MIPS: math-emu: MINA.<D|S>: Fix some cases of infinity and zero inputs
5
6 From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
7
8 commit 304bfe473e70523e591fb1c9223289d355e0bdcb upstream.
9
10 Fix following special cases for MINA>.<D|S>:
11
12 - if one of the inputs is zero, and the other is subnormal, normal,
13 or infinity, the value of the former should be returned (that is,
14 a zero).
15 - if one of the inputs is infinity, and the other input is normal,
16 or subnormal, the value of the latter should be returned.
17
18 The previous implementation's logic for such cases was incorrect - it
19 appears as if it implements MAXA, and not MINA instruction.
20
21 A relevant example:
22
23 MINA.S fd,fs,ft:
24 If fs contains 100.0, and ft contains 0.0, fd is going to contain
25 0.0 (without this patch, it used to contain 100.0).
26
27 Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
28 Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")
29
30 Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
31 Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
32 Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
33 Reviewed-by: James Hogan <james.hogan@imgtec.com>
34 Cc: Bo Hu <bohu@google.com>
35 Cc: Douglas Leung <douglas.leung@imgtec.com>
36 Cc: Jin Qian <jinqian@google.com>
37 Cc: Paul Burton <paul.burton@imgtec.com>
38 Cc: Petar Jovanovic <petar.jovanovic@imgtec.com>
39 Cc: Raghu Gandham <raghu.gandham@imgtec.com>
40 Cc: linux-mips@linux-mips.org
41 Cc: linux-kernel@vger.kernel.org
42 Patchwork: https://patchwork.linux-mips.org/patch/16885/
43 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
44 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
45
46 ---
47 arch/mips/math-emu/dp_fmin.c | 4 ++--
48 arch/mips/math-emu/sp_fmin.c | 4 ++--
49 2 files changed, 4 insertions(+), 4 deletions(-)
50
51 --- a/arch/mips/math-emu/dp_fmin.c
52 +++ b/arch/mips/math-emu/dp_fmin.c
53 @@ -210,14 +210,14 @@ union ieee754dp ieee754dp_fmina(union ie
54 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM):
55 case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO):
56 case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO):
57 - return x;
58 + return y;
59
60 case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
61 case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF):
62 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
63 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM):
64 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_DNORM):
65 - return y;
66 + return x;
67
68 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO):
69 return ieee754dp_zero(xs | ys);
70 --- a/arch/mips/math-emu/sp_fmin.c
71 +++ b/arch/mips/math-emu/sp_fmin.c
72 @@ -210,14 +210,14 @@ union ieee754sp ieee754sp_fmina(union ie
73 case CLPAIR(IEEE754_CLASS_INF, IEEE754_CLASS_DNORM):
74 case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_ZERO):
75 case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_ZERO):
76 - return x;
77 + return y;
78
79 case CLPAIR(IEEE754_CLASS_NORM, IEEE754_CLASS_INF):
80 case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_INF):
81 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_INF):
82 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_NORM):
83 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_DNORM):
84 - return y;
85 + return x;
86
87 case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO):
88 return ieee754sp_zero(xs | ys);