[PATCH RFC] target/arm: add bounding a->imm assertion

Anastasia Belova posted 1 patch 6 days, 22 hours ago
There is a newer version of this series
target/arm/tcg/translate-sve.c | 1 +
1 file changed, 1 insertion(+)
[PATCH RFC] target/arm: add bounding a->imm assertion
Posted by Anastasia Belova 6 days, 22 hours ago
From: Anastasia Belova <nabelova31@gmail.com>

Add an assertion similar to that in the do_shr_narrow().
This will make sure that functions from sshll_ops
have correct arguments.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
 target/arm/tcg/translate-sve.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
index d23be477b4..47ada85c92 100644
--- a/target/arm/tcg/translate-sve.c
+++ b/target/arm/tcg/translate-sve.c
@@ -6250,6 +6250,7 @@ static bool do_shll_tb(DisasContext *s, arg_rri_esz *a,
     if (a->esz < 0 || a->esz > 2) {
         return false;
     }
+    assert(a->imm > 0 && a->imm <= (8 << a->esz));
     if (sve_access_check(s)) {
         unsigned vsz = vec_full_reg_size(s);
         tcg_gen_gvec_2i(vec_full_reg_offset(s, a->rd),
-- 
2.47.0
Re: [PATCH RFC] target/arm: add bounding a->imm assertion
Posted by Anastasia Belova 6 days, 21 hours ago
Sorry for accidentaly sending this patch twice.

My mail system reports that it can't be delivered to Peter Maydell 
<peter.maydell@linaro.org>
and I am trying to solve it.

On 3/25/25 1:17 PM, Anastasia Belova wrote:
> From: Anastasia Belova <nabelova31@gmail.com>
>
> Add an assertion similar to that in the do_shr_narrow().
> This will make sure that functions from sshll_ops
> have correct arguments.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
> ---
>   target/arm/tcg/translate-sve.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
> index d23be477b4..47ada85c92 100644
> --- a/target/arm/tcg/translate-sve.c
> +++ b/target/arm/tcg/translate-sve.c
> @@ -6250,6 +6250,7 @@ static bool do_shll_tb(DisasContext *s, arg_rri_esz *a,
>       if (a->esz < 0 || a->esz > 2) {
>           return false;
>       }
> +    assert(a->imm > 0 && a->imm <= (8 << a->esz));
>       if (sve_access_check(s)) {
>           unsigned vsz = vec_full_reg_size(s);
>           tcg_gen_gvec_2i(vec_full_reg_offset(s, a->rd),