qemu-arm.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>, qemu-devel@nongnu.org
Cc: Anton Johansson <anjo@rev.ng>, qemu-arm@nongnu.org
Subject: Re: [PATCH v6 19/30] qemu/target-info: Add target_base_arch()
Date: Tue, 21 Oct 2025 09:53:18 +0200	[thread overview]
Message-ID: <60f2024e-324e-4856-952b-59ededfb2468@linaro.org> (raw)
In-Reply-To: <bc03818e-d76a-4301-931a-058f21bb6847@linaro.org>

On 21/10/25 01:15, Pierrick Bouvier wrote:
> On 2025-10-20 15:14, Philippe Mathieu-Daudé wrote:
>> When multiple QEMU targets are variants (word size, endianness)
>> of the same base architecture, target_base_arch() returns this
>> base. For example, for the Aarch64 target it will return
>> SYS_EMU_TARGET_ARM as common base.
>>
> 
> I'm not sure that reusing semantic on a subset of this enum is the best 
> idea, so many things can go wrong.
> 
> More widely, I don't know where we would need to access this, versus 
> specific functions like target_base_arm().
> If a code needs to check various base archs target_base_*, or it can use 
> a switch with all variants.

Yeah, good point. I'll just drop this single patch.

> 
> If we really want to have this target_base concept, at least it deserves 
> it's own enum, separate from SYS_EMU_TARGET.
> 
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/qemu/target-info-impl.h |  2 ++
>>   include/qemu/target-info-qapi.h |  7 +++++++
>>   target-info-stub.c              |  1 +
>>   target-info.c                   | 10 ++++++++++
>>   4 files changed, 20 insertions(+)
>>
>> diff --git a/include/qemu/target-info-impl.h b/include/qemu/target- 
>> info-impl.h
>> index e446585bf53..2c171f8359b 100644
>> --- a/include/qemu/target-info-impl.h
>> +++ b/include/qemu/target-info-impl.h
>> @@ -17,6 +17,8 @@ typedef struct TargetInfo {
>>       const char *target_name;
>>       /* related to TARGET_ARCH definition */
>>       SysEmuTarget target_arch;
>> +    /* related to TARGET_BASE_ARCH definition (target/${base_arch}/ 
>> path) */
>> +    SysEmuTarget target_base_arch;
>>       /* runtime equivalent of TARGET_LONG_BITS definition */
>>       unsigned long_bits;
>>       /* runtime equivalent of CPU_RESOLVING_TYPE definition */
>> diff --git a/include/qemu/target-info-qapi.h b/include/qemu/target- 
>> info-qapi.h
>> index d5ce0523238..65ed4ca8eea 100644
>> --- a/include/qemu/target-info-qapi.h
>> +++ b/include/qemu/target-info-qapi.h
>> @@ -19,6 +19,13 @@
>>    */
>>   SysEmuTarget target_arch(void);
>> +/**
>> + * target_base_arch:
>> + *
>> + * Returns: QAPI SysEmuTarget enum (i.e. SYS_EMU_TARGET_I386).
>> + */
>> +SysEmuTarget target_base_arch(void);
>> +
>>   /**
>>    * target_endian_mode:
>>    *
>> diff --git a/target-info-stub.c b/target-info-stub.c
>> index d96d8249c1d..d2cfca1b4c2 100644
>> --- a/target-info-stub.c
>> +++ b/target-info-stub.c
>> @@ -19,6 +19,7 @@ QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != 
>> sizeof(CPUState));
>>   static const TargetInfo target_info_stub = {
>>       .target_name = TARGET_NAME,
>>       .target_arch = SYS_EMU_TARGET__MAX,
>> +    .target_base_arch = SYS_EMU_TARGET__MAX,
> 
> And nothing can enforce base and arch match by design, which is a 
> problem IMHO.
> 
>>       .long_bits = TARGET_LONG_BITS,
>>       .cpu_type = CPU_RESOLVING_TYPE,
>>       .machine_typename = TYPE_MACHINE,
>> diff --git a/target-info.c b/target-info.c
>> index e567cb4c40a..332198e40a2 100644
>> --- a/target-info.c
>> +++ b/target-info.c
>> @@ -33,6 +33,16 @@ SysEmuTarget target_arch(void)
>>       return arch;
>>   }
>> +SysEmuTarget target_base_arch(void)
>> +{
>> +    SysEmuTarget base_arch = target_info()->target_base_arch;
>> +
>> +    if (base_arch == SYS_EMU_TARGET__MAX) {
>> +        base_arch = target_arch();
>> +    }
>> +    return base_arch;
> 
> More confusing, we can eventually return a non base arch if base arch 
> was not correctly set above.
> 
>> +}
>> +
>>   const char *target_cpu_type(void)
>>   {
>>       return target_info()->cpu_type;



  reply	other threads:[~2025-10-21  7:53 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-20 22:09 [PATCH v6 00/30] single-binary: Make hw/arm/ common Philippe Mathieu-Daudé
2025-10-20 22:09 ` [PATCH v6 01/30] hw/core: Filter machine list available for a particular target binary Philippe Mathieu-Daudé
2025-10-20 23:02   ` Pierrick Bouvier
2025-10-20 22:09 ` [PATCH v6 02/30] hw/boards: Move DEFINE_MACHINE() definition closer to its doc string Philippe Mathieu-Daudé
2025-10-20 23:02   ` Pierrick Bouvier
2025-10-20 22:09 ` [PATCH v6 03/30] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases Philippe Mathieu-Daudé
2025-10-20 23:03   ` Pierrick Bouvier
2025-10-20 22:09 ` [PATCH v6 04/30] hw/boards: Introduce DEFINE_MACHINE_WITH_INTERFACE_ARRAY() macro Philippe Mathieu-Daudé
2025-10-20 22:09 ` [PATCH v6 05/30] hw/arm: Register TYPE_TARGET_ARM/AARCH64_MACHINE QOM interfaces Philippe Mathieu-Daudé
2025-10-20 22:09 ` [PATCH v6 06/30] hw/core: Allow ARM/Aarch64 binaries to use the 'none' machine Philippe Mathieu-Daudé
2025-10-20 22:09 ` [PATCH v6 07/30] hw/arm: Add DEFINE_MACHINE_[ARM_]AARCH64() macros Philippe Mathieu-Daudé
2025-10-20 22:09 ` [PATCH v6 08/30] hw/arm: Filter machine types for qemu-system-arm/aarch64 binaries Philippe Mathieu-Daudé
2025-10-21  5:41   ` Jan Kiszka
2025-10-21  7:55     ` Philippe Mathieu-Daudé
2025-10-20 22:09 ` [PATCH v6 09/30] qemu/target-info: Include missing 'qapi-types-common.h' header Philippe Mathieu-Daudé
2025-10-20 23:04   ` Pierrick Bouvier
2025-10-20 22:09 ` [PATCH v6 10/30] meson: Prepare to accept per-binary TargetInfo structure implementation Philippe Mathieu-Daudé
2025-10-20 22:13 ` [PATCH 11/30] config/target: Implement per-binary TargetInfo structure (ARM, AARCH64) Philippe Mathieu-Daudé
2025-10-20 22:13 ` [PATCH 12/30] hw/arm/aspeed: Build objects once Philippe Mathieu-Daudé
2025-10-20 22:13 ` [PATCH 13/30] hw/arm/raspi: " Philippe Mathieu-Daudé
2025-10-20 22:13 ` [PATCH 14/30] hw/core/machine: Allow dynamic registration of valid CPU types Philippe Mathieu-Daudé
2025-10-20 22:13 ` [PATCH 15/30] hw/arm/virt: Register valid CPU types dynamically Philippe Mathieu-Daudé
2025-10-20 22:14 ` [PATCH v6 16/30] hw/arm/virt: Check accelerator availability at runtime Philippe Mathieu-Daudé
2025-10-20 22:14 ` [PATCH v6 17/30] qemu/target_info: Add target_arm() helper Philippe Mathieu-Daudé
2025-10-20 23:08   ` Pierrick Bouvier
2025-10-20 22:14 ` [PATCH v6 18/30] qemu/target_info: Add target_aarch64() helper Philippe Mathieu-Daudé
2025-10-20 23:08   ` Pierrick Bouvier
2025-10-20 22:14 ` [PATCH v6 19/30] qemu/target-info: Add target_base_arch() Philippe Mathieu-Daudé
2025-10-20 23:15   ` Pierrick Bouvier
2025-10-21  7:53     ` Philippe Mathieu-Daudé [this message]
2025-10-20 22:14 ` [PATCH v6 20/30] qemu/target_info: Add target_base_arm() helper Philippe Mathieu-Daudé
2025-10-20 23:16   ` Pierrick Bouvier
2025-10-20 22:14 ` [PATCH v6 21/30] hw/arm/virt: Replace TARGET_AARCH64 -> target_aarch64() Philippe Mathieu-Daudé
2025-10-20 23:16   ` Pierrick Bouvier
2025-10-20 22:15 ` [PATCH v6 22/30] hw/core: Introduce MachineClass::get_default_cpu_type() helper Philippe Mathieu-Daudé
2025-10-20 22:15 ` [PATCH v6 23/30] hw/arm/virt: Get default CPU type at runtime Philippe Mathieu-Daudé
2025-10-20 23:37   ` Pierrick Bouvier
2025-10-20 22:15 ` [PATCH v6 24/30] hw/arm/sbsa-ref: Include missing 'cpu.h' header Philippe Mathieu-Daudé
2025-10-20 23:38   ` Pierrick Bouvier
2025-10-20 22:20 ` [PATCH v6 25/30] hw/arm/sbsa-ref: Build only once Philippe Mathieu-Daudé
2025-10-20 23:39   ` Pierrick Bouvier
2025-10-20 22:20 ` [PATCH v6 26/30] hw/arm/virt-acpi-build: Include missing 'cpu.h' header Philippe Mathieu-Daudé
2025-10-20 23:40   ` Pierrick Bouvier
2025-10-20 22:20 ` [PATCH v6 27/30] hw/arm/virt-acpi-build: Build only once Philippe Mathieu-Daudé
2025-10-20 23:40   ` Pierrick Bouvier
2025-10-20 22:20 ` [PATCH v6 28/30] hw/arm/virt: " Philippe Mathieu-Daudé
2025-10-20 23:40   ` Pierrick Bouvier
2025-10-20 22:20 ` [PATCH v6 29/30] hw/arm/meson: Move Xen files to arm_common_ss[] Philippe Mathieu-Daudé
2025-10-20 23:41   ` Pierrick Bouvier
2025-10-20 22:20 ` [PATCH v6 30/30] hw/arm/meson: Remove now unused arm_ss[] source set Philippe Mathieu-Daudé
2025-10-20 23:41   ` 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=60f2024e-324e-4856-952b-59ededfb2468@linaro.org \
    --to=philmd@linaro.org \
    --cc=anjo@rev.ng \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).