[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/5] target/arm: Move computation of index in handle_simd_dupe
From: |
Peter Maydell |
Subject: |
[PULL 5/5] target/arm: Move computation of index in handle_simd_dupe |
Date: |
Mon, 23 Mar 2020 17:40:06 +0000 |
From: Richard Henderson <address@hidden>
Coverity reports a BAD_SHIFT with ctz32(imm5), with imm5 == 0.
This is an invalid encoding, but we diagnose that just below
by rejecting size > 3. Avoid the warning by sinking the
computation of index below the check.
Reported-by: Coverity (CID 1421965)
Signed-off-by: Richard Henderson <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
target/arm/translate-a64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index 032478614c4..7580e463674 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -7422,7 +7422,7 @@ static void handle_simd_dupe(DisasContext *s, int is_q,
int rd, int rn,
int imm5)
{
int size = ctz32(imm5);
- int index = imm5 >> (size + 1);
+ int index;
if (size > 3 || (size == 3 && !is_q)) {
unallocated_encoding(s);
@@ -7433,6 +7433,7 @@ static void handle_simd_dupe(DisasContext *s, int is_q,
int rd, int rn,
return;
}
+ index = imm5 >> (size + 1);
tcg_gen_gvec_dup_mem(size, vec_full_reg_offset(s, rd),
vec_reg_offset(s, rn, index, size),
is_q ? 16 : 8, vec_full_reg_size(s));
--
2.20.1
- [PULL 0/5] target-arm queue, Peter Maydell, 2020/03/23
- [PULL 4/5] target/arm: Assert immh != 0 in disas_simd_shift_imm, Peter Maydell, 2020/03/23
- [PULL 3/5] target/arm: Rearrange disabled check for watchpoints, Peter Maydell, 2020/03/23
- [PULL 5/5] target/arm: Move computation of index in handle_simd_dupe,
Peter Maydell <=
- [PULL 2/5] aspeed/smc: Fix DMA support for AST2600, Peter Maydell, 2020/03/23
- [PULL 1/5] hw/arm/bcm283x: Correct the license text, Peter Maydell, 2020/03/23
- Re: [PULL 0/5] target-arm queue, Peter Maydell, 2020/03/23