qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [RFC PATCH 2/4] hw/arm/raspi: Replace TARGET_AARCH64 by legacy_binary_is_64bit()
Date: Wed, 5 Mar 2025 08:50:56 -0800	[thread overview]
Message-ID: <391c4a7d-8dae-497b-b5f4-975d41b3252a@linaro.org> (raw)
In-Reply-To: <20250305161248.54901-3-philmd@linaro.org>

On 3/5/25 08:12, Philippe Mathieu-Daudé wrote:
> For legacy ARM binaries, legacy_binary_is_64bit() is
> equivalent of the compile time TARGET_AARCH64 definition.
> 

I'm not sure where this function comes from.

Anyway, to completely replace TARGET_AARCH64, what we want is something 
like: target_is_aarch64(), because all the objects in this file should 
not be enabled for 64 bits targets who are not arm based.

So it's more easy to introduce a specific function *per* target, and 
enable objects on a per need basis. Some will be enabled for all 
targets, some for only one, some for a specific selection.

> Use it as TypeInfo::registerable() callback to dynamically
> add Aarch64 specific types in qemu-system-aarch64 binary,
> removing the need of TARGET_AARCH64 #ifdef'ry.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/arm/bcm2836.c | 6 ++----
>   hw/arm/raspi.c   | 7 +++----
>   2 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
> index 95e16806fa1..88a32e5fc20 100644
> --- a/hw/arm/bcm2836.c
> +++ b/hw/arm/bcm2836.c
> @@ -12,6 +12,7 @@
>   #include "qemu/osdep.h"
>   #include "qapi/error.h"
>   #include "qemu/module.h"
> +#include "qemu/legacy_binary_info.h"
>   #include "hw/arm/bcm2836.h"
>   #include "hw/arm/raspi_platform.h"
>   #include "hw/sysbus.h"
> @@ -195,7 +196,6 @@ static void bcm2836_class_init(ObjectClass *oc, void *data)
>       dc->realize = bcm2836_realize;
>   };
>   
> -#ifdef TARGET_AARCH64
>   static void bcm2837_class_init(ObjectClass *oc, void *data)
>   {
>       DeviceClass *dc = DEVICE_CLASS(oc);
> @@ -208,7 +208,6 @@ static void bcm2837_class_init(ObjectClass *oc, void *data)
>       bc->clusterid = 0x0;
>       dc->realize = bcm2836_realize;
>   };
> -#endif
>   
>   static const TypeInfo bcm283x_types[] = {
>       {
> @@ -219,12 +218,11 @@ static const TypeInfo bcm283x_types[] = {
>           .name           = TYPE_BCM2836,
>           .parent         = TYPE_BCM283X,
>           .class_init     = bcm2836_class_init,
> -#ifdef TARGET_AARCH64
>       }, {
>           .name           = TYPE_BCM2837,
>           .parent         = TYPE_BCM283X,
> +        .registerable   = legacy_binary_is_64bit,
>           .class_init     = bcm2837_class_init,
> -#endif
>       }, {
>           .name           = TYPE_BCM283X,
>           .parent         = TYPE_BCM283X_BASE,
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index dce35ca11aa..f7e647a9cbf 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -15,6 +15,7 @@
>   #include "qemu/osdep.h"
>   #include "qemu/units.h"
>   #include "qemu/cutils.h"
> +#include "qemu/legacy_binary_info.h"
>   #include "qapi/error.h"
>   #include "hw/arm/boot.h"
>   #include "hw/arm/bcm2836.h"
> @@ -367,7 +368,6 @@ static void raspi2b_machine_class_init(ObjectClass *oc, void *data)
>       raspi_machine_class_init(mc, rmc->board_rev);
>   };
>   
> -#ifdef TARGET_AARCH64
>   static void raspi3ap_machine_class_init(ObjectClass *oc, void *data)
>   {
>       MachineClass *mc = MACHINE_CLASS(oc);
> @@ -387,7 +387,6 @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data)
>       rmc->board_rev = 0xa02082;
>       raspi_machine_class_init(mc, rmc->board_rev);
>   };
> -#endif /* TARGET_AARCH64 */
>   
>   static const TypeInfo raspi_machine_types[] = {
>       {
> @@ -402,16 +401,16 @@ static const TypeInfo raspi_machine_types[] = {
>           .name           = MACHINE_TYPE_NAME("raspi2b"),
>           .parent         = TYPE_RASPI_MACHINE,
>           .class_init     = raspi2b_machine_class_init,
> -#ifdef TARGET_AARCH64
>       }, {
>           .name           = MACHINE_TYPE_NAME("raspi3ap"),
>           .parent         = TYPE_RASPI_MACHINE,
> +        .registerable   = legacy_binary_is_64bit,
>           .class_init     = raspi3ap_machine_class_init,
>       }, {
>           .name           = MACHINE_TYPE_NAME("raspi3b"),
>           .parent         = TYPE_RASPI_MACHINE,
> +        .registerable   = legacy_binary_is_64bit,
>           .class_init     = raspi3b_machine_class_init,
> -#endif
>       }, {
>           .name           = TYPE_RASPI_MACHINE,
>           .parent         = TYPE_RASPI_BASE_MACHINE,


  reply	other threads:[~2025-03-05 16:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05 16:12 [RFC PATCH 0/4] hw/arm: Register target-specific QOM types at runtime Philippe Mathieu-Daudé
2025-03-05 16:12 ` [RFC PATCH 1/4] qom: Introduce TypeInfo::registerable() callback Philippe Mathieu-Daudé
2025-03-05 16:47   ` Pierrick Bouvier
2025-03-06  1:34   ` Richard Henderson
2025-03-05 16:12 ` [RFC PATCH 2/4] hw/arm/raspi: Replace TARGET_AARCH64 by legacy_binary_is_64bit() Philippe Mathieu-Daudé
2025-03-05 16:50   ` Pierrick Bouvier [this message]
2025-03-05 17:40   ` Thomas Huth
2025-03-05 18:12     ` Cédric Le Goater
2025-03-05 18:35       ` Thomas Huth
2025-03-05 19:07         ` Philippe Mathieu-Daudé
2025-03-05 20:41           ` BALATON Zoltan
2025-03-06  6:12           ` Thomas Huth
2025-03-06  9:21   ` Daniel P. Berrangé
2025-03-06 10:13     ` Peter Maydell
2025-03-05 16:12 ` [RFC PATCH 3/4] hw/arm/aspeed: " Philippe Mathieu-Daudé
2025-03-05 16:33   ` Cédric Le Goater
2025-03-05 17:07     ` Philippe Mathieu-Daudé
2025-03-05 17:43   ` Thomas Huth
2025-03-05 16:12 ` [RFC PATCH 4/4] hw/ppc: Remove TARGET_PPC64 use in ppc_create_page_sizes_prop() Philippe Mathieu-Daudé
2025-03-05 16:52   ` Pierrick Bouvier
2025-03-05 16:53 ` [RFC PATCH 0/4] hw/arm: Register target-specific QOM types at runtime Pierrick Bouvier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=391c4a7d-8dae-497b-b5f4-975d41b3252a@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=clg@kaod.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).