@samitouri / QOSamiQemu / commits / 95b1f7cfd1

include/hw/core: Rename virtio_is_big_endian to internal_is_big_endian

These functions are needed to do semihosting on CPUs that support runtime-configurable endiannes. This commit renames them and allows using them for semihosting, but makes sure to signal that these functions should not be used in other circumstances. Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20260311-semihosting-cpu-tswap-v3-1-8e239575ec08@eonerc.rwth-aachen.de Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Martin Kröning committed Mar 11, 2026 at 17:27 UTC 95b1f7cfd14473a32cb5a2eb260ae9b340033800
6 files changed +12 -12
hw/core/cpu-system.c
+3 -3
@@ -127,10 +127,10 @@ int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu,
127 return (*cpu->cc->sysemu_ops->write_elf64_note)(f, cpu, cpuid, opaque);
128 }
129
130 -bool cpu_virtio_is_big_endian(CPUState *cpu)
130 +bool cpu_internal_is_big_endian(CPUState *cpu)
131 {
132 - if (cpu->cc->sysemu_ops->virtio_is_big_endian) {
133 - return cpu->cc->sysemu_ops->virtio_is_big_endian(cpu);
132 + if (cpu->cc->sysemu_ops->internal_is_big_endian) {
133 + return cpu->cc->sysemu_ops->internal_is_big_endian(cpu);
134 }
135 return target_big_endian();
136 }
hw/virtio/virtio.c
+1 -1
@@ -2323,7 +2323,7 @@ static enum virtio_device_endian virtio_default_endian(void)
2323
2324 static enum virtio_device_endian virtio_current_cpu_endian(void)
2325 {
2326 - if (cpu_virtio_is_big_endian(current_cpu)) {
2326 + if (cpu_internal_is_big_endian(current_cpu)) {
2327 return VIRTIO_DEVICE_ENDIAN_BIG;
2328 } else {
2329 return VIRTIO_DEVICE_ENDIAN_LITTLE;
include/hw/core/cpu.h
+2 -2
@@ -782,13 +782,13 @@ hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
782 int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs);
783
784 /**
785 - * cpu_virtio_is_big_endian:
785 + * cpu_internal_is_big_endian:
786 * @cpu: CPU
787
788 * Returns %true if a CPU which supports runtime configurable endianness
789 * is currently big-endian.
790 */
791 -bool cpu_virtio_is_big_endian(CPUState *cpu);
791 +bool cpu_internal_is_big_endian(CPUState *cpu);
792
793 /**
794 * cpu_has_work:
include/hw/core/sysemu-cpu-ops.h
+3 -3
@@ -77,13 +77,13 @@ typedef struct SysemuCPUOps {
77 int (*write_elf64_qemunote)(WriteCoreDumpFunction f, CPUState *cpu,
78 DumpState *s);
79 /**
80 - * @virtio_is_big_endian: Callback to return %true if a CPU which supports
80 + * @internal_is_big_endian: Callback to return %true if a CPU which supports
81 * runtime configurable endianness is currently big-endian.
82 * Non-configurable CPUs can use the default implementation of this method.
83 * This method should not be used by any callers other than the pre-1.0
84 - * virtio devices.
84 + * virtio devices and the semihosting interface.
85 */
86 - bool (*virtio_is_big_endian)(CPUState *cpu);
86 + bool (*internal_is_big_endian)(CPUState *cpu);
87
88 /**
89 * @legacy_vmsd: Legacy state for migration.
target/arm/cpu.c
+2 -2
@@ -756,7 +756,7 @@ static void arm_cpu_set_irq(void *opaque, int irq, int level)
756 }
757 }
758
759 -static bool arm_cpu_virtio_is_big_endian(CPUState *cs)
759 +static bool arm_cpu_internal_is_big_endian(CPUState *cs)
760 {
761 ARMCPU *cpu = ARM_CPU(cs);
762 CPUARMState *env = &cpu->env;
@@ -2299,7 +2299,7 @@ static const struct SysemuCPUOps arm_sysemu_ops = {
2299 .asidx_from_attrs = arm_asidx_from_attrs,
2300 .write_elf32_note = arm_cpu_write_elf32_note,
2301 .write_elf64_note = arm_cpu_write_elf64_note,
2302 - .virtio_is_big_endian = arm_cpu_virtio_is_big_endian,
2302 + .internal_is_big_endian = arm_cpu_internal_is_big_endian,
2303 .legacy_vmsd = &vmstate_arm_cpu,
2304 };
2305 #endif
target/ppc/cpu_init.c
+1 -1
@@ -7480,7 +7480,7 @@ static const struct SysemuCPUOps ppc_sysemu_ops = {
7480 .get_phys_page_debug = ppc_cpu_get_phys_page_debug,
7481 .write_elf32_note = ppc32_cpu_write_elf32_note,
7482 .write_elf64_note = ppc64_cpu_write_elf64_note,
7483 - .virtio_is_big_endian = ppc_cpu_is_big_endian,
7483 + .internal_is_big_endian = ppc_cpu_is_big_endian,
7484 .legacy_vmsd = &vmstate_ppc_cpu,
7485 };
7486 #endif