From: Ido Plat Date: Tue, 29 Oct 2024 12:54:45 +0000 (+0000) Subject: target/arm: Fix arithmetic underflow in SETM instruction X-Git-Tag: v8.2.8~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c826be9969433abb6045240d17eb031c755bf24;p=thirdparty%2Fqemu.git target/arm: Fix arithmetic underflow in SETM instruction 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 Reviewed-by: Richard Henderson Message-id: 20241025024909.799989-1-ido.plat1@ibm.com Signed-off-by: Peter Maydell (cherry picked from commit bab209af35037b33f7eb1b8a3737085935bec3a3) Signed-off-by: Michael Tokarev --- diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index 8ad84623d37..8335505a064 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -1330,7 +1330,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;