[PATCH] target/ppc: Register the 745's HID0 and HID1 once

Showta Ishizaki posted 1 patch 3 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/179325247250.65414.17031704056960380956.745-hid@snowrabbit.org
Maintainers: Chinmay Rath <rathc@linux.ibm.com>, Nicholas Piggin <npiggin@gmail.com>, Glenn Miles <milesg@linux.ibm.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>
There is a newer version of this series
target/ppc/cpu_init.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
[PATCH] target/ppc: Register the 745's HID0 and HID1 once
Posted by Showta Ishizaki 3 weeks, 3 days ago
init_proc_745(), which the 755 shares, calls register_7xx_sprs() and
then register_745_sprs().  Since HID0 and HID1 moved into
register_7xx_sprs(), both functions register them the same way, and
_spr_register() asserts that no SPR is registered twice, so the 745 and
the 755 cannot be created at all:

  $ qemu-system-ppc -M none -cpu 745
  Assertion failed: (spr->name == NULL), function _spr_register,
  file helper_regs.c, line 419.

Leave the two to register_7xx_sprs().

Fixes: 0301b39c78c8 ("target/ppc: cpu_init: Deduplicate 7xx SPR registration")
Cc: qemu-stable@nongnu.org
Signed-off-by: Showta Ishizaki <zakinko@snowrabbit.org>
---
 target/ppc/cpu_init.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 7f3036d903e..9fb05ff265d 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -86,17 +86,10 @@ static void register_745_sprs(CPUPPCState *env)
                  &spr_read_generic, &spr_write_generic,
                  0x00000000);
 
-    /* Hardware implementation registers */
-    spr_register(env, SPR_HID0, "HID0",
-                 SPR_NOACCESS, SPR_NOACCESS,
-                 &spr_read_generic, &spr_write_generic,
-                 0x00000000);
-
-    spr_register(env, SPR_HID1, "HID1",
-                 SPR_NOACCESS, SPR_NOACCESS,
-                 &spr_read_generic, &spr_write_generic,
-                 0x00000000);
-
+    /*
+     * Hardware implementation registers.  HID0 and HID1 are registered by
+     * register_7xx_sprs(), which init_proc_745() calls first.
+     */
     spr_register(env, SPR_HID2, "HID2",
                  SPR_NOACCESS, SPR_NOACCESS,
                  &spr_read_generic, &spr_write_generic,

base-commit: 73294d096cc591e122fde9e63db4739de6d84f2b
-- 
2.54.0 (Apple Git-157)
Re: [PATCH] target/ppc: Register the 745's HID0 and HID1 once
Posted by Fabiano Rosas 3 weeks, 3 days ago
Showta Ishizaki <zakinko@snowrabbit.org> writes:

> init_proc_745(), which the 755 shares, calls register_7xx_sprs() and
> then register_745_sprs().  Since HID0 and HID1 moved into
> register_7xx_sprs(), both functions register them the same way, and
> _spr_register() asserts that no SPR is registered twice, so the 745 and
> the 755 cannot be created at all:
>
>   $ qemu-system-ppc -M none -cpu 745
>   Assertion failed: (spr->name == NULL), function _spr_register,
>   file helper_regs.c, line 419.
>
> Leave the two to register_7xx_sprs().
>
> Fixes: 0301b39c78c8 ("target/ppc: cpu_init: Deduplicate 7xx SPR registration")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Showta Ishizaki <zakinko@snowrabbit.org>
> ---
>  target/ppc/cpu_init.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index 7f3036d903e..9fb05ff265d 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -86,17 +86,10 @@ static void register_745_sprs(CPUPPCState *env)
>                   &spr_read_generic, &spr_write_generic,
>                   0x00000000);
>  
> -    /* Hardware implementation registers */
> -    spr_register(env, SPR_HID0, "HID0",
> -                 SPR_NOACCESS, SPR_NOACCESS,
> -                 &spr_read_generic, &spr_write_generic,
> -                 0x00000000);
> -
> -    spr_register(env, SPR_HID1, "HID1",
> -                 SPR_NOACCESS, SPR_NOACCESS,
> -                 &spr_read_generic, &spr_write_generic,
> -                 0x00000000);
> -
> +    /*
> +     * Hardware implementation registers.  HID0 and HID1 are registered by
> +     * register_7xx_sprs(), which init_proc_745() calls first.
> +     */
>      spr_register(env, SPR_HID2, "HID2",
>                   SPR_NOACCESS, SPR_NOACCESS,
>                   &spr_read_generic, &spr_write_generic,
>
> base-commit: 73294d096cc591e122fde9e63db4739de6d84f2b

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Re: [PATCH] target/ppc: Register the 745's HID0 and HID1 once
Posted by BALATON Zoltan 3 weeks, 3 days ago
On Thu, 29 Oct 2026, Showta Ishizaki wrote:
> init_proc_745(), which the 755 shares, calls register_7xx_sprs() and
> then register_745_sprs().  Since HID0 and HID1 moved into
> register_7xx_sprs(), both functions register them the same way, and
> _spr_register() asserts that no SPR is registered twice, so the 745 and
> the 755 cannot be created at all:
>
>  $ qemu-system-ppc -M none -cpu 745
>  Assertion failed: (spr->name == NULL), function _spr_register,
>  file helper_regs.c, line 419.
>
> Leave the two to register_7xx_sprs().
>
> Fixes: 0301b39c78c8 ("target/ppc: cpu_init: Deduplicate 7xx SPR registration")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Showta Ishizaki <zakinko@snowrabbit.org>
> ---
> target/ppc/cpu_init.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index 7f3036d903e..9fb05ff265d 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -86,17 +86,10 @@ static void register_745_sprs(CPUPPCState *env)
>                  &spr_read_generic, &spr_write_generic,
>                  0x00000000);
>
> -    /* Hardware implementation registers */
> -    spr_register(env, SPR_HID0, "HID0",
> -                 SPR_NOACCESS, SPR_NOACCESS,
> -                 &spr_read_generic, &spr_write_generic,
> -                 0x00000000);
> -
> -    spr_register(env, SPR_HID1, "HID1",
> -                 SPR_NOACCESS, SPR_NOACCESS,
> -                 &spr_read_generic, &spr_write_generic,
> -                 0x00000000);
> -
> +    /*
> +     * Hardware implementation registers.  HID0 and HID1 are registered by
> +     * register_7xx_sprs(), which init_proc_745() calls first.
> +     */

We don't have comments elsewhere so I'm not sure it's needed here.

Regards,
BALATON Zoltan

>     spr_register(env, SPR_HID2, "HID2",
>                  SPR_NOACCESS, SPR_NOACCESS,
>                  &spr_read_generic, &spr_write_generic,
>
> base-commit: 73294d096cc591e122fde9e63db4739de6d84f2b
>