Re: [PATCH v3 03/33] target/arm: Assert oprsz in range when using vfp.qc

2024-05-30 Thread Peter Maydell
On Tue, 28 May 2024 at 21:30, Richard Henderson
 wrote:
>
> Suggested-by: Peter Maydell 
> Signed-off-by: Richard Henderson 
> ---

Reviewed-by: Peter Maydell 

thanks
-- PMM



[PATCH v3 03/33] target/arm: Assert oprsz in range when using vfp.qc

2024-05-28 Thread Richard Henderson
Suggested-by: Peter Maydell 
Signed-off-by: Richard Henderson 
---
 target/arm/tcg/gengvec.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/target/arm/tcg/gengvec.c b/target/arm/tcg/gengvec.c
index bfe6885a01..3e2d3c21a1 100644
--- a/target/arm/tcg/gengvec.c
+++ b/target/arm/tcg/gengvec.c
@@ -29,6 +29,7 @@ static void gen_gvec_fn3_qc(uint32_t rd_ofs, uint32_t rn_ofs, 
uint32_t rm_ofs,
 {
 TCGv_ptr qc_ptr = tcg_temp_new_ptr();
 
+tcg_debug_assert(opr_sz <= sizeof_field(CPUARMState, vfp.qc));
 tcg_gen_addi_ptr(qc_ptr, tcg_env, offsetof(CPUARMState, vfp.qc));
 tcg_gen_gvec_3_ptr(rd_ofs, rn_ofs, rm_ofs, qc_ptr,
opr_sz, max_sz, 0, fn);
@@ -1255,6 +1256,8 @@ void gen_gvec_uqadd_qc(unsigned vece, uint32_t rd_ofs, 
uint32_t rn_ofs,
   .opt_opc = vecop_list,
   .vece = MO_64 },
 };
+
+tcg_debug_assert(opr_sz <= sizeof_field(CPUARMState, vfp.qc));
 tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
rn_ofs, rm_ofs, opr_sz, max_sz, &ops[vece]);
 }
@@ -1297,6 +1300,8 @@ void gen_gvec_sqadd_qc(unsigned vece, uint32_t rd_ofs, 
uint32_t rn_ofs,
   .write_aofs = true,
   .vece = MO_64 },
 };
+
+tcg_debug_assert(opr_sz <= sizeof_field(CPUARMState, vfp.qc));
 tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
rn_ofs, rm_ofs, opr_sz, max_sz, &ops[vece]);
 }
@@ -1339,6 +1344,8 @@ void gen_gvec_uqsub_qc(unsigned vece, uint32_t rd_ofs, 
uint32_t rn_ofs,
   .write_aofs = true,
   .vece = MO_64 },
 };
+
+tcg_debug_assert(opr_sz <= sizeof_field(CPUARMState, vfp.qc));
 tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
rn_ofs, rm_ofs, opr_sz, max_sz, &ops[vece]);
 }
@@ -1381,6 +1388,8 @@ void gen_gvec_sqsub_qc(unsigned vece, uint32_t rd_ofs, 
uint32_t rn_ofs,
   .write_aofs = true,
   .vece = MO_64 },
 };
+
+tcg_debug_assert(opr_sz <= sizeof_field(CPUARMState, vfp.qc));
 tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
rn_ofs, rm_ofs, opr_sz, max_sz, &ops[vece]);
 }
-- 
2.34.1