aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Markovic <[email protected]>2017-08-21 14:24:47 +0200
committerRalf Baechle <[email protected]>2017-08-29 15:21:56 +0200
commit1ff8560ac9db1cbffcd700b70e1661f2fcc2e5d7 (patch)
tree0a42550ba42a4e94f9ae8b9e8bd5e07816086699
parent2cfa58259f4b65b33ebe8f167019a1f89c6c3289 (diff)
MIPS: math-emu: CMP.Sxxx.<D|S>: Prevent occurrences of SIGILL crashes
Fix CMP.Sxxx.<D|S> SIGILL crashes by fixing main switch/case statement in fpu_emul() function so that inadvertent fall-troughs are prevented. Consider, let's say, CMP.SAF.S instruction when one of inputs is zero and another input is a signaling NaN. The desired output is zero, and the exception flag "invalid operation" set. For such case, the main portion of the implementation is within "d_fmt" case of the main "switch/case" statement in fpu_emul() function. The execution will follow one of "if-else" branches that doesn't contain "goto cop1scr;" statement, and will therefore reach the end of "d_fmt" case. It will subsequently fall through to the next case, "l_fmt". After following similar pattern, the execution will fall through to the succeeding case, which is "default". The "default" case contains "return SIGILL;" statement only. This means that the caller application will crash with "illegal instruction" message. It is obvious that above described fall-throughs are unnecessary and harmful. This patch rectifies that behavior by providing "break;" statements at the end of cases "d_fmt" and "l_fmt". There are 22 instructions affected by this problem: CMP.<SAF|SEQ|SLE|SLT|SNE|SOR|SUEQ|SULE|SULT|SUN|SUNE>.<D|S>. Signed-off-by: Miodrag Dinic <[email protected]> Signed-off-by: Goran Ferenc <[email protected]> Signed-off-by: Aleksandar Markovic <[email protected]> Cc: Douglas Leung <[email protected]> Cc: James Hogan <[email protected]> Cc: Maciej W. Rozycki <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Paul Burton <[email protected]> Cc: Petar Jovanovic <[email protected]> Cc: Raghu Gandham <[email protected]> Cc: [email protected] Cc: [email protected] Patchwork: https://patchwork.linux-mips.org/patch/17140/ Signed-off-by: Ralf Baechle <[email protected]>
-rw-r--r--arch/mips/math-emu/cp1emu.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index d225e2173899..9694e9e0b14c 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -2394,6 +2394,7 @@ dcopuop:
break;
}
}
+ break;
}
case l_fmt:
@@ -2468,6 +2469,8 @@ dcopuop:
break;
}
}
+ break;
+
default:
return SIGILL;
}