target/mips/mxu: Avoid overrun in gen_mxu_q8adde()
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Wed, 12 Jul 2023 05:41:32 +0000 (07:41 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 25 Jul 2023 12:40:49 +0000 (14:40 +0200)
commitfb51df0c8ea4afe17ec9af98d10650a05b36113e
treeeee1ec18719ebf9267945ba52191d101b3d1b792
parente37fdc73811dd40ccf1409e1edb9f7403283dd87
target/mips/mxu: Avoid overrun in gen_mxu_q8adde()

Coverity reports a potential overruns (CID 1517770):

  Overrunning array "mxu_gpr" of 15 8-byte elements at
  element index 4294967295 (byte offset 34359738367)
  using index "XRb - 1U" (which evaluates to 4294967295).

Add a gen_extract_mxu_gpr() helper similar to
gen_load_mxu_gpr() to safely extract MXU registers.

Fixes: eb79951ab6 ("target/mips/mxu: Add Q8ADDE ... insns")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230712060806.82323-4-philmd@linaro.org>
target/mips/tcg/mxu_translate.c