]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.52/mips-math-emu-maxa-mina-.-d-s-fix-cases-of-input-values-with-opposite-signs.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.52 / mips-math-emu-maxa-mina-.-d-s-fix-cases-of-input-values-with-opposite-signs.patch
CommitLineData
dbfa5f4f
GKH
1From 1a41b3b441508ae63b1a9ec699ec94065739eb60 Mon Sep 17 00:00:00 2001
2From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
3Date: Thu, 27 Jul 2017 18:08:51 +0200
4Subject: MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs
5
6From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
7
8commit 1a41b3b441508ae63b1a9ec699ec94065739eb60 upstream.
9
10Fix the value returned by <MAXA|MINA>.<D|S>, if the inputs are normal
11fp numbers of the same absolute value, but opposite signs.
12
13A relevant example:
14
15MAXA.S fd,fs,ft:
16 If fs contains -3.0, and ft contains +3.0, fd is going to contain
17 +3.0 (without this patch, it used to contain -3.0).
18
19Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction")
20Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction")
21
22Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
23Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
24Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
25Reviewed-by: James Hogan <james.hogan@imgtec.com>
26Cc: Bo Hu <bohu@google.com>
27Cc: Douglas Leung <douglas.leung@imgtec.com>
28Cc: Jin Qian <jinqian@google.com>
29Cc: Paul Burton <paul.burton@imgtec.com>
30Cc: Petar Jovanovic <petar.jovanovic@imgtec.com>
31Cc: Raghu Gandham <raghu.gandham@imgtec.com>
32Cc: linux-mips@linux-mips.org
33Cc: linux-kernel@vger.kernel.org
34Patchwork: https://patchwork.linux-mips.org/patch/16883/
35Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
36Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37
38---
39 arch/mips/math-emu/dp_fmax.c | 8 ++++++--
40 arch/mips/math-emu/dp_fmin.c | 6 +++++-
41 arch/mips/math-emu/sp_fmax.c | 8 ++++++--
42 arch/mips/math-emu/sp_fmin.c | 6 +++++-
43 4 files changed, 22 insertions(+), 6 deletions(-)
44
45--- a/arch/mips/math-emu/dp_fmax.c
46+++ b/arch/mips/math-emu/dp_fmax.c
47@@ -243,7 +243,11 @@ union ieee754dp ieee754dp_fmaxa(union ie
48 return y;
49
50 /* Compare mantissa */
51- if (xm <= ym)
52+ if (xm < ym)
53 return y;
54- return x;
55+ else if (xm > ym)
56+ return x;
57+ else if (xs == 0)
58+ return x;
59+ return y;
60 }
61--- a/arch/mips/math-emu/dp_fmin.c
62+++ b/arch/mips/math-emu/dp_fmin.c
63@@ -243,7 +243,11 @@ union ieee754dp ieee754dp_fmina(union ie
64 return x;
65
66 /* Compare mantissa */
67- if (xm <= ym)
68+ if (xm < ym)
69+ return x;
70+ else if (xm > ym)
71+ return y;
72+ else if (xs == 1)
73 return x;
74 return y;
75 }
76--- a/arch/mips/math-emu/sp_fmax.c
77+++ b/arch/mips/math-emu/sp_fmax.c
78@@ -243,7 +243,11 @@ union ieee754sp ieee754sp_fmaxa(union ie
79 return y;
80
81 /* Compare mantissa */
82- if (xm <= ym)
83+ if (xm < ym)
84 return y;
85- return x;
86+ else if (xm > ym)
87+ return x;
88+ else if (xs == 0)
89+ return x;
90+ return y;
91 }
92--- a/arch/mips/math-emu/sp_fmin.c
93+++ b/arch/mips/math-emu/sp_fmin.c
94@@ -243,7 +243,11 @@ union ieee754sp ieee754sp_fmina(union ie
95 return x;
96
97 /* Compare mantissa */
98- if (xm <= ym)
99+ if (xm < ym)
100+ return x;
101+ else if (xm > ym)
102+ return y;
103+ else if (xs == 1)
104 return x;
105 return y;
106 }