[PATCH 0/4] target-info: preserve full softmmu target identity

Yonggang Luo posted 4 patches 1 month, 2 weeks ago
Failed in applying to current master (apply log)
meson.build            | 11 +++++++++--
target-info-stub.c     |  2 +-
tests/qtest/qmp-test.c | 13 +++++++++++++
3 files changed, 23 insertions(+), 3 deletions(-)
[PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
`TARGET_ARCH` identifies a base architecture, not necessarily the full
system-emulation target. For example, `mipsel-softmmu` uses `TARGET_ARCH=mips`,
which caused `query-target` to report `mips` instead of `mipsel`.

Generate `TARGET_SYS_EMU` separately. Softmmu builds use the full target name,
as `SysEmuTarget` enumerates system targets. User-mode builds use
`TARGET_ARCH`: user target names such as `aarch64_be` and `mipsn32el` do not
have corresponding `SysEmuTarget` values. This means `mipsel-linux-user` now
reports the base architecture `mips` rather than `mipsel`; its executable name
remains unchanged. Initialize `TargetInfo.target_arch` from this token and add
a qtest to check the `query-target` result against the target name of the
running QEMU binary.

Yonggang Luo (4):
  Revert "target-info: Statically initialize target_arch"
  Revert "meson: Add TARGET_ARCH to config_target_data"
  tests/qtest: check query-target architecture
  target-info: preserve full softmmu target identity

 meson.build            | 11 +++++++++--
 target-info-stub.c     |  2 +-
 tests/qtest/qmp-test.c | 13 +++++++++++++
 3 files changed, 23 insertions(+), 3 deletions(-)

-- 
2.55.0.windows.3
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/4/2026 12:29 AM, Yonggang Luo wrote:
> `TARGET_ARCH` identifies a base architecture, not necessarily the full
> system-emulation target. For example, `mipsel-softmmu` uses `TARGET_ARCH=mips`,
> which caused `query-target` to report `mips` instead of `mipsel`.
> 
> Generate `TARGET_SYS_EMU` separately. Softmmu builds use the full target name,
> as `SysEmuTarget` enumerates system targets. User-mode builds use
> `TARGET_ARCH`: user target names such as `aarch64_be` and `mipsn32el` do not
> have corresponding `SysEmuTarget` values. This means `mipsel-linux-user` now
> reports the base architecture `mips` rather than `mipsel`; its executable name
> remains unchanged. Initialize `TargetInfo.target_arch` from this token and add
> a qtest to check the `query-target` result against the target name of the
> running QEMU binary.
> 
> Yonggang Luo (4):
>   Revert "target-info: Statically initialize target_arch"
>   Revert "meson: Add TARGET_ARCH to config_target_data"
>   tests/qtest: check query-target architecture
>   target-info: preserve full softmmu target identity
> 
>  meson.build            | 11 +++++++++--
>  target-info-stub.c     |  2 +-
>  tests/qtest/qmp-test.c | 13 +++++++++++++
>  3 files changed, 23 insertions(+), 3 deletions(-)
> 

Why should we do this for user binaries? Current work around
single-binary only concerns system binaries, where all targets are
correctly covered by what exists.

Regards,
Pierrick
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 12:03 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/4/2026 12:29 AM, Yonggang Luo wrote:
> > `TARGET_ARCH` identifies a base architecture, not necessarily the full
> > system-emulation target. For example, `mipsel-softmmu` uses `TARGET_ARCH=mips`,
> > which caused `query-target` to report `mips` instead of `mipsel`.
> >
> > Generate `TARGET_SYS_EMU` separately. Softmmu builds use the full target name,
> > as `SysEmuTarget` enumerates system targets. User-mode builds use
> > `TARGET_ARCH`: user target names such as `aarch64_be` and `mipsn32el` do not
> > have corresponding `SysEmuTarget` values. This means `mipsel-linux-user` now
> > reports the base architecture `mips` rather than `mipsel`; its executable name
> > remains unchanged. Initialize `TargetInfo.target_arch` from this token and add
> > a qtest to check the `query-target` result against the target name of the
> > running QEMU binary.
> >
> > Yonggang Luo (4):
> >   Revert "target-info: Statically initialize target_arch"
> >   Revert "meson: Add TARGET_ARCH to config_target_data"
> >   tests/qtest: check query-target architecture
> >   target-info: preserve full softmmu target identity
> >
> >  meson.build            | 11 +++++++++--
> >  target-info-stub.c     |  2 +-
> >  tests/qtest/qmp-test.c | 13 +++++++++++++
> >  3 files changed, 23 insertions(+), 3 deletions(-)
> >
>
> Why should we do this for user binaries? Current work around
> single-binary only concerns system binaries, where all targets are
> correctly covered by what exists.

From my personal point of view, keeping target_arch as
SYS_EMU_TARGET__MAX for user binaries
is a better option. I am doing this is for replica of commit

"target-info: Statically initialize target_arch"

>
> Regards,
> Pierrick



-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/5/2026 9:10 AM, Yonggang Luo wrote:
> On Tue, Oct 6, 2026 at 12:03 AM Pierrick Bouvier
> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>
>> On 10/4/2026 12:29 AM, Yonggang Luo wrote:
>>> `TARGET_ARCH` identifies a base architecture, not necessarily the full
>>> system-emulation target. For example, `mipsel-softmmu` uses `TARGET_ARCH=mips`,
>>> which caused `query-target` to report `mips` instead of `mipsel`.
>>>
>>> Generate `TARGET_SYS_EMU` separately. Softmmu builds use the full target name,
>>> as `SysEmuTarget` enumerates system targets. User-mode builds use
>>> `TARGET_ARCH`: user target names such as `aarch64_be` and `mipsn32el` do not
>>> have corresponding `SysEmuTarget` values. This means `mipsel-linux-user` now
>>> reports the base architecture `mips` rather than `mipsel`; its executable name
>>> remains unchanged. Initialize `TargetInfo.target_arch` from this token and add
>>> a qtest to check the `query-target` result against the target name of the
>>> running QEMU binary.
>>>
>>> Yonggang Luo (4):
>>>   Revert "target-info: Statically initialize target_arch"
>>>   Revert "meson: Add TARGET_ARCH to config_target_data"
>>>   tests/qtest: check query-target architecture
>>>   target-info: preserve full softmmu target identity
>>>
>>>  meson.build            | 11 +++++++++--
>>>  target-info-stub.c     |  2 +-
>>>  tests/qtest/qmp-test.c | 13 +++++++++++++
>>>  3 files changed, 23 insertions(+), 3 deletions(-)
>>>
>>
>> Why should we do this for user binaries? Current work around
>> single-binary only concerns system binaries, where all targets are
>> correctly covered by what exists.
> 
> From my personal point of view, keeping target_arch as
> SYS_EMU_TARGET__MAX for user binaries
> is a better option. I am doing this is for replica of commit
>

Ok, but I'm not sure it answers the why.
Could you explain the benefits?

> "target-info: Statically initialize target_arch"
> 
>>
>> Regards,
>> Pierrick
> 
> 
> 


Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 12:12 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/5/2026 9:10 AM, Yonggang Luo wrote:
> > On Tue, Oct 6, 2026 at 12:03 AM Pierrick Bouvier
> > <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>
> >> On 10/4/2026 12:29 AM, Yonggang Luo wrote:
> >>> `TARGET_ARCH` identifies a base architecture, not necessarily the full
> >>> system-emulation target. For example, `mipsel-softmmu` uses `TARGET_ARCH=mips`,
> >>> which caused `query-target` to report `mips` instead of `mipsel`.
> >>>
> >>> Generate `TARGET_SYS_EMU` separately. Softmmu builds use the full target name,
> >>> as `SysEmuTarget` enumerates system targets. User-mode builds use
> >>> `TARGET_ARCH`: user target names such as `aarch64_be` and `mipsn32el` do not
> >>> have corresponding `SysEmuTarget` values. This means `mipsel-linux-user` now
> >>> reports the base architecture `mips` rather than `mipsel`; its executable name
> >>> remains unchanged. Initialize `TargetInfo.target_arch` from this token and add
> >>> a qtest to check the `query-target` result against the target name of the
> >>> running QEMU binary.
> >>>
> >>> Yonggang Luo (4):
> >>>   Revert "target-info: Statically initialize target_arch"
> >>>   Revert "meson: Add TARGET_ARCH to config_target_data"
> >>>   tests/qtest: check query-target architecture
> >>>   target-info: preserve full softmmu target identity
> >>>
> >>>  meson.build            | 11 +++++++++--
> >>>  target-info-stub.c     |  2 +-
> >>>  tests/qtest/qmp-test.c | 13 +++++++++++++
> >>>  3 files changed, 23 insertions(+), 3 deletions(-)
> >>>
> >>
> >> Why should we do this for user binaries? Current work around
> >> single-binary only concerns system binaries, where all targets are
> >> correctly covered by what exists.
> >
> > From my personal point of view, keeping target_arch as
> > SYS_EMU_TARGET__MAX for user binaries
> > is a better option. I am doing this is for replica of commit
> >
>
> Ok, but I'm not sure it answers the why.
> Could you explain the benefits?

Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
The following original code would return -1 for some user-binary
+    SysEmuTarget arch = target_info()->target_arch;
+
+    if (arch == SYS_EMU_TARGET__MAX) {
+        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
+                               &error_abort);
+    }
+    return arch;
So basically assigning any value for the user binary is valid.
SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
-1 is another option but easy to confuse.


For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
"target-info: Statically initialize target_arch"
doing that, I am not sure.


>
> > "target-info: Statically initialize target_arch"
> >
> >>
> >> Regards,
> >> Pierrick
> >
> >
> >
>

--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/5/2026 9:19 AM, Yonggang Luo wrote:
> On Tue, Oct 6, 2026 at 12:12 AM Pierrick Bouvier
> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>
>> On 10/5/2026 9:10 AM, Yonggang Luo wrote:
>>> On Tue, Oct 6, 2026 at 12:03 AM Pierrick Bouvier
>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>
>>>> On 10/4/2026 12:29 AM, Yonggang Luo wrote:
>>>>> `TARGET_ARCH` identifies a base architecture, not necessarily the full
>>>>> system-emulation target. For example, `mipsel-softmmu` uses `TARGET_ARCH=mips`,
>>>>> which caused `query-target` to report `mips` instead of `mipsel`.
>>>>>
>>>>> Generate `TARGET_SYS_EMU` separately. Softmmu builds use the full target name,
>>>>> as `SysEmuTarget` enumerates system targets. User-mode builds use
>>>>> `TARGET_ARCH`: user target names such as `aarch64_be` and `mipsn32el` do not
>>>>> have corresponding `SysEmuTarget` values. This means `mipsel-linux-user` now
>>>>> reports the base architecture `mips` rather than `mipsel`; its executable name
>>>>> remains unchanged. Initialize `TargetInfo.target_arch` from this token and add
>>>>> a qtest to check the `query-target` result against the target name of the
>>>>> running QEMU binary.
>>>>>
>>>>> Yonggang Luo (4):
>>>>>   Revert "target-info: Statically initialize target_arch"
>>>>>   Revert "meson: Add TARGET_ARCH to config_target_data"
>>>>>   tests/qtest: check query-target architecture
>>>>>   target-info: preserve full softmmu target identity
>>>>>
>>>>>  meson.build            | 11 +++++++++--
>>>>>  target-info-stub.c     |  2 +-
>>>>>  tests/qtest/qmp-test.c | 13 +++++++++++++
>>>>>  3 files changed, 23 insertions(+), 3 deletions(-)
>>>>>
>>>>
>>>> Why should we do this for user binaries? Current work around
>>>> single-binary only concerns system binaries, where all targets are
>>>> correctly covered by what exists.
>>>
>>> From my personal point of view, keeping target_arch as
>>> SYS_EMU_TARGET__MAX for user binaries
>>> is a better option. I am doing this is for replica of commit
>>>
>>
>> Ok, but I'm not sure it answers the why.
>> Could you explain the benefits?
> 
> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
> The following original code would return -1 for some user-binary
> +    SysEmuTarget arch = target_info()->target_arch;
> +
> +    if (arch == SYS_EMU_TARGET__MAX) {
> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
> +                               &error_abort);
> +    }
> +    return arch;
> So basically assigning any value for the user binary is valid.
> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
> -1 is another option but easy to confuse.
> 
> 
> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> "target-info: Statically initialize target_arch"
> doing that, I am not sure.
>

I guess there is a (good or bad) reason for which sub variants of
targets are not reflected in SYS_EMU_TARGET enum. We should double check
that before doing any change, as it might have other consequences.

> 
>>
>>> "target-info: Statically initialize target_arch"
>>>
>>>>
>>>> Regards,
>>>> Pierrick
>>>
>>>
>>>
>>
> 
> --
>          此致
> 礼
> 罗勇刚
> Yours
>     sincerely,
> Yonggang Luo


Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
> >>
> >> Ok, but I'm not sure it answers the why.
> >> Could you explain the benefits?
> >
> > Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
> > The following original code would return -1 for some user-binary
> > +    SysEmuTarget arch = target_info()->target_arch;
> > +
> > +    if (arch == SYS_EMU_TARGET__MAX) {
> > +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
> > +                               &error_abort);
> > +    }
> > +    return arch;
> > So basically assigning any value for the user binary is valid.
> > SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
> > -1 is another option but easy to confuse.
> >
> >
> > For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> > "target-info: Statically initialize target_arch"
> > doing that, I am not sure.
> >
>
> I guess there is a (good or bad) reason for which sub variants of
> targets are not reflected in SYS_EMU_TARGET enum. We should double check
> that before doing any change, as it might have other consequences.


You’re right to ask, and I need to correct my earlier suggestion:
leaving user-mode target_arch
 as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
code shared with user-mode builds,
including cpu-max-v8.c, where its result indexes a two-entry array.
For aarch64-linux-user, the sentinel could therefore cause an
out-of-bounds access during type registration.

I checked the distinction: softmmu needs the full system-target
identity, including variants such as mipsel;
user-mode variants such as aarch64_be use their base TARGET_ARCH
(aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
 value for softmmu and use TARGET_ARCH for user-mode builds, rather
than leave the field at SYS_EMU_TARGET__MAX.

>
> >
> >>
> >>> "target-info: Statically initialize target_arch"
> >>>
> >>>>
> >>>> Regards,
> >>>> Pierrick
> >>>
> >>>
> >>>
> >>
> >
> > --
> >          此致
> > 礼
> > 罗勇刚
> > Yours
> >     sincerely,
> > Yonggang Luo
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/5/2026 10:04 AM, Yonggang Luo wrote:
> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>
>>>> Ok, but I'm not sure it answers the why.
>>>> Could you explain the benefits?
>>>
>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
>>> The following original code would return -1 for some user-binary
>>> +    SysEmuTarget arch = target_info()->target_arch;
>>> +
>>> +    if (arch == SYS_EMU_TARGET__MAX) {
>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
>>> +                               &error_abort);
>>> +    }
>>> +    return arch;
>>> So basically assigning any value for the user binary is valid.
>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
>>> -1 is another option but easy to confuse.
>>>
>>>
>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
>>> "target-info: Statically initialize target_arch"
>>> doing that, I am not sure.
>>>
>>
>> I guess there is a (good or bad) reason for which sub variants of
>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
>> that before doing any change, as it might have other consequences.
> 
> 
> You’re right to ask, and I need to correct my earlier suggestion:
> leaving user-mode target_arch
>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
> code shared with user-mode builds,
> including cpu-max-v8.c, where its result indexes a two-entry array.
> For aarch64-linux-user, the sentinel could therefore cause an
> out-of-bounds access during type registration.
> 
> I checked the distinction: softmmu needs the full system-target
> identity, including variants such as mipsel;
> user-mode variants such as aarch64_be use their base TARGET_ARCH
> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
> than leave the field at SYS_EMU_TARGET__MAX.
>

That's technical details, but not an answer to the initial question of
why we need to change anything for user binaries, compared to what exists.

>>
>>>
>>>>
>>>>> "target-info: Statically initialize target_arch"
>>>>>
>>>>>>
>>>>>> Regards,
>>>>>> Pierrick
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>> --
>>>          此致
>>> 礼
>>> 罗勇刚
>>> Yours
>>>     sincerely,
>>> Yonggang Luo
>>
> 
> 


Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
> > On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
> > <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>
> >>>> Ok, but I'm not sure it answers the why.
> >>>> Could you explain the benefits?
> >>>
> >>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
> >>> The following original code would return -1 for some user-binary
> >>> +    SysEmuTarget arch = target_info()->target_arch;
> >>> +
> >>> +    if (arch == SYS_EMU_TARGET__MAX) {
> >>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
> >>> +                               &error_abort);
> >>> +    }
> >>> +    return arch;
> >>> So basically assigning any value for the user binary is valid.
> >>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
> >>> -1 is another option but easy to confuse.
> >>>
> >>>
> >>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> >>> "target-info: Statically initialize target_arch"
> >>> doing that, I am not sure.
> >>>
> >>
> >> I guess there is a (good or bad) reason for which sub variants of
> >> targets are not reflected in SYS_EMU_TARGET enum. We should double check
> >> that before doing any change, as it might have other consequences.
> >
> >
> > You’re right to ask, and I need to correct my earlier suggestion:
> > leaving user-mode target_arch
> >  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
> > code shared with user-mode builds,
> > including cpu-max-v8.c, where its result indexes a two-entry array.
> > For aarch64-linux-user, the sentinel could therefore cause an
> > out-of-bounds access during type registration.
> >
> > I checked the distinction: softmmu needs the full system-target
> > identity, including variants such as mipsel;
> > user-mode variants such as aarch64_be use their base TARGET_ARCH
> > (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
> >  value for softmmu and use TARGET_ARCH for user-mode builds, rather
> > than leave the field at SYS_EMU_TARGET__MAX.
> >
>
> That's technical details, but not an answer to the initial question of
> why we need to change anything for user binaries, compared to what exists.

The first two patches revert the current static initialization so the
token can be replaced. They are not a user-mode behavior change.

Compared with current QEMU, user-mode still uses TARGET_ARCH.
qemu-mipsel already reports mips, and it still will. Names such as
aarch64_be are not SysEmuTarget values, so user-mode cannot use the
full target name for this field; keeping TARGET_ARCH preserves today's
value and avoids the runtime parse.

The only intended change is softmmu, where TARGET_NAME differs from
TARGET_ARCH. qemu-system-mipsel must report mipsel, not mips.

The cover-letter sentence about mipsel-linux-user compared against the
old target_name() parse, not against current QEMU.



>
> >>
> >>>
> >>>>
> >>>>> "target-info: Statically initialize target_arch"
> >>>>>
> >>>>>>
> >>>>>> Regards,
> >>>>>> Pierrick
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>
> >>> --
> >>>          此致
> >>> 礼
> >>> 罗勇刚
> >>> Yours
> >>>     sincerely,
> >>> Yonggang Luo
> >>
> >
> >
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/5/2026 11:45 AM, Yonggang Luo wrote:
> On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>
>> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
>>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>>>
>>>>>> Ok, but I'm not sure it answers the why.
>>>>>> Could you explain the benefits?
>>>>>
>>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
>>>>> The following original code would return -1 for some user-binary
>>>>> +    SysEmuTarget arch = target_info()->target_arch;
>>>>> +
>>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
>>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
>>>>> +                               &error_abort);
>>>>> +    }
>>>>> +    return arch;
>>>>> So basically assigning any value for the user binary is valid.
>>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
>>>>> -1 is another option but easy to confuse.
>>>>>
>>>>>
>>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
>>>>> "target-info: Statically initialize target_arch"
>>>>> doing that, I am not sure.
>>>>>
>>>>
>>>> I guess there is a (good or bad) reason for which sub variants of
>>>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
>>>> that before doing any change, as it might have other consequences.
>>>
>>>
>>> You’re right to ask, and I need to correct my earlier suggestion:
>>> leaving user-mode target_arch
>>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
>>> code shared with user-mode builds,
>>> including cpu-max-v8.c, where its result indexes a two-entry array.
>>> For aarch64-linux-user, the sentinel could therefore cause an
>>> out-of-bounds access during type registration.
>>>
>>> I checked the distinction: softmmu needs the full system-target
>>> identity, including variants such as mipsel;
>>> user-mode variants such as aarch64_be use their base TARGET_ARCH
>>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
>>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
>>> than leave the field at SYS_EMU_TARGET__MAX.
>>>
>>
>> That's technical details, but not an answer to the initial question of
>> why we need to change anything for user binaries, compared to what exists.
> 
> The first two patches revert the current static initialization so the
> token can be replaced. They are not a user-mode behavior change.
> 
> Compared with current QEMU, user-mode still uses TARGET_ARCH.
> qemu-mipsel already reports mips, and it still will. Names such as
> aarch64_be are not SysEmuTarget values, so user-mode cannot use the
> full target name for this field; keeping TARGET_ARCH preserves today's
> value and avoids the runtime parse.
>

Why should we need to expose this precise information?
So far, if those targets were not exposed (and aliased to 32/64 bit
variant), it's probably we didn't need it.

In case there is a real need to expose it, maybe the simplest solution
is to add such target configs.

> The only intended change is softmmu, where TARGET_NAME differs from
> TARGET_ARCH. qemu-system-mipsel must report mipsel, not mips.
> 
> The cover-letter sentence about mipsel-linux-user compared against the
> old target_name() parse, not against current QEMU.
> 
> 
> 
>>
>>>>
>>>>>
>>>>>>
>>>>>>> "target-info: Statically initialize target_arch"
>>>>>>>
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Pierrick
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>>          此致
>>>>> 礼
>>>>> 罗勇刚
>>>>> Yours
>>>>>     sincerely,
>>>>> Yonggang Luo
>>>>
>>>
>>>
>>
> 
> 


Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Daniel P. Berrangé 1 month, 2 weeks ago
On Mon, Oct 05, 2026 at 11:52:48AM -0700, Pierrick Bouvier wrote:
> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
> > On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
> > <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>
> >> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
> >>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
> >>> <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>>>
> >>>>>> Ok, but I'm not sure it answers the why.
> >>>>>> Could you explain the benefits?
> >>>>>
> >>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
> >>>>> The following original code would return -1 for some user-binary
> >>>>> +    SysEmuTarget arch = target_info()->target_arch;
> >>>>> +
> >>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
> >>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
> >>>>> +                               &error_abort);
> >>>>> +    }
> >>>>> +    return arch;
> >>>>> So basically assigning any value for the user binary is valid.
> >>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
> >>>>> -1 is another option but easy to confuse.
> >>>>>
> >>>>>
> >>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> >>>>> "target-info: Statically initialize target_arch"
> >>>>> doing that, I am not sure.
> >>>>>
> >>>>
> >>>> I guess there is a (good or bad) reason for which sub variants of
> >>>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
> >>>> that before doing any change, as it might have other consequences.
> >>>
> >>>
> >>> You’re right to ask, and I need to correct my earlier suggestion:
> >>> leaving user-mode target_arch
> >>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
> >>> code shared with user-mode builds,
> >>> including cpu-max-v8.c, where its result indexes a two-entry array.
> >>> For aarch64-linux-user, the sentinel could therefore cause an
> >>> out-of-bounds access during type registration.
> >>>
> >>> I checked the distinction: softmmu needs the full system-target
> >>> identity, including variants such as mipsel;
> >>> user-mode variants such as aarch64_be use their base TARGET_ARCH
> >>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
> >>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
> >>> than leave the field at SYS_EMU_TARGET__MAX.
> >>>
> >>
> >> That's technical details, but not an answer to the initial question of
> >> why we need to change anything for user binaries, compared to what exists.
> > 
> > The first two patches revert the current static initialization so the
> > token can be replaced. They are not a user-mode behavior change.
> > 
> > Compared with current QEMU, user-mode still uses TARGET_ARCH.
> > qemu-mipsel already reports mips, and it still will. Names such as
> > aarch64_be are not SysEmuTarget values, so user-mode cannot use the
> > full target name for this field; keeping TARGET_ARCH preserves today's
> > value and avoids the runtime parse.
> >
> 
> Why should we need to expose this precise information?
> So far, if those targets were not exposed (and aliased to 32/64 bit
> variant), it's probably we didn't need it.

Current git master is exhibiting a regression compared to previous
releases.

For example on 10.1.0:

$ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
/usr/bin/qemu-system-aarch64: "aarch64"
/usr/bin/qemu-system-alpha: "alpha"
/usr/bin/qemu-system-arm: "arm"
/usr/bin/qemu-system-avr: "avr"
/usr/bin/qemu-system-hppa: "hppa"
/usr/bin/qemu-system-i386: "i386"
/usr/bin/qemu-system-loongarch64: "loongarch64"
/usr/bin/qemu-system-m68k: "m68k"
/usr/bin/qemu-system-microblaze: "microblaze"
/usr/bin/qemu-system-microblazeel: "microblazeel"
/usr/bin/qemu-system-mips: "mips"
/usr/bin/qemu-system-mips64: "mips64"
/usr/bin/qemu-system-mips64el: "mips64el"
/usr/bin/qemu-system-mipsel: "mipsel"
/usr/bin/qemu-system-or1k: "or1k"
/usr/bin/qemu-system-ppc: "ppc"
/usr/bin/qemu-system-ppc64: "ppc64"
/usr/bin/qemu-system-riscv32: "riscv32"
/usr/bin/qemu-system-riscv64: "riscv64"
/usr/bin/qemu-system-rx: "rx"
/usr/bin/qemu-system-s390x: "s390x"
/usr/bin/qemu-system-sh4: "sh4"
/usr/bin/qemu-system-sh4eb: "sh4eb"
/usr/bin/qemu-system-sparc: "sparc"
/usr/bin/qemu-system-sparc64: "sparc64"
/usr/bin/qemu-system-tricore: "tricore"
/usr/bin/qemu-system-x86_64: "x86_64"
/usr/bin/qemu-system-xtensa: "xtensa"
/usr/bin/qemu-system-xtensaeb: "xtensaeb"


but on git master:

$ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
./build/qemu-system-hexagon: "hexagon"
./build/qemu-system-x86_64: "x86_64"
./build/qemu-system-s390x: "s390x"
./build/qemu-system-m68k: "m68k"
./build/qemu-system-xtensa: "xtensa"
./build/qemu-system-xtensaeb: "xtensa"
./build/qemu-system-rx: "rx"
./build/qemu-system-loongarch64: "loongarch64"
./build/qemu-system-riscv32: "riscv32"
./build/qemu-system-hppa: "hppa"
./build/qemu-system-ppc64: "ppc64"
./build/qemu-system-microblaze: "microblaze"
./build/qemu-system-sparc: "sparc"
./build/qemu-system-riscv64: "riscv64"
./build/qemu-system-i386: "i386"
./build/qemu-system-mipsel: "mips"
./build/qemu-system-sh4: "sh4"
./build/qemu-system-mips64el: "mips64"
./build/qemu-system-mips64: "mips64"
./build/qemu-system-sparc64: "sparc64"
./build/qemu-system-arm: "arm"
./build/qemu-system-tricore: "tricore"
./build/qemu-system-mips: "mips"
./build/qemu-system-or1k: "or1k"
./build/qemu-system-sh4eb: "sh4"
./build/qemu-system-aarch64: "aarch64"
./build/qemu-system-ppc: "ppc"
./build/qemu-system-avr: "avr"
./build/qemu-system-alpha: "alpha"


so we need to fix that behaviour change for query-target.

If we want to be able to expose only the "base" target,
then query-target's  QemuTargetInfo struct could be
extended with a 2nd field that presents the base.


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
On 6/10/26 15:56, Daniel P. Berrangé wrote:

> Current git master is exhibiting a regression compared to previous
> releases.
> 
> For example on 10.1.0:
> 
> $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done

> /usr/bin/qemu-system-xtensa: "xtensa"
> /usr/bin/qemu-system-xtensaeb: "xtensaeb"
> 
> 
> but on git master:
> 
> $ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done


> ./build/qemu-system-xtensa: "xtensa"
> ./build/qemu-system-xtensaeb: "xtensa"

> so we need to fix that behaviour change for query-target.
On a side note it would be helpful to have such test in CI :)

Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Wed, Oct 7, 2026 at 3:42 PM Philippe Mathieu-Daudé
<philmd@oss.qualcomm.com> wrote:
>
> On 6/10/26 15:56, Daniel P. Berrangé wrote:
>
> > Current git master is exhibiting a regression compared to previous
> > releases.
> >
> > For example on 10.1.0:
> >
> > $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
>
> > /usr/bin/qemu-system-xtensa: "xtensa"
> > /usr/bin/qemu-system-xtensaeb: "xtensaeb"
> >
> >
> > but on git master:
> >
> > $ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
>
>
> > ./build/qemu-system-xtensa: "xtensa"
> > ./build/qemu-system-xtensaeb: "xtensa"
>
> > so we need to fix that behaviour change for query-target.
> On a side note it would be helpful to have such test in CI :)

I have post it, the fourth patch


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Wed, Oct 7, 2026 at 3:42 PM Philippe Mathieu-Daudé
<philmd@oss.qualcomm.com> wrote:
>
> On 6/10/26 15:56, Daniel P. Berrangé wrote:
>
> > Current git master is exhibiting a regression compared to previous
> > releases.
> >
> > For example on 10.1.0:
> >
> > $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
>
> > /usr/bin/qemu-system-xtensa: "xtensa"
> > /usr/bin/qemu-system-xtensaeb: "xtensaeb"
> >
> >
> > but on git master:
> >
> > $ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
>
>
> > ./build/qemu-system-xtensa: "xtensa"
> > ./build/qemu-system-xtensaeb: "xtensa"
>
> > so we need to fix that behaviour change for query-target.
> On a side note it would be helpful to have such test in CI :)

I have already done that in
https://patchew.org/QEMU/20261004072927.1142-1-luoyonggang@gmail.com/20261004072927.1142-4-luoyonggang@gmail.com/

Check that query-target reports the target identity selected by the qtest
binary, including softmmu variants.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 tests/qtest/qmp-test.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c
index 927ab053f8..c70f6a681c 100644
--- a/tests/qtest/qmp-test.c
+++ b/tests/qtest/qmp-test.c
@@ -164,6 +164,18 @@ static void test_qmp_protocol(void)
     qtest_quit(qts);
 }

+static void test_query_target(void)
+{
+    QTestState *qts = qtest_init(common_args);
+    QDict *target;
+
+    target = qtest_qmp_assert_success_ref(qts,
+                                          "{ 'execute': 'query-target' }");
+    g_assert_cmpstr(qdict_get_try_str(target, "arch"), ==, qtest_get_arch());
+    qobject_unref(target);
+    qtest_quit(qts);
+}
+
 #ifndef _WIN32

 /* Out-of-band tests */
@@ -517,6 +529,7 @@ int main(int argc, char *argv[])
     g_test_init(&argc, &argv, NULL);

     qtest_add_func("qmp/protocol", test_qmp_protocol);
+    qtest_add_func("qmp/query-target", test_query_target);
 #ifndef _WIN32
     /* This case calls mkfifo() which does not exist on win32 */
     qtest_add_func("qmp/oob", test_qmp_oob);
-- 
2.55.0.windows.3

-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/7/2026 1:28 AM, Yonggang Luo wrote:
> On Wed, Oct 7, 2026 at 3:42 PM Philippe Mathieu-Daudé
> <philmd@oss.qualcomm.com> wrote:
>>
>> On 6/10/26 15:56, Daniel P. Berrangé wrote:
>>
>>> Current git master is exhibiting a regression compared to previous
>>> releases.
>>>
>>> For example on 10.1.0:
>>>
>>> $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
>>
>>> /usr/bin/qemu-system-xtensa: "xtensa"
>>> /usr/bin/qemu-system-xtensaeb: "xtensaeb"
>>>
>>>
>>> but on git master:
>>>
>>> $ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
>>
>>
>>> ./build/qemu-system-xtensa: "xtensa"
>>> ./build/qemu-system-xtensaeb: "xtensa"
>>
>>> so we need to fix that behaviour change for query-target.
>> On a side note it would be helpful to have such test in CI :)
> 
> I have already done that in
> https://patchew.org/QEMU/20261004072927.1142-1-luoyonggang@gmail.com/20261004072927.1142-4-luoyonggang@gmail.com/
> 
> Check that query-target reports the target identity selected by the qtest
> binary, including softmmu variants.
> 
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  tests/qtest/qmp-test.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c
> index 927ab053f8..c70f6a681c 100644
> --- a/tests/qtest/qmp-test.c
> +++ b/tests/qtest/qmp-test.c
> @@ -164,6 +164,18 @@ static void test_qmp_protocol(void)
>      qtest_quit(qts);
>  }
> 
> +static void test_query_target(void)
> +{
> +    QTestState *qts = qtest_init(common_args);
> +    QDict *target;
> +
> +    target = qtest_qmp_assert_success_ref(qts,
> +                                          "{ 'execute': 'query-target' }");
> +    g_assert_cmpstr(qdict_get_try_str(target, "arch"), ==, qtest_get_arch());
> +    qobject_unref(target);
> +    qtest_quit(qts);
> +}
> +
>  #ifndef _WIN32
> 
>  /* Out-of-band tests */
> @@ -517,6 +529,7 @@ int main(int argc, char *argv[])
>      g_test_init(&argc, &argv, NULL);
> 
>      qtest_add_func("qmp/protocol", test_qmp_protocol);
> +    qtest_add_func("qmp/query-target", test_query_target);
>  #ifndef _WIN32
>      /* This case calls mkfifo() which does not exist on win32 */
>      qtest_add_func("qmp/oob", test_qmp_oob);

I'll take it in addition to the series I sent. I'll also add a from
"you", since you posted this first. Thanks for your series, it really
helped us to move forward on this.

Regards,
Pierrick

Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 9:56 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
>
> For example on 10.1.0:
>
> $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
> /usr/bin/qemu-system-aarch64: "aarch64"
> /usr/bin/qemu-system-alpha: "alpha"
> /usr/bin/qemu-system-arm: "arm"
> /usr/bin/qemu-system-avr: "avr"
> /usr/bin/qemu-system-hppa: "hppa"
> /usr/bin/qemu-system-i386: "i386"
> /usr/bin/qemu-system-loongarch64: "loongarch64"
> /usr/bin/qemu-system-m68k: "m68k"
> /usr/bin/qemu-system-microblaze: "microblaze"
> /usr/bin/qemu-system-microblazeel: "microblazeel"
> /usr/bin/qemu-system-mips: "mips"
> /usr/bin/qemu-system-mips64: "mips64"
> /usr/bin/qemu-system-mips64el: "mips64el"
> /usr/bin/qemu-system-mipsel: "mipsel"
> /usr/bin/qemu-system-or1k: "or1k"
> /usr/bin/qemu-system-ppc: "ppc"
> /usr/bin/qemu-system-ppc64: "ppc64"
> /usr/bin/qemu-system-riscv32: "riscv32"
> /usr/bin/qemu-system-riscv64: "riscv64"
> /usr/bin/qemu-system-rx: "rx"
> /usr/bin/qemu-system-s390x: "s390x"
> /usr/bin/qemu-system-sh4: "sh4"
> /usr/bin/qemu-system-sh4eb: "sh4eb"
> /usr/bin/qemu-system-sparc: "sparc"
> /usr/bin/qemu-system-sparc64: "sparc64"
> /usr/bin/qemu-system-tricore: "tricore"
> /usr/bin/qemu-system-x86_64: "x86_64"
> /usr/bin/qemu-system-xtensa: "xtensa"
> /usr/bin/qemu-system-xtensaeb: "xtensaeb"
>
>
> but on git master:
>
> $ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
> ./build/qemu-system-hexagon: "hexagon"
> ./build/qemu-system-x86_64: "x86_64"
> ./build/qemu-system-s390x: "s390x"
> ./build/qemu-system-m68k: "m68k"
> ./build/qemu-system-xtensa: "xtensa"
> ./build/qemu-system-xtensaeb: "xtensa"
> ./build/qemu-system-rx: "rx"
> ./build/qemu-system-loongarch64: "loongarch64"
> ./build/qemu-system-riscv32: "riscv32"
> ./build/qemu-system-hppa: "hppa"
> ./build/qemu-system-ppc64: "ppc64"
> ./build/qemu-system-microblaze: "microblaze"
> ./build/qemu-system-sparc: "sparc"
> ./build/qemu-system-riscv64: "riscv64"
> ./build/qemu-system-i386: "i386"
> ./build/qemu-system-mipsel: "mips"
> ./build/qemu-system-sh4: "sh4"
> ./build/qemu-system-mips64el: "mips64"
> ./build/qemu-system-mips64: "mips64"
> ./build/qemu-system-sparc64: "sparc64"
> ./build/qemu-system-arm: "arm"
> ./build/qemu-system-tricore: "tricore"
> ./build/qemu-system-mips: "mips"
> ./build/qemu-system-or1k: "or1k"
> ./build/qemu-system-sh4eb: "sh4"
> ./build/qemu-system-aarch64: "aarch64"
> ./build/qemu-system-ppc: "ppc"
> ./build/qemu-system-avr: "avr"
> ./build/qemu-system-alpha: "alpha"
>
>
> so we need to fix that behaviour change for query-target.
>
> If we want to be able to expose only the "base" target,
> then query-target's  QemuTargetInfo struct could be
> extended with a 2nd field that presents the base.
>

Thanks a lot, this is a better way to describe the issue.

>
> With regards,
> Daniel
> --
> |: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
> |: https://libvirt.org          ~~          https://entangle-photo.org :|
> |: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/6/2026 6:56 AM, Daniel P. Berrangé wrote:
> On Mon, Oct 05, 2026 at 11:52:48AM -0700, Pierrick Bouvier wrote:
>> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
>>> On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>
>>>> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
>>>>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
>>>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>>>>>
>>>>>>>> Ok, but I'm not sure it answers the why.
>>>>>>>> Could you explain the benefits?
>>>>>>>
>>>>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
>>>>>>> The following original code would return -1 for some user-binary
>>>>>>> +    SysEmuTarget arch = target_info()->target_arch;
>>>>>>> +
>>>>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
>>>>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
>>>>>>> +                               &error_abort);
>>>>>>> +    }
>>>>>>> +    return arch;
>>>>>>> So basically assigning any value for the user binary is valid.
>>>>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
>>>>>>> -1 is another option but easy to confuse.
>>>>>>>
>>>>>>>
>>>>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
>>>>>>> "target-info: Statically initialize target_arch"
>>>>>>> doing that, I am not sure.
>>>>>>>
>>>>>>
>>>>>> I guess there is a (good or bad) reason for which sub variants of
>>>>>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
>>>>>> that before doing any change, as it might have other consequences.
>>>>>
>>>>>
>>>>> You’re right to ask, and I need to correct my earlier suggestion:
>>>>> leaving user-mode target_arch
>>>>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
>>>>> code shared with user-mode builds,
>>>>> including cpu-max-v8.c, where its result indexes a two-entry array.
>>>>> For aarch64-linux-user, the sentinel could therefore cause an
>>>>> out-of-bounds access during type registration.
>>>>>
>>>>> I checked the distinction: softmmu needs the full system-target
>>>>> identity, including variants such as mipsel;
>>>>> user-mode variants such as aarch64_be use their base TARGET_ARCH
>>>>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
>>>>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
>>>>> than leave the field at SYS_EMU_TARGET__MAX.
>>>>>
>>>>
>>>> That's technical details, but not an answer to the initial question of
>>>> why we need to change anything for user binaries, compared to what exists.
>>>
>>> The first two patches revert the current static initialization so the
>>> token can be replaced. They are not a user-mode behavior change.
>>>
>>> Compared with current QEMU, user-mode still uses TARGET_ARCH.
>>> qemu-mipsel already reports mips, and it still will. Names such as
>>> aarch64_be are not SysEmuTarget values, so user-mode cannot use the
>>> full target name for this field; keeping TARGET_ARCH preserves today's
>>> value and avoids the runtime parse.
>>>
>>
>> Why should we need to expose this precise information?
>> So far, if those targets were not exposed (and aliased to 32/64 bit
>> variant), it's probably we didn't need it.
> 
> Current git master is exhibiting a regression compared to previous
> releases.
> 
> For example on 10.1.0:
> 
> $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
> /usr/bin/qemu-system-aarch64: "aarch64"
> /usr/bin/qemu-system-alpha: "alpha"
> /usr/bin/qemu-system-arm: "arm"
> /usr/bin/qemu-system-avr: "avr"
> /usr/bin/qemu-system-hppa: "hppa"
> /usr/bin/qemu-system-i386: "i386"
> /usr/bin/qemu-system-loongarch64: "loongarch64"
> /usr/bin/qemu-system-m68k: "m68k"
> /usr/bin/qemu-system-microblaze: "microblaze"
> /usr/bin/qemu-system-microblazeel: "microblazeel"
> /usr/bin/qemu-system-mips: "mips"
> /usr/bin/qemu-system-mips64: "mips64"
> /usr/bin/qemu-system-mips64el: "mips64el"
> /usr/bin/qemu-system-mipsel: "mipsel"
> /usr/bin/qemu-system-or1k: "or1k"
> /usr/bin/qemu-system-ppc: "ppc"
> /usr/bin/qemu-system-ppc64: "ppc64"
> /usr/bin/qemu-system-riscv32: "riscv32"
> /usr/bin/qemu-system-riscv64: "riscv64"
> /usr/bin/qemu-system-rx: "rx"
> /usr/bin/qemu-system-s390x: "s390x"
> /usr/bin/qemu-system-sh4: "sh4"
> /usr/bin/qemu-system-sh4eb: "sh4eb"
> /usr/bin/qemu-system-sparc: "sparc"
> /usr/bin/qemu-system-sparc64: "sparc64"
> /usr/bin/qemu-system-tricore: "tricore"
> /usr/bin/qemu-system-x86_64: "x86_64"
> /usr/bin/qemu-system-xtensa: "xtensa"
> /usr/bin/qemu-system-xtensaeb: "xtensaeb"
> 
> 
> but on git master:
> 
> $ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
> ./build/qemu-system-hexagon: "hexagon"
> ./build/qemu-system-x86_64: "x86_64"
> ./build/qemu-system-s390x: "s390x"
> ./build/qemu-system-m68k: "m68k"
> ./build/qemu-system-xtensa: "xtensa"
> ./build/qemu-system-xtensaeb: "xtensa"
> ./build/qemu-system-rx: "rx"
> ./build/qemu-system-loongarch64: "loongarch64"
> ./build/qemu-system-riscv32: "riscv32"
> ./build/qemu-system-hppa: "hppa"
> ./build/qemu-system-ppc64: "ppc64"
> ./build/qemu-system-microblaze: "microblaze"
> ./build/qemu-system-sparc: "sparc"
> ./build/qemu-system-riscv64: "riscv64"
> ./build/qemu-system-i386: "i386"
> ./build/qemu-system-mipsel: "mips"
> ./build/qemu-system-sh4: "sh4"
> ./build/qemu-system-mips64el: "mips64"
> ./build/qemu-system-mips64: "mips64"
> ./build/qemu-system-sparc64: "sparc64"
> ./build/qemu-system-arm: "arm"
> ./build/qemu-system-tricore: "tricore"
> ./build/qemu-system-mips: "mips"
> ./build/qemu-system-or1k: "or1k"
> ./build/qemu-system-sh4eb: "sh4"
> ./build/qemu-system-aarch64: "aarch64"
> ./build/qemu-system-ppc: "ppc"
> ./build/qemu-system-avr: "avr"
> ./build/qemu-system-alpha: "alpha"
> 
> 
> so we need to fix that behaviour change for query-target.
> 
> If we want to be able to expose only the "base" target,
> then query-target's  QemuTargetInfo struct could be
> extended with a 2nd field that presents the base.
> 
> 
> With regards,
> Daniel

Thanks for finding this Daniel.
SYS_EMU_TARGET already has the correct variants, the regression was to
use TARGET_ARCH instead of TARGET_NAME in target-info-stub.c.

I think Richard used this one just because TARGET_NAME is a string, so
it can't be concatenated with C preprocessor.

I'll fix that part.

Regards,
Pierrick

Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/6/2026 10:31 AM, Pierrick Bouvier wrote:
> On 10/6/2026 6:56 AM, Daniel P. Berrangé wrote:
>> On Mon, Oct 05, 2026 at 11:52:48AM -0700, Pierrick Bouvier wrote:
>>> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
>>>> On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
>>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>>
>>>>> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
>>>>>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
>>>>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>>>>>>
>>>>>>>>> Ok, but I'm not sure it answers the why.
>>>>>>>>> Could you explain the benefits?
>>>>>>>>
>>>>>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
>>>>>>>> The following original code would return -1 for some user-binary
>>>>>>>> +    SysEmuTarget arch = target_info()->target_arch;
>>>>>>>> +
>>>>>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
>>>>>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
>>>>>>>> +                               &error_abort);
>>>>>>>> +    }
>>>>>>>> +    return arch;
>>>>>>>> So basically assigning any value for the user binary is valid.
>>>>>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
>>>>>>>> -1 is another option but easy to confuse.
>>>>>>>>
>>>>>>>>
>>>>>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
>>>>>>>> "target-info: Statically initialize target_arch"
>>>>>>>> doing that, I am not sure.
>>>>>>>>
>>>>>>>
>>>>>>> I guess there is a (good or bad) reason for which sub variants of
>>>>>>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
>>>>>>> that before doing any change, as it might have other consequences.
>>>>>>
>>>>>>
>>>>>> You’re right to ask, and I need to correct my earlier suggestion:
>>>>>> leaving user-mode target_arch
>>>>>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
>>>>>> code shared with user-mode builds,
>>>>>> including cpu-max-v8.c, where its result indexes a two-entry array.
>>>>>> For aarch64-linux-user, the sentinel could therefore cause an
>>>>>> out-of-bounds access during type registration.
>>>>>>
>>>>>> I checked the distinction: softmmu needs the full system-target
>>>>>> identity, including variants such as mipsel;
>>>>>> user-mode variants such as aarch64_be use their base TARGET_ARCH
>>>>>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
>>>>>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
>>>>>> than leave the field at SYS_EMU_TARGET__MAX.
>>>>>>
>>>>>
>>>>> That's technical details, but not an answer to the initial question of
>>>>> why we need to change anything for user binaries, compared to what exists.
>>>>
>>>> The first two patches revert the current static initialization so the
>>>> token can be replaced. They are not a user-mode behavior change.
>>>>
>>>> Compared with current QEMU, user-mode still uses TARGET_ARCH.
>>>> qemu-mipsel already reports mips, and it still will. Names such as
>>>> aarch64_be are not SysEmuTarget values, so user-mode cannot use the
>>>> full target name for this field; keeping TARGET_ARCH preserves today's
>>>> value and avoids the runtime parse.
>>>>
>>>
>>> Why should we need to expose this precise information?
>>> So far, if those targets were not exposed (and aliased to 32/64 bit
>>> variant), it's probably we didn't need it.
>>
>> Current git master is exhibiting a regression compared to previous
>> releases.
>>
>> For example on 10.1.0:
>>
>> $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
>> /usr/bin/qemu-system-aarch64: "aarch64"
>> /usr/bin/qemu-system-alpha: "alpha"
>> /usr/bin/qemu-system-arm: "arm"
>> /usr/bin/qemu-system-avr: "avr"
>> /usr/bin/qemu-system-hppa: "hppa"
>> /usr/bin/qemu-system-i386: "i386"
>> /usr/bin/qemu-system-loongarch64: "loongarch64"
>> /usr/bin/qemu-system-m68k: "m68k"
>> /usr/bin/qemu-system-microblaze: "microblaze"
>> /usr/bin/qemu-system-microblazeel: "microblazeel"
>> /usr/bin/qemu-system-mips: "mips"
>> /usr/bin/qemu-system-mips64: "mips64"
>> /usr/bin/qemu-system-mips64el: "mips64el"
>> /usr/bin/qemu-system-mipsel: "mipsel"
>> /usr/bin/qemu-system-or1k: "or1k"
>> /usr/bin/qemu-system-ppc: "ppc"
>> /usr/bin/qemu-system-ppc64: "ppc64"
>> /usr/bin/qemu-system-riscv32: "riscv32"
>> /usr/bin/qemu-system-riscv64: "riscv64"
>> /usr/bin/qemu-system-rx: "rx"
>> /usr/bin/qemu-system-s390x: "s390x"
>> /usr/bin/qemu-system-sh4: "sh4"
>> /usr/bin/qemu-system-sh4eb: "sh4eb"
>> /usr/bin/qemu-system-sparc: "sparc"
>> /usr/bin/qemu-system-sparc64: "sparc64"
>> /usr/bin/qemu-system-tricore: "tricore"
>> /usr/bin/qemu-system-x86_64: "x86_64"
>> /usr/bin/qemu-system-xtensa: "xtensa"
>> /usr/bin/qemu-system-xtensaeb: "xtensaeb"
>>
>>
>> but on git master:
>>
>> $ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n "$i: " ; echo -e '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ; done
>> ./build/qemu-system-hexagon: "hexagon"
>> ./build/qemu-system-x86_64: "x86_64"
>> ./build/qemu-system-s390x: "s390x"
>> ./build/qemu-system-m68k: "m68k"
>> ./build/qemu-system-xtensa: "xtensa"
>> ./build/qemu-system-xtensaeb: "xtensa"
>> ./build/qemu-system-rx: "rx"
>> ./build/qemu-system-loongarch64: "loongarch64"
>> ./build/qemu-system-riscv32: "riscv32"
>> ./build/qemu-system-hppa: "hppa"
>> ./build/qemu-system-ppc64: "ppc64"
>> ./build/qemu-system-microblaze: "microblaze"
>> ./build/qemu-system-sparc: "sparc"
>> ./build/qemu-system-riscv64: "riscv64"
>> ./build/qemu-system-i386: "i386"
>> ./build/qemu-system-mipsel: "mips"
>> ./build/qemu-system-sh4: "sh4"
>> ./build/qemu-system-mips64el: "mips64"
>> ./build/qemu-system-mips64: "mips64"
>> ./build/qemu-system-sparc64: "sparc64"
>> ./build/qemu-system-arm: "arm"
>> ./build/qemu-system-tricore: "tricore"
>> ./build/qemu-system-mips: "mips"
>> ./build/qemu-system-or1k: "or1k"
>> ./build/qemu-system-sh4eb: "sh4"
>> ./build/qemu-system-aarch64: "aarch64"
>> ./build/qemu-system-ppc: "ppc"
>> ./build/qemu-system-avr: "avr"
>> ./build/qemu-system-alpha: "alpha"
>>
>>
>> so we need to fix that behaviour change for query-target.
>>
>> If we want to be able to expose only the "base" target,
>> then query-target's  QemuTargetInfo struct could be
>> extended with a 2nd field that presents the base.
>>
>>
>> With regards,
>> Daniel
> 
> Thanks for finding this Daniel.
> SYS_EMU_TARGET already has the correct variants, the regression was to
> use TARGET_ARCH instead of TARGET_NAME in target-info-stub.c.
> 
> I think Richard used this one just because TARGET_NAME is a string, so
> it can't be concatenated with C preprocessor.
> 
> I'll fix that part.
>

Please take a look to the following series that solves this regression,
and also allows to detect endianness variants through target_arch():

20261006182558.151956-1-pierrick.bouvier@oss.qualcomm.com
"[PATCH 0/2] target-info: expose full target variant"

Regards,
Pierrick

Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
where I do not see it


         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> 于 2026年10月7日周三 02:30写道:

> On 10/6/2026 10:31 AM, Pierrick Bouvier wrote:
> > On 10/6/2026 6:56 AM, Daniel P. Berrangé wrote:
> >> On Mon, Oct 05, 2026 at 11:52:48AM -0700, Pierrick Bouvier wrote:
> >>> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
> >>>> On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
> >>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>>
> >>>>> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
> >>>>>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
> >>>>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>>>>>>
> >>>>>>>>> Ok, but I'm not sure it answers the why.
> >>>>>>>>> Could you explain the benefits?
> >>>>>>>>
> >>>>>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for
> user-binary because
> >>>>>>>> The following original code would return -1 for some user-binary
> >>>>>>>> +    SysEmuTarget arch = target_info()->target_arch;
> >>>>>>>> +
> >>>>>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
> >>>>>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup,
> target_name(), -1,
> >>>>>>>> +                               &error_abort);
> >>>>>>>> +    }
> >>>>>>>> +    return arch;
> >>>>>>>> So basically assigning any value for the user binary is valid.
> >>>>>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type
> SysEmuTarget.
> >>>>>>>> -1 is another option but easy to confuse.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> >>>>>>>> "target-info: Statically initialize target_arch"
> >>>>>>>> doing that, I am not sure.
> >>>>>>>>
> >>>>>>>
> >>>>>>> I guess there is a (good or bad) reason for which sub variants of
> >>>>>>> targets are not reflected in SYS_EMU_TARGET enum. We should double
> check
> >>>>>>> that before doing any change, as it might have other consequences.
> >>>>>>
> >>>>>>
> >>>>>> You’re right to ask, and I need to correct my earlier suggestion:
> >>>>>> leaving user-mode target_arch
> >>>>>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
> >>>>>> code shared with user-mode builds,
> >>>>>> including cpu-max-v8.c, where its result indexes a two-entry array.
> >>>>>> For aarch64-linux-user, the sentinel could therefore cause an
> >>>>>> out-of-bounds access during type registration.
> >>>>>>
> >>>>>> I checked the distinction: softmmu needs the full system-target
> >>>>>> identity, including variants such as mipsel;
> >>>>>> user-mode variants such as aarch64_be use their base TARGET_ARCH
> >>>>>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
> >>>>>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
> >>>>>> than leave the field at SYS_EMU_TARGET__MAX.
> >>>>>>
> >>>>>
> >>>>> That's technical details, but not an answer to the initial question
> of
> >>>>> why we need to change anything for user binaries, compared to what
> exists.
> >>>>
> >>>> The first two patches revert the current static initialization so the
> >>>> token can be replaced. They are not a user-mode behavior change.
> >>>>
> >>>> Compared with current QEMU, user-mode still uses TARGET_ARCH.
> >>>> qemu-mipsel already reports mips, and it still will. Names such as
> >>>> aarch64_be are not SysEmuTarget values, so user-mode cannot use the
> >>>> full target name for this field; keeping TARGET_ARCH preserves today's
> >>>> value and avoids the runtime parse.
> >>>>
> >>>
> >>> Why should we need to expose this precise information?
> >>> So far, if those targets were not exposed (and aliased to 32/64 bit
> >>> variant), it's probably we didn't need it.
> >>
> >> Current git master is exhibiting a regression compared to previous
> >> releases.
> >>
> >> For example on 10.1.0:
> >>
> >> $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e
> '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n'
> | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ;
> done
> >> /usr/bin/qemu-system-aarch64: "aarch64"
> >> /usr/bin/qemu-system-alpha: "alpha"
> >> /usr/bin/qemu-system-arm: "arm"
> >> /usr/bin/qemu-system-avr: "avr"
> >> /usr/bin/qemu-system-hppa: "hppa"
> >> /usr/bin/qemu-system-i386: "i386"
> >> /usr/bin/qemu-system-loongarch64: "loongarch64"
> >> /usr/bin/qemu-system-m68k: "m68k"
> >> /usr/bin/qemu-system-microblaze: "microblaze"
> >> /usr/bin/qemu-system-microblazeel: "microblazeel"
> >> /usr/bin/qemu-system-mips: "mips"
> >> /usr/bin/qemu-system-mips64: "mips64"
> >> /usr/bin/qemu-system-mips64el: "mips64el"
> >> /usr/bin/qemu-system-mipsel: "mipsel"
> >> /usr/bin/qemu-system-or1k: "or1k"
> >> /usr/bin/qemu-system-ppc: "ppc"
> >> /usr/bin/qemu-system-ppc64: "ppc64"
> >> /usr/bin/qemu-system-riscv32: "riscv32"
> >> /usr/bin/qemu-system-riscv64: "riscv64"
> >> /usr/bin/qemu-system-rx: "rx"
> >> /usr/bin/qemu-system-s390x: "s390x"
> >> /usr/bin/qemu-system-sh4: "sh4"
> >> /usr/bin/qemu-system-sh4eb: "sh4eb"
> >> /usr/bin/qemu-system-sparc: "sparc"
> >> /usr/bin/qemu-system-sparc64: "sparc64"
> >> /usr/bin/qemu-system-tricore: "tricore"
> >> /usr/bin/qemu-system-x86_64: "x86_64"
> >> /usr/bin/qemu-system-xtensa: "xtensa"
> >> /usr/bin/qemu-system-xtensaeb: "xtensaeb"
> >>
> >>
> >> but on git master:
> >>
> >> $ for i in $(find ./build -type f -name 'qemu-system-*') ; do echo -n
> "$i: " ; echo -e
> '{"execute":"qmp_capabilities"}\r\n{"execute":"query-target"}\r\n{"execute":"quit"}\r\n'
> | $i -qmp stdio -display none -M none | jq .return.arch | grep -v null ;
> done
> >> ./build/qemu-system-hexagon: "hexagon"
> >> ./build/qemu-system-x86_64: "x86_64"
> >> ./build/qemu-system-s390x: "s390x"
> >> ./build/qemu-system-m68k: "m68k"
> >> ./build/qemu-system-xtensa: "xtensa"
> >> ./build/qemu-system-xtensaeb: "xtensa"
> >> ./build/qemu-system-rx: "rx"
> >> ./build/qemu-system-loongarch64: "loongarch64"
> >> ./build/qemu-system-riscv32: "riscv32"
> >> ./build/qemu-system-hppa: "hppa"
> >> ./build/qemu-system-ppc64: "ppc64"
> >> ./build/qemu-system-microblaze: "microblaze"
> >> ./build/qemu-system-sparc: "sparc"
> >> ./build/qemu-system-riscv64: "riscv64"
> >> ./build/qemu-system-i386: "i386"
> >> ./build/qemu-system-mipsel: "mips"
> >> ./build/qemu-system-sh4: "sh4"
> >> ./build/qemu-system-mips64el: "mips64"
> >> ./build/qemu-system-mips64: "mips64"
> >> ./build/qemu-system-sparc64: "sparc64"
> >> ./build/qemu-system-arm: "arm"
> >> ./build/qemu-system-tricore: "tricore"
> >> ./build/qemu-system-mips: "mips"
> >> ./build/qemu-system-or1k: "or1k"
> >> ./build/qemu-system-sh4eb: "sh4"
> >> ./build/qemu-system-aarch64: "aarch64"
> >> ./build/qemu-system-ppc: "ppc"
> >> ./build/qemu-system-avr: "avr"
> >> ./build/qemu-system-alpha: "alpha"
> >>
> >>
> >> so we need to fix that behaviour change for query-target.
> >>
> >> If we want to be able to expose only the "base" target,
> >> then query-target's  QemuTargetInfo struct could be
> >> extended with a 2nd field that presents the base.
> >>
> >>
> >> With regards,
> >> Daniel
> >
> > Thanks for finding this Daniel.
> > SYS_EMU_TARGET already has the correct variants, the regression was to
> > use TARGET_ARCH instead of TARGET_NAME in target-info-stub.c.
> >
> > I think Richard used this one just because TARGET_NAME is a string, so
> > it can't be concatenated with C preprocessor.
> >
> > I'll fix that part.
> >
>
> Please take a look to the following series that solves this regression,
> and also allows to detect endianness variants through target_arch():
>
> 20261006182558.151956-1-pierrick.bouvier@oss.qualcomm.com
> "[PATCH 0/2] target-info: expose full target variant"
>
> Regards,
> Pierrick
>
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/6/2026 11:46 AM, Yonggang Luo wrote:
> where I do not see it
>

I wonder if list is down, I don't see any new thread on it...

> 
>          此致
> 礼
> 罗勇刚
> Yours
>     sincerely,
> Yonggang Luo
> 
> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com
> <mailto:pierrick.bouvier@oss.qualcomm.com>> 于 2026年10月7日周三 02:30写道:
> 
>     On 10/6/2026 10:31 AM, Pierrick Bouvier wrote:
>     > On 10/6/2026 6:56 AM, Daniel P. Berrangé wrote:
>     >> On Mon, Oct 05, 2026 at 11:52:48AM -0700, Pierrick Bouvier wrote:
>     >>> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
>     >>>> On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
>     >>>> <pierrick.bouvier@oss.qualcomm.com
>     <mailto:pierrick.bouvier@oss.qualcomm.com>> wrote:
>     >>>>>
>     >>>>> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
>     >>>>>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
>     >>>>>> <pierrick.bouvier@oss.qualcomm.com
>     <mailto:pierrick.bouvier@oss.qualcomm.com>> wrote:
>     >>>>>>>>>
>     >>>>>>>>> Ok, but I'm not sure it answers the why.
>     >>>>>>>>> Could you explain the benefits?
>     >>>>>>>>
>     >>>>>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for
>     user-binary because
>     >>>>>>>> The following original code would return -1 for some user-
>     binary
>     >>>>>>>> +    SysEmuTarget arch = target_info()->target_arch;
>     >>>>>>>> +
>     >>>>>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
>     >>>>>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup,
>     target_name(), -1,
>     >>>>>>>> +                               &error_abort);
>     >>>>>>>> +    }
>     >>>>>>>> +    return arch;
>     >>>>>>>> So basically assigning any value for the user binary is valid.
>     >>>>>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to
>     type SysEmuTarget.
>     >>>>>>>> -1 is another option but easy to confuse.
>     >>>>>>>>
>     >>>>>>>>
>     >>>>>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
>     >>>>>>>> "target-info: Statically initialize target_arch"
>     >>>>>>>> doing that, I am not sure.
>     >>>>>>>>
>     >>>>>>>
>     >>>>>>> I guess there is a (good or bad) reason for which sub
>     variants of
>     >>>>>>> targets are not reflected in SYS_EMU_TARGET enum. We should
>     double check
>     >>>>>>> that before doing any change, as it might have other
>     consequences.
>     >>>>>>
>     >>>>>>
>     >>>>>> You’re right to ask, and I need to correct my earlier suggestion:
>     >>>>>> leaving user-mode target_arch
>     >>>>>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used
>     by ARM
>     >>>>>> code shared with user-mode builds,
>     >>>>>> including cpu-max-v8.c, where its result indexes a two-entry
>     array.
>     >>>>>> For aarch64-linux-user, the sentinel could therefore cause an
>     >>>>>> out-of-bounds access during type registration.
>     >>>>>>
>     >>>>>> I checked the distinction: softmmu needs the full system-target
>     >>>>>> identity, including variants such as mipsel;
>     >>>>>> user-mode variants such as aarch64_be use their base TARGET_ARCH
>     >>>>>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
>     >>>>>>  value for softmmu and use TARGET_ARCH for user-mode builds,
>     rather
>     >>>>>> than leave the field at SYS_EMU_TARGET__MAX.
>     >>>>>>
>     >>>>>
>     >>>>> That's technical details, but not an answer to the initial
>     question of
>     >>>>> why we need to change anything for user binaries, compared to
>     what exists.
>     >>>>
>     >>>> The first two patches revert the current static initialization
>     so the
>     >>>> token can be replaced. They are not a user-mode behavior change.
>     >>>>
>     >>>> Compared with current QEMU, user-mode still uses TARGET_ARCH.
>     >>>> qemu-mipsel already reports mips, and it still will. Names such as
>     >>>> aarch64_be are not SysEmuTarget values, so user-mode cannot use the
>     >>>> full target name for this field; keeping TARGET_ARCH preserves
>     today's
>     >>>> value and avoids the runtime parse.
>     >>>>
>     >>>
>     >>> Why should we need to expose this precise information?
>     >>> So far, if those targets were not exposed (and aliased to 32/64 bit
>     >>> variant), it's probably we didn't need it.
>     >>
>     >> Current git master is exhibiting a regression compared to previous
>     >> releases.
>     >>
>     >> For example on 10.1.0:
>     >>
>     >> $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e
>     '{"execute":"qmp_capabilities"}\r\n{"execute":"query-
>     target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M
>     none | jq .return.arch | grep -v null ; done
>     >> /usr/bin/qemu-system-aarch64: "aarch64"
>     >> /usr/bin/qemu-system-alpha: "alpha"
>     >> /usr/bin/qemu-system-arm: "arm"
>     >> /usr/bin/qemu-system-avr: "avr"
>     >> /usr/bin/qemu-system-hppa: "hppa"
>     >> /usr/bin/qemu-system-i386: "i386"
>     >> /usr/bin/qemu-system-loongarch64: "loongarch64"
>     >> /usr/bin/qemu-system-m68k: "m68k"
>     >> /usr/bin/qemu-system-microblaze: "microblaze"
>     >> /usr/bin/qemu-system-microblazeel: "microblazeel"
>     >> /usr/bin/qemu-system-mips: "mips"
>     >> /usr/bin/qemu-system-mips64: "mips64"
>     >> /usr/bin/qemu-system-mips64el: "mips64el"
>     >> /usr/bin/qemu-system-mipsel: "mipsel"
>     >> /usr/bin/qemu-system-or1k: "or1k"
>     >> /usr/bin/qemu-system-ppc: "ppc"
>     >> /usr/bin/qemu-system-ppc64: "ppc64"
>     >> /usr/bin/qemu-system-riscv32: "riscv32"
>     >> /usr/bin/qemu-system-riscv64: "riscv64"
>     >> /usr/bin/qemu-system-rx: "rx"
>     >> /usr/bin/qemu-system-s390x: "s390x"
>     >> /usr/bin/qemu-system-sh4: "sh4"
>     >> /usr/bin/qemu-system-sh4eb: "sh4eb"
>     >> /usr/bin/qemu-system-sparc: "sparc"
>     >> /usr/bin/qemu-system-sparc64: "sparc64"
>     >> /usr/bin/qemu-system-tricore: "tricore"
>     >> /usr/bin/qemu-system-x86_64: "x86_64"
>     >> /usr/bin/qemu-system-xtensa: "xtensa"
>     >> /usr/bin/qemu-system-xtensaeb: "xtensaeb"
>     >>
>     >>
>     >> but on git master:
>     >>
>     >> $ for i in $(find ./build -type f -name 'qemu-system-*') ; do
>     echo -n "$i: " ; echo -e
>     '{"execute":"qmp_capabilities"}\r\n{"execute":"query-
>     target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M
>     none | jq .return.arch | grep -v null ; done
>     >> ./build/qemu-system-hexagon: "hexagon"
>     >> ./build/qemu-system-x86_64: "x86_64"
>     >> ./build/qemu-system-s390x: "s390x"
>     >> ./build/qemu-system-m68k: "m68k"
>     >> ./build/qemu-system-xtensa: "xtensa"
>     >> ./build/qemu-system-xtensaeb: "xtensa"
>     >> ./build/qemu-system-rx: "rx"
>     >> ./build/qemu-system-loongarch64: "loongarch64"
>     >> ./build/qemu-system-riscv32: "riscv32"
>     >> ./build/qemu-system-hppa: "hppa"
>     >> ./build/qemu-system-ppc64: "ppc64"
>     >> ./build/qemu-system-microblaze: "microblaze"
>     >> ./build/qemu-system-sparc: "sparc"
>     >> ./build/qemu-system-riscv64: "riscv64"
>     >> ./build/qemu-system-i386: "i386"
>     >> ./build/qemu-system-mipsel: "mips"
>     >> ./build/qemu-system-sh4: "sh4"
>     >> ./build/qemu-system-mips64el: "mips64"
>     >> ./build/qemu-system-mips64: "mips64"
>     >> ./build/qemu-system-sparc64: "sparc64"
>     >> ./build/qemu-system-arm: "arm"
>     >> ./build/qemu-system-tricore: "tricore"
>     >> ./build/qemu-system-mips: "mips"
>     >> ./build/qemu-system-or1k: "or1k"
>     >> ./build/qemu-system-sh4eb: "sh4"
>     >> ./build/qemu-system-aarch64: "aarch64"
>     >> ./build/qemu-system-ppc: "ppc"
>     >> ./build/qemu-system-avr: "avr"
>     >> ./build/qemu-system-alpha: "alpha"
>     >>
>     >>
>     >> so we need to fix that behaviour change for query-target.
>     >>
>     >> If we want to be able to expose only the "base" target,
>     >> then query-target's  QemuTargetInfo struct could be
>     >> extended with a 2nd field that presents the base.
>     >>
>     >>
>     >> With regards,
>     >> Daniel
>     >
>     > Thanks for finding this Daniel.
>     > SYS_EMU_TARGET already has the correct variants, the regression was to
>     > use TARGET_ARCH instead of TARGET_NAME in target-info-stub.c.
>     >
>     > I think Richard used this one just because TARGET_NAME is a string, so
>     > it can't be concatenated with C preprocessor.
>     >
>     > I'll fix that part.
>     >
> 
>     Please take a look to the following series that solves this regression,
>     and also allows to detect endianness variants through target_arch():
> 
>     20261006182558.151956-1-pierrick.bouvier@oss.qualcomm.com
>     <mailto:20261006182558.151956-1-pierrick.bouvier@oss.qualcomm.com>
>     "[PATCH 0/2] target-info: expose full target variant"
> 
>     Regards,
>     Pierrick
> 


Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/6/2026 12:32 PM, Pierrick Bouvier wrote:
> On 10/6/2026 11:46 AM, Yonggang Luo wrote:
>> where I do not see it
>>
> 
> I wonder if list is down, I don't see any new thread on it...
>

It seems to be down for now.

   ----- Transcript of session follows -----
<qemu-devel@nongnu.org>... Deferred: eggs.gnu.org.: No route to host
Warning: message still undelivered after 4 hours
Will keep trying until message is 5 days old

I'll wait and resend the series when it's back.

>>
>>          此致
>> 礼
>> 罗勇刚
>> Yours
>>     sincerely,
>> Yonggang Luo
>>
>> Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com
>> <mailto:pierrick.bouvier@oss.qualcomm.com>> 于 2026年10月7日周三 02:30写道:
>>
>>     On 10/6/2026 10:31 AM, Pierrick Bouvier wrote:
>>     > On 10/6/2026 6:56 AM, Daniel P. Berrangé wrote:
>>     >> On Mon, Oct 05, 2026 at 11:52:48AM -0700, Pierrick Bouvier wrote:
>>     >>> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
>>     >>>> On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
>>     >>>> <pierrick.bouvier@oss.qualcomm.com
>>     <mailto:pierrick.bouvier@oss.qualcomm.com>> wrote:
>>     >>>>>
>>     >>>>> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
>>     >>>>>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
>>     >>>>>> <pierrick.bouvier@oss.qualcomm.com
>>     <mailto:pierrick.bouvier@oss.qualcomm.com>> wrote:
>>     >>>>>>>>>
>>     >>>>>>>>> Ok, but I'm not sure it answers the why.
>>     >>>>>>>>> Could you explain the benefits?
>>     >>>>>>>>
>>     >>>>>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for
>>     user-binary because
>>     >>>>>>>> The following original code would return -1 for some user-
>>     binary
>>     >>>>>>>> +    SysEmuTarget arch = target_info()->target_arch;
>>     >>>>>>>> +
>>     >>>>>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
>>     >>>>>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup,
>>     target_name(), -1,
>>     >>>>>>>> +                               &error_abort);
>>     >>>>>>>> +    }
>>     >>>>>>>> +    return arch;
>>     >>>>>>>> So basically assigning any value for the user binary is valid.
>>     >>>>>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to
>>     type SysEmuTarget.
>>     >>>>>>>> -1 is another option but easy to confuse.
>>     >>>>>>>>
>>     >>>>>>>>
>>     >>>>>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
>>     >>>>>>>> "target-info: Statically initialize target_arch"
>>     >>>>>>>> doing that, I am not sure.
>>     >>>>>>>>
>>     >>>>>>>
>>     >>>>>>> I guess there is a (good or bad) reason for which sub
>>     variants of
>>     >>>>>>> targets are not reflected in SYS_EMU_TARGET enum. We should
>>     double check
>>     >>>>>>> that before doing any change, as it might have other
>>     consequences.
>>     >>>>>>
>>     >>>>>>
>>     >>>>>> You’re right to ask, and I need to correct my earlier suggestion:
>>     >>>>>> leaving user-mode target_arch
>>     >>>>>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used
>>     by ARM
>>     >>>>>> code shared with user-mode builds,
>>     >>>>>> including cpu-max-v8.c, where its result indexes a two-entry
>>     array.
>>     >>>>>> For aarch64-linux-user, the sentinel could therefore cause an
>>     >>>>>> out-of-bounds access during type registration.
>>     >>>>>>
>>     >>>>>> I checked the distinction: softmmu needs the full system-target
>>     >>>>>> identity, including variants such as mipsel;
>>     >>>>>> user-mode variants such as aarch64_be use their base TARGET_ARCH
>>     >>>>>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
>>     >>>>>>  value for softmmu and use TARGET_ARCH for user-mode builds,
>>     rather
>>     >>>>>> than leave the field at SYS_EMU_TARGET__MAX.
>>     >>>>>>
>>     >>>>>
>>     >>>>> That's technical details, but not an answer to the initial
>>     question of
>>     >>>>> why we need to change anything for user binaries, compared to
>>     what exists.
>>     >>>>
>>     >>>> The first two patches revert the current static initialization
>>     so the
>>     >>>> token can be replaced. They are not a user-mode behavior change.
>>     >>>>
>>     >>>> Compared with current QEMU, user-mode still uses TARGET_ARCH.
>>     >>>> qemu-mipsel already reports mips, and it still will. Names such as
>>     >>>> aarch64_be are not SysEmuTarget values, so user-mode cannot use the
>>     >>>> full target name for this field; keeping TARGET_ARCH preserves
>>     today's
>>     >>>> value and avoids the runtime parse.
>>     >>>>
>>     >>>
>>     >>> Why should we need to expose this precise information?
>>     >>> So far, if those targets were not exposed (and aliased to 32/64 bit
>>     >>> variant), it's probably we didn't need it.
>>     >>
>>     >> Current git master is exhibiting a regression compared to previous
>>     >> releases.
>>     >>
>>     >> For example on 10.1.0:
>>     >>
>>     >> $ for i in /usr/bin/qemu-system-* ; do echo -n "$i: " ; echo -e
>>     '{"execute":"qmp_capabilities"}\r\n{"execute":"query-
>>     target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M
>>     none | jq .return.arch | grep -v null ; done
>>     >> /usr/bin/qemu-system-aarch64: "aarch64"
>>     >> /usr/bin/qemu-system-alpha: "alpha"
>>     >> /usr/bin/qemu-system-arm: "arm"
>>     >> /usr/bin/qemu-system-avr: "avr"
>>     >> /usr/bin/qemu-system-hppa: "hppa"
>>     >> /usr/bin/qemu-system-i386: "i386"
>>     >> /usr/bin/qemu-system-loongarch64: "loongarch64"
>>     >> /usr/bin/qemu-system-m68k: "m68k"
>>     >> /usr/bin/qemu-system-microblaze: "microblaze"
>>     >> /usr/bin/qemu-system-microblazeel: "microblazeel"
>>     >> /usr/bin/qemu-system-mips: "mips"
>>     >> /usr/bin/qemu-system-mips64: "mips64"
>>     >> /usr/bin/qemu-system-mips64el: "mips64el"
>>     >> /usr/bin/qemu-system-mipsel: "mipsel"
>>     >> /usr/bin/qemu-system-or1k: "or1k"
>>     >> /usr/bin/qemu-system-ppc: "ppc"
>>     >> /usr/bin/qemu-system-ppc64: "ppc64"
>>     >> /usr/bin/qemu-system-riscv32: "riscv32"
>>     >> /usr/bin/qemu-system-riscv64: "riscv64"
>>     >> /usr/bin/qemu-system-rx: "rx"
>>     >> /usr/bin/qemu-system-s390x: "s390x"
>>     >> /usr/bin/qemu-system-sh4: "sh4"
>>     >> /usr/bin/qemu-system-sh4eb: "sh4eb"
>>     >> /usr/bin/qemu-system-sparc: "sparc"
>>     >> /usr/bin/qemu-system-sparc64: "sparc64"
>>     >> /usr/bin/qemu-system-tricore: "tricore"
>>     >> /usr/bin/qemu-system-x86_64: "x86_64"
>>     >> /usr/bin/qemu-system-xtensa: "xtensa"
>>     >> /usr/bin/qemu-system-xtensaeb: "xtensaeb"
>>     >>
>>     >>
>>     >> but on git master:
>>     >>
>>     >> $ for i in $(find ./build -type f -name 'qemu-system-*') ; do
>>     echo -n "$i: " ; echo -e
>>     '{"execute":"qmp_capabilities"}\r\n{"execute":"query-
>>     target"}\r\n{"execute":"quit"}\r\n' | $i -qmp stdio -display none -M
>>     none | jq .return.arch | grep -v null ; done
>>     >> ./build/qemu-system-hexagon: "hexagon"
>>     >> ./build/qemu-system-x86_64: "x86_64"
>>     >> ./build/qemu-system-s390x: "s390x"
>>     >> ./build/qemu-system-m68k: "m68k"
>>     >> ./build/qemu-system-xtensa: "xtensa"
>>     >> ./build/qemu-system-xtensaeb: "xtensa"
>>     >> ./build/qemu-system-rx: "rx"
>>     >> ./build/qemu-system-loongarch64: "loongarch64"
>>     >> ./build/qemu-system-riscv32: "riscv32"
>>     >> ./build/qemu-system-hppa: "hppa"
>>     >> ./build/qemu-system-ppc64: "ppc64"
>>     >> ./build/qemu-system-microblaze: "microblaze"
>>     >> ./build/qemu-system-sparc: "sparc"
>>     >> ./build/qemu-system-riscv64: "riscv64"
>>     >> ./build/qemu-system-i386: "i386"
>>     >> ./build/qemu-system-mipsel: "mips"
>>     >> ./build/qemu-system-sh4: "sh4"
>>     >> ./build/qemu-system-mips64el: "mips64"
>>     >> ./build/qemu-system-mips64: "mips64"
>>     >> ./build/qemu-system-sparc64: "sparc64"
>>     >> ./build/qemu-system-arm: "arm"
>>     >> ./build/qemu-system-tricore: "tricore"
>>     >> ./build/qemu-system-mips: "mips"
>>     >> ./build/qemu-system-or1k: "or1k"
>>     >> ./build/qemu-system-sh4eb: "sh4"
>>     >> ./build/qemu-system-aarch64: "aarch64"
>>     >> ./build/qemu-system-ppc: "ppc"
>>     >> ./build/qemu-system-avr: "avr"
>>     >> ./build/qemu-system-alpha: "alpha"
>>     >>
>>     >>
>>     >> so we need to fix that behaviour change for query-target.
>>     >>
>>     >> If we want to be able to expose only the "base" target,
>>     >> then query-target's  QemuTargetInfo struct could be
>>     >> extended with a 2nd field that presents the base.
>>     >>
>>     >>
>>     >> With regards,
>>     >> Daniel
>>     >
>>     > Thanks for finding this Daniel.
>>     > SYS_EMU_TARGET already has the correct variants, the regression was to
>>     > use TARGET_ARCH instead of TARGET_NAME in target-info-stub.c.
>>     >
>>     > I think Richard used this one just because TARGET_NAME is a string, so
>>     > it can't be concatenated with C preprocessor.
>>     >
>>     > I'll fix that part.
>>     >
>>
>>     Please take a look to the following series that solves this regression,
>>     and also allows to detect endianness variants through target_arch():
>>
>>     20261006182558.151956-1-pierrick.bouvier@oss.qualcomm.com
>>     <mailto:20261006182558.151956-1-pierrick.bouvier@oss.qualcomm.com>
>>     "[PATCH 0/2] target-info: expose full target variant"
>>
>>     Regards,
>>     Pierrick
>>
> 


Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 2:52 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
> > On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
> > <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>
> >> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
> >>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
> >>> <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>>>
> >>>>>> Ok, but I'm not sure it answers the why.
> >>>>>> Could you explain the benefits?
> >>>>>
> >>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
> >>>>> The following original code would return -1 for some user-binary
> >>>>> +    SysEmuTarget arch = target_info()->target_arch;
> >>>>> +
> >>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
> >>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
> >>>>> +                               &error_abort);
> >>>>> +    }
> >>>>> +    return arch;
> >>>>> So basically assigning any value for the user binary is valid.
> >>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
> >>>>> -1 is another option but easy to confuse.
> >>>>>
> >>>>>
> >>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> >>>>> "target-info: Statically initialize target_arch"
> >>>>> doing that, I am not sure.
> >>>>>
> >>>>
> >>>> I guess there is a (good or bad) reason for which sub variants of
> >>>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
> >>>> that before doing any change, as it might have other consequences.
> >>>
> >>>
> >>> You’re right to ask, and I need to correct my earlier suggestion:
> >>> leaving user-mode target_arch
> >>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
> >>> code shared with user-mode builds,
> >>> including cpu-max-v8.c, where its result indexes a two-entry array.
> >>> For aarch64-linux-user, the sentinel could therefore cause an
> >>> out-of-bounds access during type registration.
> >>>
> >>> I checked the distinction: softmmu needs the full system-target
> >>> identity, including variants such as mipsel;
> >>> user-mode variants such as aarch64_be use their base TARGET_ARCH
> >>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
> >>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
> >>> than leave the field at SYS_EMU_TARGET__MAX.
> >>>
> >>
> >> That's technical details, but not an answer to the initial question of
> >> why we need to change anything for user binaries, compared to what exists.
> >
> > The first two patches revert the current static initialization so the
> > token can be replaced. They are not a user-mode behavior change.
> >
> > Compared with current QEMU, user-mode still uses TARGET_ARCH.
> > qemu-mipsel already reports mips, and it still will. Names such as
> > aarch64_be are not SysEmuTarget values, so user-mode cannot use the
> > full target name for this field; keeping TARGET_ARCH preserves today's
> > value and avoids the runtime parse.
> >
>
> Why should we need to expose this precise information?
> So far, if those targets were not exposed (and aliased to 32/64 bit
> variant), it's probably we didn't need it.

Another thing for a combined-binary qemu-system. The qmp's
query-machines' targets
can not return the exact target list of SysEmuTarget.
malta belongs to both mips, mips64 mips64el mipsel
qemu-system -target none -M malta will not able to print the full list that
 mips, mips64 mips64el mipsel are the proper target
but give us misleading
mips mips64

static const char * const mips_machines[] = {
    "malta",
    "none",
};

static const char * const mips64_machines[] = {
    "magnum",
    "malta",
    "none",
    "pica61",
};

>
> In case there is a real need to expose it, maybe the simplest solution
> is to add such target configs.
>
> > The only intended change is softmmu, where TARGET_NAME differs from
> > TARGET_ARCH. qemu-system-mipsel must report mipsel, not mips.
> >
> > The cover-letter sentence about mipsel-linux-user compared against the
> > old target_name() parse, not against current QEMU.
> >
> >
> >
> >>
> >>>>
> >>>>>
> >>>>>>
> >>>>>>> "target-info: Statically initialize target_arch"
> >>>>>>>
> >>>>>>>>
> >>>>>>>> Regards,
> >>>>>>>> Pierrick
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>> --
> >>>>>          此致
> >>>>> 礼
> >>>>> 罗勇刚
> >>>>> Yours
> >>>>>     sincerely,
> >>>>> Yonggang Luo
> >>>>
> >>>
> >>>
> >>
> >
> >
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 2:52 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
> > On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
> > <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>
> >> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
> >>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
> >>> <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>>>
> >>>>>> Ok, but I'm not sure it answers the why.
> >>>>>> Could you explain the benefits?
> >>>>>
> >>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
> >>>>> The following original code would return -1 for some user-binary
> >>>>> +    SysEmuTarget arch = target_info()->target_arch;
> >>>>> +
> >>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
> >>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
> >>>>> +                               &error_abort);
> >>>>> +    }
> >>>>> +    return arch;
> >>>>> So basically assigning any value for the user binary is valid.
> >>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
> >>>>> -1 is another option but easy to confuse.
> >>>>>
> >>>>>
> >>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> >>>>> "target-info: Statically initialize target_arch"
> >>>>> doing that, I am not sure.
> >>>>>
> >>>>
> >>>> I guess there is a (good or bad) reason for which sub variants of
> >>>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
> >>>> that before doing any change, as it might have other consequences.
> >>>
> >>>
> >>> You’re right to ask, and I need to correct my earlier suggestion:
> >>> leaving user-mode target_arch
> >>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
> >>> code shared with user-mode builds,
> >>> including cpu-max-v8.c, where its result indexes a two-entry array.
> >>> For aarch64-linux-user, the sentinel could therefore cause an
> >>> out-of-bounds access during type registration.
> >>>
> >>> I checked the distinction: softmmu needs the full system-target
> >>> identity, including variants such as mipsel;
> >>> user-mode variants such as aarch64_be use their base TARGET_ARCH
> >>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
> >>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
> >>> than leave the field at SYS_EMU_TARGET__MAX.
> >>>
> >>
> >> That's technical details, but not an answer to the initial question of
> >> why we need to change anything for user binaries, compared to what exists.
> >
> > The first two patches revert the current static initialization so the
> > token can be replaced. They are not a user-mode behavior change.
> >
> > Compared with current QEMU, user-mode still uses TARGET_ARCH.
> > qemu-mipsel already reports mips, and it still will. Names such as
> > aarch64_be are not SysEmuTarget values, so user-mode cannot use the
> > full target name for this field; keeping TARGET_ARCH preserves today's
> > value and avoids the runtime parse.
> >
>
> Why should we need to expose this precise information?
> So far, if those targets were not exposed (and aliased to 32/64 bit
> variant), it's probably we didn't need it.

because for different SysEmuTarget, the machine list is different.
return a wrong SysEmuTarget would cause a mismatch between SysEmuTarget
and the machine list. for example:

static const char * const mips_machines[] = {
    "malta",
    "none",
};

static const char * const mips64_machines[] = {
    "magnum",
    "malta",
    "none",
    "pica61",
};

static const char * const mips64el_machines[] = {
    "boston",
    "fuloong2e",
    "loongson3-virt",
    "magnum",
    "malta",
    "none",
    "pica61",
};

static const char * const mipsel_machines[] = {
    "malta",
    "none",
};


>
> In case there is a real need to expose it, maybe the simplest solution
> is to add such target configs.
>
> > The only intended change is softmmu, where TARGET_NAME differs from
> > TARGET_ARCH. qemu-system-mipsel must report mipsel, not mips.
> >
> > The cover-letter sentence about mipsel-linux-user compared against the
> > old target_name() parse, not against current QEMU.
> >
> >
> >
> >>
> >>>>
> >>>>>
> >>>>>>
> >>>>>>> "target-info: Statically initialize target_arch"
> >>>>>>>
> >>>>>>>>
> >>>>>>>> Regards,
> >>>>>>>> Pierrick
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>> --
> >>>>>          此致
> >>>>> 礼
> >>>>> 罗勇刚
> >>>>> Yours
> >>>>>     sincerely,
> >>>>> Yonggang Luo
> >>>>
> >>>
> >>>
> >>
> >
> >
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/5/2026 12:06 PM, Yonggang Luo wrote:
> On Tue, Oct 6, 2026 at 2:52 AM Pierrick Bouvier
> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>
>> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
>>> On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>
>>>> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
>>>>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
>>>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
>>>>>>>>
>>>>>>>> Ok, but I'm not sure it answers the why.
>>>>>>>> Could you explain the benefits?
>>>>>>>
>>>>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
>>>>>>> The following original code would return -1 for some user-binary
>>>>>>> +    SysEmuTarget arch = target_info()->target_arch;
>>>>>>> +
>>>>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
>>>>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
>>>>>>> +                               &error_abort);
>>>>>>> +    }
>>>>>>> +    return arch;
>>>>>>> So basically assigning any value for the user binary is valid.
>>>>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
>>>>>>> -1 is another option but easy to confuse.
>>>>>>>
>>>>>>>
>>>>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
>>>>>>> "target-info: Statically initialize target_arch"
>>>>>>> doing that, I am not sure.
>>>>>>>
>>>>>>
>>>>>> I guess there is a (good or bad) reason for which sub variants of
>>>>>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
>>>>>> that before doing any change, as it might have other consequences.
>>>>>
>>>>>
>>>>> You’re right to ask, and I need to correct my earlier suggestion:
>>>>> leaving user-mode target_arch
>>>>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
>>>>> code shared with user-mode builds,
>>>>> including cpu-max-v8.c, where its result indexes a two-entry array.
>>>>> For aarch64-linux-user, the sentinel could therefore cause an
>>>>> out-of-bounds access during type registration.
>>>>>
>>>>> I checked the distinction: softmmu needs the full system-target
>>>>> identity, including variants such as mipsel;
>>>>> user-mode variants such as aarch64_be use their base TARGET_ARCH
>>>>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
>>>>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
>>>>> than leave the field at SYS_EMU_TARGET__MAX.
>>>>>
>>>>
>>>> That's technical details, but not an answer to the initial question of
>>>> why we need to change anything for user binaries, compared to what exists.
>>>
>>> The first two patches revert the current static initialization so the
>>> token can be replaced. They are not a user-mode behavior change.
>>>
>>> Compared with current QEMU, user-mode still uses TARGET_ARCH.
>>> qemu-mipsel already reports mips, and it still will. Names such as
>>> aarch64_be are not SysEmuTarget values, so user-mode cannot use the
>>> full target name for this field; keeping TARGET_ARCH preserves today's
>>> value and avoids the runtime parse.
>>>
>>
>> Why should we need to expose this precise information?
>> So far, if those targets were not exposed (and aliased to 32/64 bit
>> variant), it's probably we didn't need it.
> 
> because for different SysEmuTarget, the machine list is different.
> return a wrong SysEmuTarget would cause a mismatch between SysEmuTarget
> and the machine list. for example:
> 
> static const char * const mips_machines[] = {
>     "malta",
>     "none",
> };
> 
> static const char * const mips64_machines[] = {
>     "magnum",
>     "malta",
>     "none",
>     "pica61",
> };
> 
> static const char * const mips64el_machines[] = {
>     "boston",
>     "fuloong2e",
>     "loongson3-virt",
>     "magnum",
>     "malta",
>     "none",
>     "pica61",
> };
> 
> static const char * const mipsel_machines[] = {
>     "malta",
>     "none",
> };
> 
>

I see, in this case, I would invite you to first work on how to declare
for which target a machine is available, as discussed with Daniel on a
previous thread.

What comes out of this will give the answer about how to deal with sub
variants.

If it's a callback, it should be easy to use:
is_available_mips64el() {
  target_mips64() && target_big_endian()
}

If it's a static list of SYS_EMU_TARGET, then the easiest path will
probably be to extend list of targets in this enum.

In all cases, that's the first thing to work on before any other step.

Regards,
Pierrick

Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 3:15 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/5/2026 12:06 PM, Yonggang Luo wrote:
> > On Tue, Oct 6, 2026 at 2:52 AM Pierrick Bouvier
> > <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>
> >> On 10/5/2026 11:45 AM, Yonggang Luo wrote:
> >>> On Tue, Oct 6, 2026 at 2:06 AM Pierrick Bouvier
> >>> <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>
> >>>> On 10/5/2026 10:04 AM, Yonggang Luo wrote:
> >>>>> On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
> >>>>> <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>>>>>
> >>>>>>>> Ok, but I'm not sure it answers the why.
> >>>>>>>> Could you explain the benefits?
> >>>>>>>
> >>>>>>> Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
> >>>>>>> The following original code would return -1 for some user-binary
> >>>>>>> +    SysEmuTarget arch = target_info()->target_arch;
> >>>>>>> +
> >>>>>>> +    if (arch == SYS_EMU_TARGET__MAX) {
> >>>>>>> +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
> >>>>>>> +                               &error_abort);
> >>>>>>> +    }
> >>>>>>> +    return arch;
> >>>>>>> So basically assigning any value for the user binary is valid.
> >>>>>>> SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
> >>>>>>> -1 is another option but easy to confuse.
> >>>>>>>
> >>>>>>>
> >>>>>>> For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> >>>>>>> "target-info: Statically initialize target_arch"
> >>>>>>> doing that, I am not sure.
> >>>>>>>
> >>>>>>
> >>>>>> I guess there is a (good or bad) reason for which sub variants of
> >>>>>> targets are not reflected in SYS_EMU_TARGET enum. We should double check
> >>>>>> that before doing any change, as it might have other consequences.
> >>>>>
> >>>>>
> >>>>> You’re right to ask, and I need to correct my earlier suggestion:
> >>>>> leaving user-mode target_arch
> >>>>>  as SYS_EMU_TARGET__MAX is not safe. target_aarch64() is used by ARM
> >>>>> code shared with user-mode builds,
> >>>>> including cpu-max-v8.c, where its result indexes a two-entry array.
> >>>>> For aarch64-linux-user, the sentinel could therefore cause an
> >>>>> out-of-bounds access during type registration.
> >>>>>
> >>>>> I checked the distinction: softmmu needs the full system-target
> >>>>> identity, including variants such as mipsel;
> >>>>> user-mode variants such as aarch64_be use their base TARGET_ARCH
> >>>>> (aarch64) for this enum. I’ll keep the full TARGET_SYS_EMU
> >>>>>  value for softmmu and use TARGET_ARCH for user-mode builds, rather
> >>>>> than leave the field at SYS_EMU_TARGET__MAX.
> >>>>>
> >>>>
> >>>> That's technical details, but not an answer to the initial question of
> >>>> why we need to change anything for user binaries, compared to what exists.
> >>>
> >>> The first two patches revert the current static initialization so the
> >>> token can be replaced. They are not a user-mode behavior change.
> >>>
> >>> Compared with current QEMU, user-mode still uses TARGET_ARCH.
> >>> qemu-mipsel already reports mips, and it still will. Names such as
> >>> aarch64_be are not SysEmuTarget values, so user-mode cannot use the
> >>> full target name for this field; keeping TARGET_ARCH preserves today's
> >>> value and avoids the runtime parse.
> >>>
> >>
> >> Why should we need to expose this precise information?
> >> So far, if those targets were not exposed (and aliased to 32/64 bit
> >> variant), it's probably we didn't need it.
> >
> > because for different SysEmuTarget, the machine list is different.
> > return a wrong SysEmuTarget would cause a mismatch between SysEmuTarget
> > and the machine list. for example:
> >
> > static const char * const mips_machines[] = {
> >     "malta",
> >     "none",
> > };
> >
> > static const char * const mips64_machines[] = {
> >     "magnum",
> >     "malta",
> >     "none",
> >     "pica61",
> > };
> >
> > static const char * const mips64el_machines[] = {
> >     "boston",
> >     "fuloong2e",
> >     "loongson3-virt",
> >     "magnum",
> >     "malta",
> >     "none",
> >     "pica61",
> > };
> >
> > static const char * const mipsel_machines[] = {
> >     "malta",
> >     "none",
> > };
> >
> >
>
> I see, in this case, I would invite you to first work on how to declare
> for which target a machine is available, as discussed with Daniel on a
> previous thread.
>
> What comes out of this will give the answer about how to deal with sub
> variants.
>
> If it's a callback, it should be easy to use:
> is_available_mips64el() {
>   target_mips64() && target_big_endian()
> }

That again triggers another issue, the query-machines need to return
the endianness/target_arch() pair
for checking if the machine filtering is implemented valid to match
existing qemu-system-$arch binaries.

>
> If it's a static list of SYS_EMU_TARGET, then the easiest path will
> probably be to extend list of targets in this enum.


No, adding every user-mode target to SYS_EMU_TARGET is not necessary for this
 softmmu machine-availability work. All configured softmmu targets already have
matching enum values. The missing variants (aarch64_be, armeb,
microblazeel, mipsn32, mipsn32el, ppc64le, and sparc32plus)
are user-mode-only here, so include them only if the availability
mechanism is intended
 to represent user-mode targets too.



>
> In all cases, that's the first thing to work on before any other step.
>
> Regards,
> Pierrick



-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> I guess there is a (good or bad) reason for which sub variants of
> targets are not reflected in SYS_EMU_TARGET enum. We should double check
> that before doing any change, as it might have other consequences.

Just for record, I found the original reason doing this is here
https://lore.kernel.org/qemu-devel/20260205030617.266625-1-richard.henderson@linaro.org/

target_arch() function would reparse target_name() every time if
it was not set to a proper SYS_EMU_TARGET_* value (when using
target-info-stub.c), which is not efficient.

This was found when doing changes to virtio_access_is_big_endian()
function, having an overhead of 50% after switching to runtime checks.
With this, overhead left is around 3%, due to indirect function calls.


>
> >
> >>
> >>> "target-info: Statically initialize target_arch"
> >>>
> >>>>
> >>>> Regards,
> >>>> Pierrick
> >>>
> >>>
> >>>
> >>
> >
> > --
> >          此致
> > 礼
> > 罗勇刚
> > Yours
> >     sincerely,
> > Yonggang Luo
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
Re: [PATCH 0/4] target-info: preserve full softmmu target identity
Posted by Yonggang Luo 1 month, 2 weeks ago
On Tue, Oct 6, 2026 at 12:25 AM Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 10/5/2026 9:19 AM, Yonggang Luo wrote:
> > On Tue, Oct 6, 2026 at 12:12 AM Pierrick Bouvier
> > <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>
> >> On 10/5/2026 9:10 AM, Yonggang Luo wrote:
> >>> On Tue, Oct 6, 2026 at 12:03 AM Pierrick Bouvier
> >>> <pierrick.bouvier@oss.qualcomm.com> wrote:
> >>>>
> >>>> On 10/4/2026 12:29 AM, Yonggang Luo wrote:
> >>>>> `TARGET_ARCH` identifies a base architecture, not necessarily the full
> >>>>> system-emulation target. For example, `mipsel-softmmu` uses `TARGET_ARCH=mips`,
> >>>>> which caused `query-target` to report `mips` instead of `mipsel`.
> >>>>>
> >>>>> Generate `TARGET_SYS_EMU` separately. Softmmu builds use the full target name,
> >>>>> as `SysEmuTarget` enumerates system targets. User-mode builds use
> >>>>> `TARGET_ARCH`: user target names such as `aarch64_be` and `mipsn32el` do not
> >>>>> have corresponding `SysEmuTarget` values. This means `mipsel-linux-user` now
> >>>>> reports the base architecture `mips` rather than `mipsel`; its executable name
> >>>>> remains unchanged. Initialize `TargetInfo.target_arch` from this token and add
> >>>>> a qtest to check the `query-target` result against the target name of the
> >>>>> running QEMU binary.
> >>>>>
> >>>>> Yonggang Luo (4):
> >>>>>   Revert "target-info: Statically initialize target_arch"
> >>>>>   Revert "meson: Add TARGET_ARCH to config_target_data"
> >>>>>   tests/qtest: check query-target architecture
> >>>>>   target-info: preserve full softmmu target identity
> >>>>>
> >>>>>  meson.build            | 11 +++++++++--
> >>>>>  target-info-stub.c     |  2 +-
> >>>>>  tests/qtest/qmp-test.c | 13 +++++++++++++
> >>>>>  3 files changed, 23 insertions(+), 3 deletions(-)
> >>>>>
> >>>>
> >>>> Why should we do this for user binaries? Current work around
> >>>> single-binary only concerns system binaries, where all targets are
> >>>> correctly covered by what exists.
> >>>
> >>> From my personal point of view, keeping target_arch as
> >>> SYS_EMU_TARGET__MAX for user binaries
> >>> is a better option. I am doing this is for replica of commit
> >>>
> >>
> >> Ok, but I'm not sure it answers the why.
> >> Could you explain the benefits?
> >
> > Which part? keeping target_arch as SYS_EMU_TARGET__MAX for user-binary because
> > The following original code would return -1 for some user-binary
> > +    SysEmuTarget arch = target_info()->target_arch;
> > +
> > +    if (arch == SYS_EMU_TARGET__MAX) {
> > +        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
> > +                               &error_abort);
> > +    }
> > +    return arch;
> > So basically assigning any value for the user binary is valid.
> > SYS_EMU_TARGET__MAX is more explicit as it's related to type SysEmuTarget.
> > -1 is another option but easy to confuse.
> >
> >
> > For why commit e934c624f32f6f44f427d73a2e6a67e983a02ae6.
> > "target-info: Statically initialize target_arch"
> > doing that, I am not sure.
> >
>
> I guess there is a (good or bad) reason for which sub variants of
> targets are not reflected in SYS_EMU_TARGET enum. We should double check
> that before doing any change, as it might have other consequences.

Yeap, but this functional change caused me have to add endianness into
query-targets at
https://lore.kernel.org/qemu-devel/CAE2XoE_fxTRQJPzsDZHS44z65KR0e54cWjVpyZQGtr1sdLOinw@mail.gmail.com/

because in the current qemu tip, The $arch returned by query-target
not match the qemu-sytem-$arch anymore.

>
> >
> >>
> >>> "target-info: Statically initialize target_arch"
> >>>
> >>>>
> >>>> Regards,
> >>>> Pierrick
> >>>
> >>>
> >>>
> >>
> >
> > --
> >          此致
> > 礼
> > 罗勇刚
> > Yours
> >     sincerely,
> > Yonggang Luo
>


-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo