aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandar Markovic <aleksandar.markovic@mips.com>2017-11-02 07:13:58 -0400
committerJames Hogan <jhogan@kernel.org>2017-11-07 13:33:15 -0500
commit409fcace9963c1e8d2cb0f7ac62e8b34d47ef979 (patch)
tree35b31a5b963f66c2fdf299ea90c458cab2cab93b
parentedf188bee1d908ea8181d2067ddaeefab9264688 (diff)
MIPS: math-emu: Fix final emulation phase for certain instructions
Fix final phase of <CLASS|MADDF|MSUBF|MAX|MIN|MAXA|MINA>.<D|S> emulation. Provide proper generation of SIGFPE signal and updating debugfs FP exception stats in cases of any exception flags set in preceding phases of emulation. CLASS.<D|S> instruction may generate "Unimplemented Operation" FP exception. <MADDF|MSUBF>.<D|S> instructions may generate "Inexact", "Unimplemented Operation", "Invalid Operation", "Overflow", and "Underflow" FP exceptions. <MAX|MIN|MAXA|MINA>.<D|S> instructions can generate "Unimplemented Operation" and "Invalid Operation" FP exceptions. The proper final processing of the cases when any FP exception flag is set is achieved by replacing "break" statement with "goto copcsr" statement. With such solution, this patch brings the final phase of emulation of the above instructions consistent with the one corresponding to the previously implemented emulation of other related FPU instructions (ADD, SUB, etc.). Fixes: 38db37ba069f ("MIPS: math-emu: Add support for the MIPS R6 CLASS FPU instruction") Fixes: e24c3bec3e8e ("MIPS: math-emu: Add support for the MIPS R6 MADDF FPU instruction") Fixes: 83d43305a1df ("MIPS: math-emu: Add support for the MIPS R6 MSUBF FPU instruction") Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction") Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction") Signed-off-by: Aleksandar Markovic <aleksandar.markovic@mips.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Douglas Leung <douglas.leung@mips.com> Cc: Goran Ferenc <goran.ferenc@mips.com> Cc: "Maciej W. Rozycki" <macro@imgtec.com> Cc: Miodrag Dinic <miodrag.dinic@mips.com> Cc: Paul Burton <paul.burton@mips.com> Cc: Petar Jovanovic <petar.jovanovic@mips.com> Cc: Raghu Gandham <raghu.gandham@mips.com> Cc: linux-mips@linux-mips.org Cc: <stable@vger.kernel.org> # 4.3+ Patchwork: https://patchwork.linux-mips.org/patch/17581/ Signed-off-by: James Hogan <jhogan@kernel.org>
-rw-r--r--arch/mips/math-emu/cp1emu.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 192542dbd972..d2fcb3084279 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -1795,7 +1795,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1795 SPFROMREG(fs, MIPSInst_FS(ir)); 1795 SPFROMREG(fs, MIPSInst_FS(ir));
1796 SPFROMREG(fd, MIPSInst_FD(ir)); 1796 SPFROMREG(fd, MIPSInst_FD(ir));
1797 rv.s = ieee754sp_maddf(fd, fs, ft); 1797 rv.s = ieee754sp_maddf(fd, fs, ft);
1798 break; 1798 goto copcsr;
1799 } 1799 }
1800 1800
1801 case fmsubf_op: { 1801 case fmsubf_op: {
@@ -1809,7 +1809,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1809 SPFROMREG(fs, MIPSInst_FS(ir)); 1809 SPFROMREG(fs, MIPSInst_FS(ir));
1810 SPFROMREG(fd, MIPSInst_FD(ir)); 1810 SPFROMREG(fd, MIPSInst_FD(ir));
1811 rv.s = ieee754sp_msubf(fd, fs, ft); 1811 rv.s = ieee754sp_msubf(fd, fs, ft);
1812 break; 1812 goto copcsr;
1813 } 1813 }
1814 1814
1815 case frint_op: { 1815 case frint_op: {
@@ -1834,7 +1834,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1834 SPFROMREG(fs, MIPSInst_FS(ir)); 1834 SPFROMREG(fs, MIPSInst_FS(ir));
1835 rv.w = ieee754sp_2008class(fs); 1835 rv.w = ieee754sp_2008class(fs);
1836 rfmt = w_fmt; 1836 rfmt = w_fmt;
1837 break; 1837 goto copcsr;
1838 } 1838 }
1839 1839
1840 case fmin_op: { 1840 case fmin_op: {
@@ -1847,7 +1847,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1847 SPFROMREG(ft, MIPSInst_FT(ir)); 1847 SPFROMREG(ft, MIPSInst_FT(ir));
1848 SPFROMREG(fs, MIPSInst_FS(ir)); 1848 SPFROMREG(fs, MIPSInst_FS(ir));
1849 rv.s = ieee754sp_fmin(fs, ft); 1849 rv.s = ieee754sp_fmin(fs, ft);
1850 break; 1850 goto copcsr;
1851 } 1851 }
1852 1852
1853 case fmina_op: { 1853 case fmina_op: {
@@ -1860,7 +1860,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1860 SPFROMREG(ft, MIPSInst_FT(ir)); 1860 SPFROMREG(ft, MIPSInst_FT(ir));
1861 SPFROMREG(fs, MIPSInst_FS(ir)); 1861 SPFROMREG(fs, MIPSInst_FS(ir));
1862 rv.s = ieee754sp_fmina(fs, ft); 1862 rv.s = ieee754sp_fmina(fs, ft);
1863 break; 1863 goto copcsr;
1864 } 1864 }
1865 1865
1866 case fmax_op: { 1866 case fmax_op: {
@@ -1873,7 +1873,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1873 SPFROMREG(ft, MIPSInst_FT(ir)); 1873 SPFROMREG(ft, MIPSInst_FT(ir));
1874 SPFROMREG(fs, MIPSInst_FS(ir)); 1874 SPFROMREG(fs, MIPSInst_FS(ir));
1875 rv.s = ieee754sp_fmax(fs, ft); 1875 rv.s = ieee754sp_fmax(fs, ft);
1876 break; 1876 goto copcsr;
1877 } 1877 }
1878 1878
1879 case fmaxa_op: { 1879 case fmaxa_op: {
@@ -1886,7 +1886,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1886 SPFROMREG(ft, MIPSInst_FT(ir)); 1886 SPFROMREG(ft, MIPSInst_FT(ir));
1887 SPFROMREG(fs, MIPSInst_FS(ir)); 1887 SPFROMREG(fs, MIPSInst_FS(ir));
1888 rv.s = ieee754sp_fmaxa(fs, ft); 1888 rv.s = ieee754sp_fmaxa(fs, ft);
1889 break; 1889 goto copcsr;
1890 } 1890 }
1891 1891
1892 case fabs_op: 1892 case fabs_op:
@@ -2165,7 +2165,7 @@ copcsr:
2165 DPFROMREG(fs, MIPSInst_FS(ir)); 2165 DPFROMREG(fs, MIPSInst_FS(ir));
2166 DPFROMREG(fd, MIPSInst_FD(ir)); 2166 DPFROMREG(fd, MIPSInst_FD(ir));
2167 rv.d = ieee754dp_maddf(fd, fs, ft); 2167 rv.d = ieee754dp_maddf(fd, fs, ft);
2168 break; 2168 goto copcsr;
2169 } 2169 }
2170 2170
2171 case fmsubf_op: { 2171 case fmsubf_op: {
@@ -2179,7 +2179,7 @@ copcsr:
2179 DPFROMREG(fs, MIPSInst_FS(ir)); 2179 DPFROMREG(fs, MIPSInst_FS(ir));
2180 DPFROMREG(fd, MIPSInst_FD(ir)); 2180 DPFROMREG(fd, MIPSInst_FD(ir));
2181 rv.d = ieee754dp_msubf(fd, fs, ft); 2181 rv.d = ieee754dp_msubf(fd, fs, ft);
2182 break; 2182 goto copcsr;
2183 } 2183 }
2184 2184
2185 case frint_op: { 2185 case frint_op: {
@@ -2204,7 +2204,7 @@ copcsr:
2204 DPFROMREG(fs, MIPSInst_FS(ir)); 2204 DPFROMREG(fs, MIPSInst_FS(ir));
2205 rv.l = ieee754dp_2008class(fs); 2205 rv.l = ieee754dp_2008class(fs);
2206 rfmt = l_fmt; 2206 rfmt = l_fmt;
2207 break; 2207 goto copcsr;
2208 } 2208 }
2209 2209
2210 case fmin_op: { 2210 case fmin_op: {
@@ -2217,7 +2217,7 @@ copcsr:
2217 DPFROMREG(ft, MIPSInst_FT(ir)); 2217 DPFROMREG(ft, MIPSInst_FT(ir));
2218 DPFROMREG(fs, MIPSInst_FS(ir)); 2218 DPFROMREG(fs, MIPSInst_FS(ir));
2219 rv.d = ieee754dp_fmin(fs, ft); 2219 rv.d = ieee754dp_fmin(fs, ft);
2220 break; 2220 goto copcsr;
2221 } 2221 }
2222 2222
2223 case fmina_op: { 2223 case fmina_op: {
@@ -2230,7 +2230,7 @@ copcsr:
2230 DPFROMREG(ft, MIPSInst_FT(ir)); 2230 DPFROMREG(ft, MIPSInst_FT(ir));
2231 DPFROMREG(fs, MIPSInst_FS(ir)); 2231 DPFROMREG(fs, MIPSInst_FS(ir));
2232 rv.d = ieee754dp_fmina(fs, ft); 2232 rv.d = ieee754dp_fmina(fs, ft);
2233 break; 2233 goto copcsr;
2234 } 2234 }
2235 2235
2236 case fmax_op: { 2236 case fmax_op: {
@@ -2243,7 +2243,7 @@ copcsr:
2243 DPFROMREG(ft, MIPSInst_FT(ir)); 2243 DPFROMREG(ft, MIPSInst_FT(ir));
2244 DPFROMREG(fs, MIPSInst_FS(ir)); 2244 DPFROMREG(fs, MIPSInst_FS(ir));
2245 rv.d = ieee754dp_fmax(fs, ft); 2245 rv.d = ieee754dp_fmax(fs, ft);
2246 break; 2246 goto copcsr;
2247 } 2247 }
2248 2248
2249 case fmaxa_op: { 2249 case fmaxa_op: {
@@ -2256,7 +2256,7 @@ copcsr:
2256 DPFROMREG(ft, MIPSInst_FT(ir)); 2256 DPFROMREG(ft, MIPSInst_FT(ir));
2257 DPFROMREG(fs, MIPSInst_FS(ir)); 2257 DPFROMREG(fs, MIPSInst_FS(ir));
2258 rv.d = ieee754dp_fmaxa(fs, ft); 2258 rv.d = ieee754dp_fmaxa(fs, ft);
2259 break; 2259 goto copcsr;
2260 } 2260 }
2261 2261
2262 case fabs_op: 2262 case fabs_op: