diff mbox series

[RFC,4/4] hw/ppc: Remove TARGET_PPC64 use in ppc_create_page_sizes_prop()

Message ID 20250305161248.54901-5-philmd@linaro.org
State New
Headers show
Series hw/arm: Register target-specific QOM types at runtime | expand

Commit Message

Philippe Mathieu-Daudé March 5, 2025, 4:12 p.m. UTC
Check the binary is built for 64-bit PPC at runtime,
removing the need for TARGET_PPC64 #ifdef'ry.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/ppc/fdt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Pierrick Bouvier March 5, 2025, 4:52 p.m. UTC | #1
On 3/5/25 08:12, Philippe Mathieu-Daudé wrote:
> Check the binary is built for 64-bit PPC at runtime,
> removing the need for TARGET_PPC64 #ifdef'ry.
> 

Same goes here, we want a target_is_ppc64() function.
As well, modifying hw/ppc stuff should be in an independent series 
ideally, to keep it more clear.

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/ppc/fdt.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ppc/fdt.c b/hw/ppc/fdt.c
> index 0828ad72548..bae269c72ac 100644
> --- a/hw/ppc/fdt.c
> +++ b/hw/ppc/fdt.c
> @@ -8,12 +8,12 @@
>    */
>   
>   #include "qemu/osdep.h"
> +#include "qemu/legacy_binary_info.h"
>   #include "target/ppc/cpu.h"
>   #include "target/ppc/mmu-hash64.h"
>   
>   #include "hw/ppc/fdt.h"
>   
> -#if defined(TARGET_PPC64)
>   size_t ppc_create_page_sizes_prop(PowerPCCPU *cpu, uint32_t *prop,
>                                     size_t maxsize)
>   {
> @@ -21,6 +21,8 @@ size_t ppc_create_page_sizes_prop(PowerPCCPU *cpu, uint32_t *prop,
>       int i, j, count;
>       uint32_t *p = prop;
>   
> +    assert(legacy_binary_is_64bit());
> +
>       for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) {
>           PPCHash64SegmentPageSizes *sps = &cpu->hash64_opts->sps[i];
>   
> @@ -46,4 +48,3 @@ size_t ppc_create_page_sizes_prop(PowerPCCPU *cpu, uint32_t *prop,
>   
>       return (p - prop) * sizeof(uint32_t);
>   }
> -#endif
diff mbox series

Patch

diff --git a/hw/ppc/fdt.c b/hw/ppc/fdt.c
index 0828ad72548..bae269c72ac 100644
--- a/hw/ppc/fdt.c
+++ b/hw/ppc/fdt.c
@@ -8,12 +8,12 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu/legacy_binary_info.h"
 #include "target/ppc/cpu.h"
 #include "target/ppc/mmu-hash64.h"
 
 #include "hw/ppc/fdt.h"
 
-#if defined(TARGET_PPC64)
 size_t ppc_create_page_sizes_prop(PowerPCCPU *cpu, uint32_t *prop,
                                   size_t maxsize)
 {
@@ -21,6 +21,8 @@  size_t ppc_create_page_sizes_prop(PowerPCCPU *cpu, uint32_t *prop,
     int i, j, count;
     uint32_t *p = prop;
 
+    assert(legacy_binary_is_64bit());
+
     for (i = 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) {
         PPCHash64SegmentPageSizes *sps = &cpu->hash64_opts->sps[i];
 
@@ -46,4 +48,3 @@  size_t ppc_create_page_sizes_prop(PowerPCCPU *cpu, uint32_t *prop,
 
     return (p - prop) * sizeof(uint32_t);
 }
-#endif