[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] target/ppc: fix unreachable code in do_ldst_quad()
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH] target/ppc: fix unreachable code in do_ldst_quad() |
Date: |
Wed, 20 Jul 2022 10:57:23 -0300 |
Coverity reports that commit fc34e81acd51 ("target/ppc: add macros to
check privilege level") turned the following code unreachable:
if (!prefixed && !(ctx->insns_flags2 & PPC2_LSQ_ISA207)) {
/* lq and stq were privileged prior to V. 2.07 */
REQUIRE_SV(ctx);
>>> CID 1490757: Control flow issues (UNREACHABLE)
>>> This code cannot be reached: "if (ctx->le_mode) {
if (ctx->le_mode) {
gen_align_no_le(ctx);
return true;
}
}
This happens because the macro REQUIRE_SV(), in CONFIG_USER_MODE, will
always result in a 'return true' statement.
Fix it by using "#if !defined(CONFIG_USER_ONLY)" to fold the code that
shouldn't be there if we're running in a non-privileged state. This is
also how the REQUIRE_SV() macro is being used in
storage-ctrl-impl.c.inc.
Fixes: Coverity CID 1490757
Fixes: fc34e81acd51 ("target/ppc: add macros to check privilege level")
Cc: Matheus Ferst <matheus.ferst@eldorado.org.br>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
target/ppc/translate/fixedpoint-impl.c.inc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/target/ppc/translate/fixedpoint-impl.c.inc
b/target/ppc/translate/fixedpoint-impl.c.inc
index db14d3bebc..4a32fac4f3 100644
--- a/target/ppc/translate/fixedpoint-impl.c.inc
+++ b/target/ppc/translate/fixedpoint-impl.c.inc
@@ -82,10 +82,14 @@ static bool do_ldst_quad(DisasContext *ctx, arg_D *a, bool
store, bool prefixed)
/* lq and stq were privileged prior to V. 2.07 */
REQUIRE_SV(ctx);
+#if !defined(CONFIG_USER_ONLY)
if (ctx->le_mode) {
gen_align_no_le(ctx);
return true;
}
+#else
+ qemu_build_not_reached();
+#endif
}
if (!store && unlikely(a->ra == a->rt)) {
--
2.36.1
- [PATCH] target/ppc: fix unreachable code in do_ldst_quad(),
Daniel Henrique Barboza <=