From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: Anton Johansson <anjo@rev.ng>
Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
kvm@vger.kernel.org, alex.bennee@linaro.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
qemu-arm@nongnu.org, richard.henderson@linaro.org
Subject: Re: [PATCH 09/13] target/arm/cpu: get endianness from cpu state
Date: Tue, 29 Apr 2025 14:07:03 -0700 [thread overview]
Message-ID: <6e628189-f497-4d95-a6ac-c3cc726be2ad@linaro.org> (raw)
In-Reply-To: <bwdflzaiqdpq33uzowvrgjbha3wye6k74puwur755pq27z67eu@mnc2ze4it5cl>
On 4/29/25 5:26 AM, Anton Johansson wrote:
> On 29/04/25, Pierrick Bouvier wrote:
>> Remove TARGET_BIG_ENDIAN dependency.
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>> target/arm/cpu.c | 22 +++++++++++-----------
>> 1 file changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
>> index e7a15ade8b4..85e886944f6 100644
>> --- a/target/arm/cpu.c
>> +++ b/target/arm/cpu.c
>> @@ -67,6 +67,15 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value)
>> }
>> }
>>
>> +static bool arm_cpu_is_big_endian(CPUState *cs)
>> +{
>> + ARMCPU *cpu = ARM_CPU(cs);
>> + CPUARMState *env = &cpu->env;
>> +
>> + cpu_synchronize_state(cs);
>> + return arm_cpu_data_is_big_endian(env);
>> +}
>> +
>> static vaddr arm_cpu_get_pc(CPUState *cs)
>> {
>> ARMCPU *cpu = ARM_CPU(cs);
>> @@ -1130,15 +1139,6 @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level)
>> #endif
>> }
>>
>> -static bool arm_cpu_virtio_is_big_endian(CPUState *cs)
>> -{
>> - ARMCPU *cpu = ARM_CPU(cs);
>> - CPUARMState *env = &cpu->env;
>> -
>> - cpu_synchronize_state(cs);
>> - return arm_cpu_data_is_big_endian(env);
>> -}
>> -
>> #ifdef CONFIG_TCG
>> bool arm_cpu_exec_halt(CPUState *cs)
>> {
>> @@ -1203,7 +1203,7 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
>>
>> info->endian = BFD_ENDIAN_LITTLE;
>> if (bswap_code(sctlr_b)) {
>> - info->endian = TARGET_BIG_ENDIAN ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG;
>> + info->endian = arm_cpu_is_big_endian(cpu) ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG;
>> }
>
> I'm not the most familiar with arm but as far as I can tell these are
> not equivalent. My understanding is that arm_cpu_is_big_endian() models
> data endianness, and TARGET_BIG_ENDIAN instruction endianness.
>
> Also, for user mode where this branch is relevant, bswap_code() still
> depends on TARGET_BIG_ENDIAN anyway and the above branch would reduce to
> (on arm32)
>
> if (TARGET_BIG_ENDIAN ^ sctlr_b) {
> info->endian = sctlr_b ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG;
> }
>
> giving the opposite result to the original code.
>
Ooops, that's a good point, I missed it was calling
arm_cpu_data_is_big_endian under the hoods.
I'll stick to target_big_endian().
Thanks,
Pierrick
next prev parent reply other threads:[~2025-04-29 21:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 4:59 [PATCH 00/13] single-binary: compile target/arm twice Pierrick Bouvier
2025-04-29 4:59 ` [PATCH 01/13] target/arm: Replace target_ulong -> uint64_t for HWBreakpoint Pierrick Bouvier
2025-04-29 9:15 ` Alex Bennée
2025-04-29 4:59 ` [PATCH 02/13] include/system/hvf: missing vaddr include Pierrick Bouvier
2025-04-29 5:36 ` Philippe Mathieu-Daudé
2025-04-29 7:13 ` Philippe Mathieu-Daudé
2025-04-29 21:09 ` Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 03/13] meson: add common libs for target and target_system Pierrick Bouvier
2025-04-29 18:01 ` Philippe Mathieu-Daudé
2025-04-29 21:11 ` Pierrick Bouvier
2025-04-30 6:06 ` Philippe Mathieu-Daudé
2025-04-30 6:12 ` Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 04/13] target/arm: move kvm stubs and remove CONFIG_KVM from kvm_arm.h Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 05/13] target/arm/kvm_arm: copy definitions from kvm headers Pierrick Bouvier
2025-04-29 10:28 ` Alex Bennée
2025-04-29 21:14 ` Pierrick Bouvier
2025-04-29 22:02 ` Pierrick Bouvier
2025-04-30 6:08 ` Philippe Mathieu-Daudé
2025-04-29 5:00 ` [PATCH 06/13] target/arm/kvm-stub: add missing stubs Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 07/13] target/arm/cpu: remove CONFIG_KVM from arm_cpu_kvm_set_irq Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 08/13] accel/hvf: add hvf_enabled() for common code Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 09/13] target/arm/cpu: get endianness from cpu state Pierrick Bouvier
2025-04-29 12:26 ` Anton Johansson via
2025-04-29 21:07 ` Pierrick Bouvier [this message]
2025-04-29 5:00 ` [PATCH 10/13] target/arm/cpu: remove TARGET_AARCH64 around aarch64_cpu_dump_state common Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 11/13] target/arm/cpu: remove TARGET_AARCH64 in arm_cpu_finalize_features Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 12/13] target/arm/cpu: compile file twice (user, system) only Pierrick Bouvier
2025-04-30 8:32 ` Philippe Mathieu-Daudé
2025-04-30 14:39 ` Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 13/13] target/arm/cpu32-stubs.c: compile file twice (user, system) Pierrick Bouvier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e628189-f497-4d95-a6ac-c3cc726be2ad@linaro.org \
--to=pierrick.bouvier@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=anjo@rev.ng \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).