[PATCH] target/ppc: Remove unused helper_lscbx()

Peter Maydell posted 1 patch 2 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260709095056.1803725-1-peter.maydell@linaro.org
Maintainers: Nicholas Piggin <npiggin@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>, Glenn Miles <milesg@linux.ibm.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>
target/ppc/helper.h     |  1 -
target/ppc/mem_helper.c | 28 ----------------------------
2 files changed, 29 deletions(-)
[PATCH] target/ppc: Remove unused helper_lscbx()
Posted by Peter Maydell 2 weeks, 2 days ago
The helper_lscbx() function isn't called anywhere.  It used to be
used by the PPC 601 CPU support; we removed that in commit 005b69fdcc
in 2022 but missed this helper function.

Fixes: 005b69fdcc ("target/ppc: Remove PowerPC 601 CPUs")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
This came to my attention because Coverity reported a
"shifts into sign bit" issue in the function: CID 1663681
---
 target/ppc/helper.h     |  1 -
 target/ppc/mem_helper.c | 28 ----------------------------
 2 files changed, 29 deletions(-)

diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index e99c8c824b..6b2d19a3ad 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -54,7 +54,6 @@ DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl)
 #endif
 DEF_HELPER_FLAGS_2(icbi, TCG_CALL_NO_WG, void, env, tl)
 DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl)
-DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)
 
 #if defined(TARGET_PPC64)
 DEF_HELPER_4(DIVDEU, i64, env, i64, i64, i32)
diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
index 119dc1df23..787ba2cdec 100644
--- a/target/ppc/mem_helper.c
+++ b/target/ppc/mem_helper.c
@@ -367,34 +367,6 @@ void helper_icbiep(CPUPPCState *env, target_ulong addr)
 #endif
 }
 
-/* XXX: to be tested */
-target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg,
-                          uint32_t ra, uint32_t rb)
-{
-    int i, c, d;
-
-    d = 24;
-    for (i = 0; i < xer_bc; i++) {
-        c = cpu_ldub_data_ra(env, addr, GETPC());
-        addr = addr_add(env, addr, 1);
-        /* ra (if not 0) and rb are never modified */
-        if (likely(reg != rb && (ra == 0 || reg != ra))) {
-            env->gpr[reg] = (env->gpr[reg] & ~(0xFF << d)) | (c << d);
-        }
-        if (unlikely(c == xer_cmp)) {
-            break;
-        }
-        if (likely(d != 0)) {
-            d -= 8;
-        } else {
-            d = 24;
-            reg++;
-            reg = reg & 0x1F;
-        }
-    }
-    return i;
-}
-
 /*****************************************************************************/
 /* Altivec extension helpers */
 #if HOST_BIG_ENDIAN
-- 
2.43.0
Re: [PATCH] target/ppc: Remove unused helper_lscbx()
Posted by Amit Machhiwal 2 weeks, 2 days ago
On 2026/07/09 10:50 AM, Peter Maydell wrote:
> The helper_lscbx() function isn't called anywhere.  It used to be
> used by the PPC 601 CPU support; we removed that in commit 005b69fdcc
> in 2022 but missed this helper function.
> 
> Fixes: 005b69fdcc ("target/ppc: Remove PowerPC 601 CPUs")
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This came to my attention because Coverity reported a
> "shifts into sign bit" issue in the function: CID 1663681
> ---
>  target/ppc/helper.h     |  1 -
>  target/ppc/mem_helper.c | 28 ----------------------------
>  2 files changed, 29 deletions(-)

"git grep lscbx" returns only the declaration in helper.h and the
definition in mem_helper.c -- no TCG translator references, no
gen_lscbx, nothing in translate.c. Confirmed dead code with zero
callers. Thanks for the cleanup.

Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com>

Thanks,
Amit

> 
> diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> index e99c8c824b..6b2d19a3ad 100644
> --- a/target/ppc/helper.h
> +++ b/target/ppc/helper.h
> @@ -54,7 +54,6 @@ DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl)
>  #endif
>  DEF_HELPER_FLAGS_2(icbi, TCG_CALL_NO_WG, void, env, tl)
>  DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl)
> -DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)
>  
>  #if defined(TARGET_PPC64)
>  DEF_HELPER_4(DIVDEU, i64, env, i64, i64, i32)
> diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
> index 119dc1df23..787ba2cdec 100644
> --- a/target/ppc/mem_helper.c
> +++ b/target/ppc/mem_helper.c
> @@ -367,34 +367,6 @@ void helper_icbiep(CPUPPCState *env, target_ulong addr)
>  #endif
>  }
>  
> -/* XXX: to be tested */
> -target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg,
> -                          uint32_t ra, uint32_t rb)
> -{
> -    int i, c, d;
> -
> -    d = 24;
> -    for (i = 0; i < xer_bc; i++) {
> -        c = cpu_ldub_data_ra(env, addr, GETPC());
> -        addr = addr_add(env, addr, 1);
> -        /* ra (if not 0) and rb are never modified */
> -        if (likely(reg != rb && (ra == 0 || reg != ra))) {
> -            env->gpr[reg] = (env->gpr[reg] & ~(0xFF << d)) | (c << d);
> -        }
> -        if (unlikely(c == xer_cmp)) {
> -            break;
> -        }
> -        if (likely(d != 0)) {
> -            d -= 8;
> -        } else {
> -            d = 24;
> -            reg++;
> -            reg = reg & 0x1F;
> -        }
> -    }
> -    return i;
> -}
> -
>  /*****************************************************************************/
>  /* Altivec extension helpers */
>  #if HOST_BIG_ENDIAN
> -- 
> 2.43.0
> 
>
Re: [PATCH] target/ppc: Remove unused helper_lscbx()
Posted by Peter Maydell 6 days ago
Ping: this has been reviewed, is somebody on the ppc side
going to pick it up ?

thanks
-- PMM

On Thu, 9 Jul 2026 at 15:46, Amit Machhiwal <amachhiw@linux.ibm.com> wrote:
>
> On 2026/07/09 10:50 AM, Peter Maydell wrote:
> > The helper_lscbx() function isn't called anywhere.  It used to be
> > used by the PPC 601 CPU support; we removed that in commit 005b69fdcc
> > in 2022 but missed this helper function.
> >
> > Fixes: 005b69fdcc ("target/ppc: Remove PowerPC 601 CPUs")
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> > This came to my attention because Coverity reported a
> > "shifts into sign bit" issue in the function: CID 1663681
> > ---
> >  target/ppc/helper.h     |  1 -
> >  target/ppc/mem_helper.c | 28 ----------------------------
> >  2 files changed, 29 deletions(-)
>
> "git grep lscbx" returns only the declaration in helper.h and the
> definition in mem_helper.c -- no TCG translator references, no
> gen_lscbx, nothing in translate.c. Confirmed dead code with zero
> callers. Thanks for the cleanup.
>
> Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com>
>
> Thanks,
> Amit
>
> >
> > diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> > index e99c8c824b..6b2d19a3ad 100644
> > --- a/target/ppc/helper.h
> > +++ b/target/ppc/helper.h
> > @@ -54,7 +54,6 @@ DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env, tl)
> >  #endif
> >  DEF_HELPER_FLAGS_2(icbi, TCG_CALL_NO_WG, void, env, tl)
> >  DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl)
> > -DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)
> >
> >  #if defined(TARGET_PPC64)
> >  DEF_HELPER_4(DIVDEU, i64, env, i64, i64, i32)
> > diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
> > index 119dc1df23..787ba2cdec 100644
> > --- a/target/ppc/mem_helper.c
> > +++ b/target/ppc/mem_helper.c
> > @@ -367,34 +367,6 @@ void helper_icbiep(CPUPPCState *env, target_ulong addr)
> >  #endif
> >  }
> >
> > -/* XXX: to be tested */
> > -target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg,
> > -                          uint32_t ra, uint32_t rb)
> > -{
> > -    int i, c, d;
> > -
> > -    d = 24;
> > -    for (i = 0; i < xer_bc; i++) {
> > -        c = cpu_ldub_data_ra(env, addr, GETPC());
> > -        addr = addr_add(env, addr, 1);
> > -        /* ra (if not 0) and rb are never modified */
> > -        if (likely(reg != rb && (ra == 0 || reg != ra))) {
> > -            env->gpr[reg] = (env->gpr[reg] & ~(0xFF << d)) | (c << d);
> > -        }
> > -        if (unlikely(c == xer_cmp)) {
> > -            break;
> > -        }
> > -        if (likely(d != 0)) {
> > -            d -= 8;
> > -        } else {
> > -            d = 24;
> > -            reg++;
> > -            reg = reg & 0x1F;
> > -        }
> > -    }
> > -    return i;
> > -}
> > -
> >  /*****************************************************************************/
> >  /* Altivec extension helpers */
> >  #if HOST_BIG_ENDIAN
> > --
> > 2.43.0
Re: [PATCH] target/ppc: Remove unused helper_lscbx()
Posted by Harsh Prateek Bora 6 days ago
Hi Peter,

I am travelling till July end.
If it's urgent, Could you please take it via your next PR or I can take it
via next PPC PR in August.

Thanks
Harsh

On Mon, 20 Jul, 2026, 2:10 pm Peter Maydell, <peter.maydell@linaro.org>
wrote:

> Ping: this has been reviewed, is somebody on the ppc side
> going to pick it up ?
>
> thanks
> -- PMM
>
> On Thu, 9 Jul 2026 at 15:46, Amit Machhiwal <amachhiw@linux.ibm.com>
> wrote:
> >
> > On 2026/07/09 10:50 AM, Peter Maydell wrote:
> > > The helper_lscbx() function isn't called anywhere.  It used to be
> > > used by the PPC 601 CPU support; we removed that in commit 005b69fdcc
> > > in 2022 but missed this helper function.
> > >
> > > Fixes: 005b69fdcc ("target/ppc: Remove PowerPC 601 CPUs")
> > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > > ---
> > > This came to my attention because Coverity reported a
> > > "shifts into sign bit" issue in the function: CID 1663681
> > > ---
> > >  target/ppc/helper.h     |  1 -
> > >  target/ppc/mem_helper.c | 28 ----------------------------
> > >  2 files changed, 29 deletions(-)
> >
> > "git grep lscbx" returns only the declaration in helper.h and the
> > definition in mem_helper.c -- no TCG translator references, no
> > gen_lscbx, nothing in translate.c. Confirmed dead code with zero
> > callers. Thanks for the cleanup.
> >
> > Reviewed-by: Amit Machhiwal <amachhiw@linux.ibm.com>
> >
> > Thanks,
> > Amit
> >
> > >
> > > diff --git a/target/ppc/helper.h b/target/ppc/helper.h
> > > index e99c8c824b..6b2d19a3ad 100644
> > > --- a/target/ppc/helper.h
> > > +++ b/target/ppc/helper.h
> > > @@ -54,7 +54,6 @@ DEF_HELPER_FLAGS_2(dcbzl, TCG_CALL_NO_WG, void, env,
> tl)
> > >  #endif
> > >  DEF_HELPER_FLAGS_2(icbi, TCG_CALL_NO_WG, void, env, tl)
> > >  DEF_HELPER_FLAGS_2(icbiep, TCG_CALL_NO_WG, void, env, tl)
> > > -DEF_HELPER_5(lscbx, tl, env, tl, i32, i32, i32)
> > >
> > >  #if defined(TARGET_PPC64)
> > >  DEF_HELPER_4(DIVDEU, i64, env, i64, i64, i32)
> > > diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c
> > > index 119dc1df23..787ba2cdec 100644
> > > --- a/target/ppc/mem_helper.c
> > > +++ b/target/ppc/mem_helper.c
> > > @@ -367,34 +367,6 @@ void helper_icbiep(CPUPPCState *env, target_ulong
> addr)
> > >  #endif
> > >  }
> > >
> > > -/* XXX: to be tested */
> > > -target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr,
> uint32_t reg,
> > > -                          uint32_t ra, uint32_t rb)
> > > -{
> > > -    int i, c, d;
> > > -
> > > -    d = 24;
> > > -    for (i = 0; i < xer_bc; i++) {
> > > -        c = cpu_ldub_data_ra(env, addr, GETPC());
> > > -        addr = addr_add(env, addr, 1);
> > > -        /* ra (if not 0) and rb are never modified */
> > > -        if (likely(reg != rb && (ra == 0 || reg != ra))) {
> > > -            env->gpr[reg] = (env->gpr[reg] & ~(0xFF << d)) | (c << d);
> > > -        }
> > > -        if (unlikely(c == xer_cmp)) {
> > > -            break;
> > > -        }
> > > -        if (likely(d != 0)) {
> > > -            d -= 8;
> > > -        } else {
> > > -            d = 24;
> > > -            reg++;
> > > -            reg = reg & 0x1F;
> > > -        }
> > > -    }
> > > -    return i;
> > > -}
> > > -
> > >
> /*****************************************************************************/
> > >  /* Altivec extension helpers */
> > >  #if HOST_BIG_ENDIAN
> > > --
> > > 2.43.0
>
>
Re: [PATCH] target/ppc: Remove unused helper_lscbx()
Posted by Peter Maydell 6 days ago
On Mon, 20 Jul 2026 at 09:48, Harsh Prateek Bora
<harsh.prateek.bora@gmail.com> wrote:
>
> Hi Peter,
>
> I am travelling till July end.
> If it's urgent, Could you please take it via your next PR or I can take it via next PPC PR in August.

It's not super urgent, but I'm happy to pick it up via my tree
as it's a pretty small safe change.

thanks
-- PMM
Re: [PATCH] target/ppc: Remove unused helper_lscbx()
Posted by Harsh Prateek Bora 6 days ago
On Mon, 20 Jul, 2026, 2:29 pm Peter Maydell, <peter.maydell@linaro.org>
wrote:

> On Mon, 20 Jul 2026 at 09:48, Harsh Prateek Bora
> <harsh.prateek.bora@gmail.com> wrote:
> >
> > Hi Peter,
> >
> > I am travelling till July end.
> > If it's urgent, Could you please take it via your next PR or I can take
> it via next PPC PR in August.
>
> It's not super urgent, but I'm happy to pick it up via my tree
> as it's a pretty small safe change.
>

Sure, thanks Peter.

Regards
Harsh


> thanks
> -- PMM
>