* [PATCH 01/10] target: Set disassemble_info::endian value for little-endian targets
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 13:49 ` Thomas Huth
2025-01-27 11:54 ` [PATCH 02/10] target: Set disassemble_info::endian value for big-endian targets Philippe Mathieu-Daudé
` (8 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field for little-endian targets.
Note, there was no disas_set_info() handler registered
for the TriCore target, so we implement one.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/alpha/cpu.c | 1 +
target/avr/cpu.c | 1 +
target/hexagon/cpu.c | 1 +
target/i386/cpu.c | 1 +
target/loongarch/cpu.c | 1 +
target/rx/cpu.c | 1 +
target/tricore/cpu.c | 6 ++++++
7 files changed, 12 insertions(+)
diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
index da21f99a6ac..acf81fda371 100644
--- a/target/alpha/cpu.c
+++ b/target/alpha/cpu.c
@@ -85,6 +85,7 @@ static int alpha_cpu_mmu_index(CPUState *cs, bool ifetch)
static void alpha_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
{
+ info->endian = BFD_ENDIAN_LITTLE;
info->mach = bfd_mach_alpha_ev6;
info->print_insn = print_insn_alpha;
}
diff --git a/target/avr/cpu.c b/target/avr/cpu.c
index 5a0e21465e5..2871d30540a 100644
--- a/target/avr/cpu.c
+++ b/target/avr/cpu.c
@@ -102,6 +102,7 @@ static void avr_cpu_reset_hold(Object *obj, ResetType type)
static void avr_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
{
+ info->endian = BFD_ENDIAN_LITTLE;
info->mach = bfd_arch_avr;
info->print_insn = avr_print_insn;
}
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
index 238e63bcea4..a9beb9a1757 100644
--- a/target/hexagon/cpu.c
+++ b/target/hexagon/cpu.c
@@ -293,6 +293,7 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)
static void hexagon_cpu_disas_set_info(CPUState *s, disassemble_info *info)
{
info->print_insn = print_insn_hexagon;
+ info->endian = BFD_ENDIAN_LITTLE;
}
static void hexagon_cpu_realize(DeviceState *dev, Error **errp)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 1b9c11022c4..eecb6f54d9e 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -8343,6 +8343,7 @@ static void x86_disas_set_info(CPUState *cs, disassemble_info *info)
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
+ info->endian = BFD_ENDIAN_LITTLE;
info->mach = (env->hflags & HF_CS64_MASK ? bfd_mach_x86_64
: env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386
: bfd_mach_i386_i8086);
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 227870e2856..cb9b9f909f3 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -617,6 +617,7 @@ static void loongarch_cpu_reset_hold(Object *obj, ResetType type)
static void loongarch_cpu_disas_set_info(CPUState *s, disassemble_info *info)
{
+ info->endian = BFD_ENDIAN_LITTLE;
info->print_insn = print_insn_loongarch;
}
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
index d237d007023..f283315474c 100644
--- a/target/rx/cpu.c
+++ b/target/rx/cpu.c
@@ -160,6 +160,7 @@ static void rx_cpu_set_irq(void *opaque, int no, int request)
static void rx_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
{
+ info->endian = BFD_ENDIAN_LITTLE;
info->mach = bfd_mach_rx;
info->print_insn = print_insn_rx;
}
diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
index eb794674c8d..49c18a0cd92 100644
--- a/target/tricore/cpu.c
+++ b/target/tricore/cpu.c
@@ -35,6 +35,11 @@ static const gchar *tricore_gdb_arch_name(CPUState *cs)
return "tricore";
}
+static void tricore_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
+{
+ info->endian = BFD_ENDIAN_LITTLE;
+}
+
static void tricore_cpu_set_pc(CPUState *cs, vaddr value)
{
cpu_env(cs)->PC = value & ~(target_ulong)1;
@@ -201,6 +206,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data)
cc->gdb_num_core_regs = 44;
cc->gdb_arch_name = tricore_gdb_arch_name;
+ cc->disas_set_info = tricore_cpu_disas_set_info;
cc->dump_state = tricore_cpu_dump_state;
cc->set_pc = tricore_cpu_set_pc;
cc->get_pc = tricore_cpu_get_pc;
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 01/10] target: Set disassemble_info::endian value for little-endian targets
2025-01-27 11:54 ` [PATCH 01/10] target: Set disassemble_info::endian value for little-endian targets Philippe Mathieu-Daudé
@ 2025-01-27 13:49 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 13:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field for little-endian targets.
>
> Note, there was no disas_set_info() handler registered
> for the TriCore target, so we implement one.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/alpha/cpu.c | 1 +
> target/avr/cpu.c | 1 +
> target/hexagon/cpu.c | 1 +
> target/i386/cpu.c | 1 +
> target/loongarch/cpu.c | 1 +
> target/rx/cpu.c | 1 +
> target/tricore/cpu.c | 6 ++++++
> 7 files changed, 12 insertions(+)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 02/10] target: Set disassemble_info::endian value for big-endian targets
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
2025-01-27 11:54 ` [PATCH 01/10] target: Set disassemble_info::endian value for little-endian targets Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 13:50 ` Thomas Huth
2025-01-27 11:54 ` [PATCH 03/10] target/arm: Set disassemble_info::endian value in disas_set_info() Philippe Mathieu-Daudé
` (7 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field for big-endian targets.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/hppa/cpu.c | 1 +
target/m68k/cpu.c | 1 +
target/openrisc/cpu.c | 1 +
target/s390x/cpu.c | 1 +
target/sparc/cpu.c | 1 +
5 files changed, 5 insertions(+)
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index f2441d4d7fb..1bc5cd746ec 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -144,6 +144,7 @@ static int hppa_cpu_mmu_index(CPUState *cs, bool ifetch)
static void hppa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
{
info->mach = bfd_mach_hppa20;
+ info->endian = BFD_ENDIAN_BIG;
info->print_insn = print_insn_hppa;
}
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index 5eac4a38c62..ff167aaea71 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -122,6 +122,7 @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type)
static void m68k_cpu_disas_set_info(CPUState *s, disassemble_info *info)
{
info->print_insn = print_insn_m68k;
+ info->endian = BFD_ENDIAN_BIG;
info->mach = 0;
}
diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c
index 0669ba2fd10..b81179bbbaa 100644
--- a/target/openrisc/cpu.c
+++ b/target/openrisc/cpu.c
@@ -83,6 +83,7 @@ static int openrisc_cpu_mmu_index(CPUState *cs, bool ifetch)
static void openrisc_disas_set_info(CPUState *cpu, disassemble_info *info)
{
+ info->endian = BFD_ENDIAN_BIG;
info->print_insn = print_insn_or1k;
}
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 3bea014f9ee..972d265478d 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -243,6 +243,7 @@ static void s390_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
{
info->mach = bfd_mach_s390_64;
info->cap_arch = CS_ARCH_SYSZ;
+ info->endian = BFD_ENDIAN_BIG;
info->cap_insn_unit = 2;
info->cap_insn_split = 6;
}
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index e3b46137178..9fd222e4c82 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -106,6 +106,7 @@ static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
static void cpu_sparc_disas_set_info(CPUState *cpu, disassemble_info *info)
{
info->print_insn = print_insn_sparc;
+ info->endian = BFD_ENDIAN_BIG;
#ifdef TARGET_SPARC64
info->mach = bfd_mach_sparc_v9b;
#endif
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 02/10] target: Set disassemble_info::endian value for big-endian targets
2025-01-27 11:54 ` [PATCH 02/10] target: Set disassemble_info::endian value for big-endian targets Philippe Mathieu-Daudé
@ 2025-01-27 13:50 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 13:50 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field for big-endian targets.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/hppa/cpu.c | 1 +
> target/m68k/cpu.c | 1 +
> target/openrisc/cpu.c | 1 +
> target/s390x/cpu.c | 1 +
> target/sparc/cpu.c | 1 +
> 5 files changed, 5 insertions(+)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 03/10] target/arm: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
2025-01-27 11:54 ` [PATCH 01/10] target: Set disassemble_info::endian value for little-endian targets Philippe Mathieu-Daudé
2025-01-27 11:54 ` [PATCH 02/10] target: Set disassemble_info::endian value for big-endian targets Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 13:57 ` Thomas Huth
2025-01-27 11:54 ` [PATCH 04/10] target/microblaze: Set disassemble_info::endian value in disas_set_info Philippe Mathieu-Daudé
` (6 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/cpu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index f9fdf708653..9de8c799c77 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1220,6 +1220,8 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
#else
info->endian = BFD_ENDIAN_BIG;
#endif
+ } else {
+ info->endian = BFD_ENDIAN_LITTLE;
}
info->flags &= ~INSN_ARM_BE32;
#ifndef CONFIG_USER_ONLY
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 03/10] target/arm: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 ` [PATCH 03/10] target/arm: Set disassemble_info::endian value in disas_set_info() Philippe Mathieu-Daudé
@ 2025-01-27 13:57 ` Thomas Huth
2025-02-10 21:24 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 13:57 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/arm/cpu.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index f9fdf708653..9de8c799c77 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -1220,6 +1220,8 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
> #else
> info->endian = BFD_ENDIAN_BIG;
> #endif
> + } else {
> + info->endian = BFD_ENDIAN_LITTLE;
> }
I'd maybe rather go with something like this:
info->endian = BFD_ENDIAN_LITTLE;
#if TARGET_BIG_ENDIAN
if (bswap_code(sctlr_b)) {
info->endian = BFD_ENDIAN_LITTLE;
}
#endif
What do you think?
Thomas
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 03/10] target/arm: Set disassemble_info::endian value in disas_set_info()
2025-01-27 13:57 ` Thomas Huth
@ 2025-02-10 21:24 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-10 21:24 UTC (permalink / raw)
To: Thomas Huth, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/1/25 14:57, Thomas Huth wrote:
> On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
>> Have the CPUClass::disas_set_info() callback set the
>> disassemble_info::endian field.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> target/arm/cpu.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
>> index f9fdf708653..9de8c799c77 100644
>> --- a/target/arm/cpu.c
>> +++ b/target/arm/cpu.c
>> @@ -1220,6 +1220,8 @@ static void arm_disas_set_info(CPUState *cpu,
>> disassemble_info *info)
>> #else
>> info->endian = BFD_ENDIAN_BIG;
>> #endif
>> + } else {
>> + info->endian = BFD_ENDIAN_LITTLE;
>> }
>
> I'd maybe rather go with something like this:
>
> info->endian = BFD_ENDIAN_LITTLE;
> #if TARGET_BIG_ENDIAN
> if (bswap_code(sctlr_b)) {
> info->endian = BFD_ENDIAN_LITTLE;
> }
This misses:
else {
info->endian = BFD_ENDIAN_BIG;
}
> #endif
>
> What do you think?
I'll go with Richard's ternary suggestion for v2 and see :)
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 04/10] target/microblaze: Set disassemble_info::endian value in disas_set_info
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-01-27 11:54 ` [PATCH 03/10] target/arm: Set disassemble_info::endian value in disas_set_info() Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 14:03 ` Thomas Huth
2025-01-27 16:24 ` Richard Henderson
2025-01-27 11:54 ` [PATCH 05/10] target/mips: Set disassemble_info::endian value in disas_set_info() Philippe Mathieu-Daudé
` (5 subsequent siblings)
9 siblings, 2 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/microblaze/cpu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
index 13d194cef88..7603d2e8f73 100644
--- a/target/microblaze/cpu.c
+++ b/target/microblaze/cpu.c
@@ -224,6 +224,11 @@ static void mb_disas_set_info(CPUState *cpu, disassemble_info *info)
{
info->mach = bfd_arch_microblaze;
info->print_insn = print_insn_microblaze;
+#if TARGET_BIG_ENDIAN
+ info->endian = BFD_ENDIAN_BIG;
+#else
+ info->endian = BFD_ENDIAN_LITTLE;
+#endif
}
static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 04/10] target/microblaze: Set disassemble_info::endian value in disas_set_info
2025-01-27 11:54 ` [PATCH 04/10] target/microblaze: Set disassemble_info::endian value in disas_set_info Philippe Mathieu-Daudé
@ 2025-01-27 14:03 ` Thomas Huth
2025-01-27 16:24 ` Richard Henderson
1 sibling, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 14:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/microblaze/cpu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
> index 13d194cef88..7603d2e8f73 100644
> --- a/target/microblaze/cpu.c
> +++ b/target/microblaze/cpu.c
> @@ -224,6 +224,11 @@ static void mb_disas_set_info(CPUState *cpu, disassemble_info *info)
> {
> info->mach = bfd_arch_microblaze;
> info->print_insn = print_insn_microblaze;
> +#if TARGET_BIG_ENDIAN
> + info->endian = BFD_ENDIAN_BIG;
> +#else
> + info->endian = BFD_ENDIAN_LITTLE;
> +#endif
> }
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 04/10] target/microblaze: Set disassemble_info::endian value in disas_set_info
2025-01-27 11:54 ` [PATCH 04/10] target/microblaze: Set disassemble_info::endian value in disas_set_info Philippe Mathieu-Daudé
2025-01-27 14:03 ` Thomas Huth
@ 2025-01-27 16:24 ` Richard Henderson
1 sibling, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2025-01-27 16:24 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Thomas Huth, qemu-ppc
On 1/27/25 03:54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/microblaze/cpu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
> index 13d194cef88..7603d2e8f73 100644
> --- a/target/microblaze/cpu.c
> +++ b/target/microblaze/cpu.c
> @@ -224,6 +224,11 @@ static void mb_disas_set_info(CPUState *cpu, disassemble_info *info)
> {
> info->mach = bfd_arch_microblaze;
> info->print_insn = print_insn_microblaze;
> +#if TARGET_BIG_ENDIAN
> + info->endian = BFD_ENDIAN_BIG;
> +#else
> + info->endian = BFD_ENDIAN_LITTLE;
> +#endif
Avoid preprocessor wherever possible:
if (TARGET_BIG_ENDIAN) {
or ?:.
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 05/10] target/mips: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-01-27 11:54 ` [PATCH 04/10] target/microblaze: Set disassemble_info::endian value in disas_set_info Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 13:58 ` Thomas Huth
2025-01-27 11:54 ` [PATCH 06/10] target/ppc: " Philippe Mathieu-Daudé
` (4 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/mips/cpu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index 0b267d2e507..f6d247b530f 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -429,12 +429,15 @@ static void mips_cpu_disas_set_info(CPUState *s, disassemble_info *info)
{
if (!(cpu_env(s)->insn_flags & ISA_NANOMIPS32)) {
#if TARGET_BIG_ENDIAN
+ info->endian = BFD_ENDIAN_BIG;
info->print_insn = print_insn_big_mips;
#else
+ info->endian = BFD_ENDIAN_LITTLE;
info->print_insn = print_insn_little_mips;
#endif
} else {
info->print_insn = print_insn_nanomips;
+ info->endian = BFD_ENDIAN_LITTLE;
}
}
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 05/10] target/mips: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 ` [PATCH 05/10] target/mips: Set disassemble_info::endian value in disas_set_info() Philippe Mathieu-Daudé
@ 2025-01-27 13:58 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 13:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/mips/cpu.c | 3 +++
> 1 file changed, 3 insertions(+)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 06/10] target/ppc: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-01-27 11:54 ` [PATCH 05/10] target/mips: Set disassemble_info::endian value in disas_set_info() Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 14:03 ` Thomas Huth
2025-01-27 11:54 ` [PATCH 07/10] target/riscv: " Philippe Mathieu-Daudé
` (3 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/ppc/cpu_init.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index ed85448bc7d..c3263f26219 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -7398,6 +7398,8 @@ static void ppc_disas_set_info(CPUState *cs, disassemble_info *info)
if ((env->hflags >> MSR_LE) & 1) {
info->endian = BFD_ENDIAN_LITTLE;
+ } else {
+ info->endian = BFD_ENDIAN_BIG;
}
info->mach = env->bfd_mach;
if (!env->bfd_mach) {
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 06/10] target/ppc: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 ` [PATCH 06/10] target/ppc: " Philippe Mathieu-Daudé
@ 2025-01-27 14:03 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 14:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field.
Maybe add a "always" between "callback" and "set" ?
Anyway,
Reviewed-by: Thomas Huth <thuth@redhat.com>
> diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
> index ed85448bc7d..c3263f26219 100644
> --- a/target/ppc/cpu_init.c
> +++ b/target/ppc/cpu_init.c
> @@ -7398,6 +7398,8 @@ static void ppc_disas_set_info(CPUState *cs, disassemble_info *info)
>
> if ((env->hflags >> MSR_LE) & 1) {
> info->endian = BFD_ENDIAN_LITTLE;
> + } else {
> + info->endian = BFD_ENDIAN_BIG;
> }
> info->mach = env->bfd_mach;
> if (!env->bfd_mach) {
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 07/10] target/riscv: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-01-27 11:54 ` [PATCH 06/10] target/ppc: " Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 14:04 ` Thomas Huth
2025-01-27 11:54 ` [PATCH 08/10] target/sh4: " Philippe Mathieu-Daudé
` (2 subsequent siblings)
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/riscv/cpu.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 3d4bd157d2c..b39a701d751 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1156,6 +1156,15 @@ static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)
CPURISCVState *env = &cpu->env;
info->target_info = &cpu->cfg;
+ /*
+ * A couple of bits in MSTATUS set the endianness:
+ * - MSTATUS_UBE (User-mode),
+ * - MSTATUS_SBE (Supervisor-mode),
+ * - MSTATUS_MBE (Machine-mode)
+ * but we don't implement that yet.
+ */
+ info->endian = BFD_ENDIAN_LITTLE;
+
switch (env->xl) {
case MXL_RV32:
info->print_insn = print_insn_riscv32;
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 07/10] target/riscv: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 ` [PATCH 07/10] target/riscv: " Philippe Mathieu-Daudé
@ 2025-01-27 14:04 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 14:04 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/riscv/cpu.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
> index 3d4bd157d2c..b39a701d751 100644
> --- a/target/riscv/cpu.c
> +++ b/target/riscv/cpu.c
> @@ -1156,6 +1156,15 @@ static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)
> CPURISCVState *env = &cpu->env;
> info->target_info = &cpu->cfg;
>
> + /*
> + * A couple of bits in MSTATUS set the endianness:
> + * - MSTATUS_UBE (User-mode),
> + * - MSTATUS_SBE (Supervisor-mode),
> + * - MSTATUS_MBE (Machine-mode)
> + * but we don't implement that yet.
> + */
> + info->endian = BFD_ENDIAN_LITTLE;
> +
> switch (env->xl) {
> case MXL_RV32:
> info->print_insn = print_insn_riscv32;
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 08/10] target/sh4: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-01-27 11:54 ` [PATCH 07/10] target/riscv: " Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 14:05 ` Thomas Huth
2025-01-27 11:54 ` [PATCH 09/10] target/xtensa: " Philippe Mathieu-Daudé
2025-01-27 11:54 ` [PATCH 10/10] disas: Remove target_words_bigendian() call in initialize_debug_target() Philippe Mathieu-Daudé
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/sh4/cpu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
index e3c2aea1a64..9d3e6cb2fd7 100644
--- a/target/sh4/cpu.c
+++ b/target/sh4/cpu.c
@@ -134,6 +134,11 @@ static void superh_cpu_reset_hold(Object *obj, ResetType type)
static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
{
+#if TARGET_BIG_ENDIAN
+ info->endian = BFD_ENDIAN_BIG;
+#else
+ info->endian = BFD_ENDIAN_LITTLE;
+#endif
info->mach = bfd_mach_sh4;
info->print_insn = print_insn_sh;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 08/10] target/sh4: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 ` [PATCH 08/10] target/sh4: " Philippe Mathieu-Daudé
@ 2025-01-27 14:05 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 14:05 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/sh4/cpu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
> index e3c2aea1a64..9d3e6cb2fd7 100644
> --- a/target/sh4/cpu.c
> +++ b/target/sh4/cpu.c
> @@ -134,6 +134,11 @@ static void superh_cpu_reset_hold(Object *obj, ResetType type)
>
> static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
> {
> +#if TARGET_BIG_ENDIAN
> + info->endian = BFD_ENDIAN_BIG;
> +#else
> + info->endian = BFD_ENDIAN_LITTLE;
> +#endif
> info->mach = bfd_mach_sh4;
> info->print_insn = print_insn_sh;
> }
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 09/10] target/xtensa: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-01-27 11:54 ` [PATCH 08/10] target/sh4: " Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 14:05 ` Thomas Huth
2025-01-27 11:54 ` [PATCH 10/10] disas: Remove target_words_bigendian() call in initialize_debug_target() Philippe Mathieu-Daudé
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
Have the CPUClass::disas_set_info() callback set the
disassemble_info::endian field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/xtensa/cpu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index efbfe73fcfb..bc170dbb5cc 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -159,6 +159,11 @@ static void xtensa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
info->private_data = cpu->env.config->isa;
info->print_insn = print_insn_xtensa;
+#if TARGET_BIG_ENDIAN
+ info->endian = BFD_ENDIAN_BIG;
+#else
+ info->endian = BFD_ENDIAN_LITTLE;
+#endif
}
static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp)
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 09/10] target/xtensa: Set disassemble_info::endian value in disas_set_info()
2025-01-27 11:54 ` [PATCH 09/10] target/xtensa: " Philippe Mathieu-Daudé
@ 2025-01-27 14:05 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 14:05 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> Have the CPUClass::disas_set_info() callback set the
> disassemble_info::endian field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/xtensa/cpu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
> index efbfe73fcfb..bc170dbb5cc 100644
> --- a/target/xtensa/cpu.c
> +++ b/target/xtensa/cpu.c
> @@ -159,6 +159,11 @@ static void xtensa_cpu_disas_set_info(CPUState *cs, disassemble_info *info)
>
> info->private_data = cpu->env.config->isa;
> info->print_insn = print_insn_xtensa;
> +#if TARGET_BIG_ENDIAN
> + info->endian = BFD_ENDIAN_BIG;
> +#else
> + info->endian = BFD_ENDIAN_LITTLE;
> +#endif
> }
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 10/10] disas: Remove target_words_bigendian() call in initialize_debug_target()
2025-01-27 11:54 [PATCH 00/10] disas: Have CPUClass::disas_set_info() callback set the endianness Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-01-27 11:54 ` [PATCH 09/10] target/xtensa: " Philippe Mathieu-Daudé
@ 2025-01-27 11:54 ` Philippe Mathieu-Daudé
2025-01-27 14:07 ` Thomas Huth
9 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-27 11:54 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, Thomas Huth, qemu-ppc,
Philippe Mathieu-Daudé
All CPUClass implementations must implement disas_set_info()
which sets the disassemble_info::endian value.
Ensure that by:
1/ assert disas_set_info() handler is not NULL
2/ set %endian to BFD_ENDIAN_UNKNOWN before calling the
CPUClass::disas_set_info() handler, then assert %endian
is not BFD_ENDIAN_UNKNOWN after the call.
This allows removing the target_words_bigendian() call in disas/.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
disas/disas-common.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/disas/disas-common.c b/disas/disas-common.c
index 57505823cb7..42e911e36be 100644
--- a/disas/disas-common.c
+++ b/disas/disas-common.c
@@ -7,7 +7,6 @@
#include "disas/disas.h"
#include "disas/capstone.h"
#include "hw/core/cpu.h"
-#include "exec/tswap.h"
#include "disas-internal.h"
@@ -61,15 +60,11 @@ void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu)
s->cpu = cpu;
s->info.print_address_func = print_address;
- if (target_words_bigendian()) {
- s->info.endian = BFD_ENDIAN_BIG;
- } else {
- s->info.endian = BFD_ENDIAN_LITTLE;
- }
+ s->info.endian = BFD_ENDIAN_UNKNOWN;
- if (cpu->cc->disas_set_info) {
- cpu->cc->disas_set_info(cpu, &s->info);
- }
+ g_assert(cpu->cc->disas_set_info);
+ cpu->cc->disas_set_info(cpu, &s->info);
+ g_assert(s->info.endian != BFD_ENDIAN_UNKNOWN);
}
int disas_gstring_printf(FILE *stream, const char *fmt, ...)
--
2.47.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 10/10] disas: Remove target_words_bigendian() call in initialize_debug_target()
2025-01-27 11:54 ` [PATCH 10/10] disas: Remove target_words_bigendian() call in initialize_debug_target() Philippe Mathieu-Daudé
@ 2025-01-27 14:07 ` Thomas Huth
0 siblings, 0 replies; 23+ messages in thread
From: Thomas Huth @ 2025-01-27 14:07 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-arm, qemu-s390x, Paolo Bonzini, qemu-riscv, Peter Maydell,
Richard Henderson, qemu-ppc
On 27/01/2025 12.54, Philippe Mathieu-Daudé wrote:
> All CPUClass implementations must implement disas_set_info()
> which sets the disassemble_info::endian value.
>
> Ensure that by:
>
> 1/ assert disas_set_info() handler is not NULL
> 2/ set %endian to BFD_ENDIAN_UNKNOWN before calling the
> CPUClass::disas_set_info() handler, then assert %endian
> is not BFD_ENDIAN_UNKNOWN after the call.
>
> This allows removing the target_words_bigendian() call in disas/.
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> disas/disas-common.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 23+ messages in thread