diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-07-12 07:51:44 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-07-25 14:40:49 +0200 |
commit | e37fdc73811dd40ccf1409e1edb9f7403283dd87 (patch) | |
tree | 809dc63abdbc47cbb74fa435ab90dd46d97051b4 /target | |
parent | d4eda549d27b6d0abdaa55a76dd2d0eff7d65bf0 (diff) | |
download | qemu-e37fdc73811dd40ccf1409e1edb9f7403283dd87.zip qemu-e37fdc73811dd40ccf1409e1edb9f7403283dd87.tar.gz qemu-e37fdc73811dd40ccf1409e1edb9f7403283dd87.tar.bz2 |
target/mips/mxu: Avoid overrun in gen_mxu_S32SLT()
Coverity reports a potential overrun (CID 1517769):
Overrunning array "mxu_gpr" of 15 8-byte elements at
element index 4294967295 (byte offset 34359738367)
using index "XRb - 1U" (which evaluates to 4294967295).
Use gen_load_mxu_gpr() to safely load MXU registers.
Fixes: ff7936f009 ("target/mips/mxu: Add S32SLT ... insns")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230712060806.82323-3-philmd@linaro.org>
Diffstat (limited to 'target')
-rw-r--r-- | target/mips/tcg/mxu_translate.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/target/mips/tcg/mxu_translate.c b/target/mips/tcg/mxu_translate.c index b007948..520747a 100644 --- a/target/mips/tcg/mxu_translate.c +++ b/target/mips/tcg/mxu_translate.c @@ -2434,8 +2434,12 @@ static void gen_mxu_S32SLT(DisasContext *ctx) tcg_gen_movi_tl(mxu_gpr[XRa - 1], 0); } else { /* the most general case */ - tcg_gen_setcond_tl(TCG_COND_LT, mxu_gpr[XRa - 1], - mxu_gpr[XRb - 1], mxu_gpr[XRc - 1]); + TCGv t0 = tcg_temp_new(); + TCGv t1 = tcg_temp_new(); + + gen_load_mxu_gpr(t0, XRb); + gen_load_mxu_gpr(t1, XRc); + tcg_gen_setcond_tl(TCG_COND_LT, mxu_gpr[XRa - 1], t0, t1); } } |