target/arm: Fix arithmetic underflow in SETM instruction
authorIdo Plat <ido.plat1@ibm.com>
Tue, 29 Oct 2024 12:54:45 +0000 (12:54 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 29 Oct 2024 15:04:47 +0000 (15:04 +0000)
Pass the stage size to step function callback, otherwise do_setm
would hang when size is larger then page size because stage size
would underflow.  This fix changes do_setm to be more inline with
do_setp.

Cc: qemu-stable@nongnu.org
Fixes: 0e92818887dee ("target/arm: Implement the SET* instructions")
Signed-off-by: Ido Plat <ido.plat1@ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241025024909.799989-1-ido.plat1@ibm.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target/arm/tcg/helper-a64.c

index 56b431faf57f4809cac09692d18ec312b4b85113..8f42a28d07ba31e8f0fabcfd5c1a66953310df89 100644 (file)
@@ -1348,7 +1348,7 @@ static void do_setm(CPUARMState *env, uint32_t syndrome, uint32_t mtedesc,
     /* Do the actual memset: we leave the last partial page to SETE */
     stagesetsize = setsize & TARGET_PAGE_MASK;
     while (stagesetsize > 0) {
-        step = stepfn(env, toaddr, setsize, data, memidx, &mtedesc, ra);
+        step = stepfn(env, toaddr, stagesetsize, data, memidx, &mtedesc, ra);
         toaddr += step;
         setsize -= step;
         stagesetsize -= step;