hw/microblaze: Quick single binary proof of concept
cover hw/microblaze: Quick single binary proof of concept
Introduce an API to get target-specific information from our current binary names (considered legacy as of today).
At this point, get endianness and target_long_bits, just enough to build qemu-system-microblaze (default to big endian) and its little-endian symlink:
$ make qemu-system-microblaze{,el}$ ./qemu-system-microblaze -M help Supported machines are: none empty machine petalogix-ml605 PetaLogix linux refdesign for xilinx ml605 (big endian) (deprecated) petalogix-s3adsp1800 PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (big endian) (default) xlnx-zynqmp-pmu Xilinx ZynqMP PMU machine (big endian) (deprecated)
$ ./qemu-system-microblazeel -M help Supported machines are: none empty machine petalogix-ml605 PetaLogix linux refdesign for xilinx ml605 (big endian) (deprecated) petalogix-s3adsp1800 PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (little endian) (default) xlnx-zynqmp-pmu Xilinx ZynqMP PMU machine (big endian) (deprecated)
Based-on: <[email protected]>
Philippe Mathieu-Daudé (18):
hw/xen/hvm: Fix Aarch64 typo
hw/vfio/common: Get target page size using runtime helpers
include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition
qemu: Introduce 'qemu/legacy_binary_info.h'
qemu: Introduce legacy_binary_is_64bit() helper hw/mips/mipssim: Replace TARGET_MIPS64 by legacy_binary_is_64bit() hw/mips/malta: Replace TARGET_MIPS64 by legacy_binary_is_64bit() hw/i386: Inline TARGET_DEFAULT_CPU_TYPE definition hw/ppc/mac: Replace TARGET_PPC64 by legacy_binary_is_64bit()
qemu: Introduce legacy_binary_is_big_endian() helper hw/mips/jazz: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian hw/mips/mipssim: Use legacy_binary_is_big_endian() hw/xtensa/sim: Replace TARGET_BIG_ENDIAN by
legacy_binary_is_big_endian
hw/xtensa/xtfpga: Check endianness via legacy_binary_is_big_endian() hw/microblaze/petalogix_ml605_mmu: Use legacy_binary_is_big_endian() hw/microblaze/petalogix_s3adsp1800_mmu: Use
legacy_binary_is_big_endian
meson: Allow symlinking system emulation binaries configs/targets: Merge qemu-system-microblaze{el} binaries
configs/targets/microblazeel-softmmu.mak | 8 - meson.build | 18 +- include/exec/poison.h | 1 + include/hw/xen/arch_hvm.h | 2 +- include/qemu/legacy_binary_info.h | 25 +++ target/i386/cpu.h | 6 - hw/i386/microvm.c | 5 +- hw/i386/pc.c | 5 +- hw/i386/xen/xen-pvh.c | 5 +- hw/microblaze/petalogix_ml605_mmu.c | 4 +- hw/microblaze/petalogix_s3adsp1800_mmu.c | 13 +- hw/mips/jazz.c | 23 ++- hw/mips/malta.c | 8 +- hw/mips/mipssim.c | 36 ++-- hw/ppc/mac_newworld.c | 9 +- hw/ppc/mac_oldworld.c | 5 +- hw/vfio/common.c | 9 +- hw/xtensa/sim.c | 4 +- hw/xtensa/xtfpga.c | 12 +- legacy_binary_info.c | 240 +++++++++++++++++++++++ system/vl.c | 2 + 21 files changed, 358 insertions(+), 82 deletions(-) delete mode 100644 configs/targets/microblazeel-softmmu.mak create mode 100644 include/qemu/legacy_binary_info.h create mode 100644 legacy_binary_info.c
Signature · 1 line
2.47.1
RFC PATCH 1/18 hw/xen/hvm: Fix Aarch64 typo
There is no TARGET_ARM_64 definition. Luckily enough, when TARGET_AARCH64 is defined, TARGET_ARM also is.
--- include/hw/xen/arch_hvm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/xen/arch_hvm.h +1 -1
@@ -1,5 +1,5 @@#if defined(TARGET_I386 ) || defined(TARGET_X86_64 )#include "hw/i386/xen_arch_hvm.h" -#elif defined(TARGET_ARM ) || defined(TARGET_ARM_64 ) +#elif defined(TARGET_ARM ) || defined(TARGET_AARCH64 )#include "hw/arm/xen_arch_hvm.h" #endif
Signature · 1 line
2.47.1
Re: [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
Quoted 14 lines · Philippe Mathieu-Daudé
There is no
TARGET_ARM_64definition. Luckily enough, whenTARGET_AARCH64is defined,TARGET_ARMalso is.Fixes 733766cd373 ("hw/arm: introduce xenpvh machine")Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/xen/arch_hvm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/hw/xen/arch_hvm.h +0
-0
include/hw/xen/arch_hvm.h line 5
Quoted 6 lines
include/hw/xen/arch_hvm.h +1
-1@@ -1,5 +1,5 @@#if defined(TARGET_I386 ) || defined(TARGET_X86_64 )#include "hw/i386/xen_arch_hvm.h" -#elif defined(TARGET_ARM ) || defined(TARGET_ARM_64 ) +#elif defined(TARGET_ARM ) || defined(TARGET_AARCH64 )#include "hw/arm/xen_arch_hvm.h" #endif
Re: [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
There is no
TARGET_ARM_64definition. Luckily enough, whenTARGET_AARCH64is defined,TARGET_ARMalso is.Fixes 733766cd373 ("hw/arm: introduce xenpvh machine")Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/xen/arch_hvm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Quoted 12 lines
include/hw/xen/arch_hvm.h +1
-1@@ -1,5 +1,5 @@#if defined(TARGET_I386 ) || defined(TARGET_X86_64 )#include "hw/i386/xen_arch_hvm.h" -#elif defined(TARGET_ARM ) || defined(TARGET_ARM_64 ) +#elif defined(TARGET_ARM ) || defined(TARGET_AARCH64 )#include "hw/arm/xen_arch_hvm.h" #endif
Re: [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
In reply to Philippe Mathieu-DaudéQuoted 14 lines · Philippe Mathieu-Daudé
There is no
TARGET_ARM_64definition. Luckily enough, whenTARGET_AARCH64is defined,TARGET_ARMalso is.Fixes 733766cd373 ("hw/arm: introduce xenpvh machine")Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/xen/arch_hvm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/hw/xen/arch_hvm.h +0
-0
include/hw/xen/arch_hvm.h line 5
Quoted 6 lines
include/hw/xen/arch_hvm.h +1
-1@@ -1,5 +1,5 @@#if defined(TARGET_I386 ) || defined(TARGET_X86_64 )#include "hw/i386/xen_arch_hvm.h" -#elif defined(TARGET_ARM ) || defined(TARGET_ARM_64 ) +#elif defined(TARGET_ARM ) || defined(TARGET_AARCH64 )#include "hw/arm/xen_arch_hvm.h" #endif
This is a no-difference change, but I'm picking this up for qemu-stable - just to remove a wrong code example for possible copy-paste errors :)
FWIW,
/mjt
Re: [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
Quoted 10 lines · Michael Tokarev
Quoted 9 lines · Philippe Mathieu-Daudé
There is no
TARGET_ARM_64definition. Luckily enough, whenTARGET_AARCH64is defined,TARGET_ARMalso is.Fixes 733766cd373 ("hw/arm: introduce xenpvh machine")Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/xen/arch_hvm.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
include/hw/xen/arch_hvm.h line 5
Quoted 11 lines
include/hw/xen/arch_hvm.h +1
-1@@ -1,5 +1,5 @@ #if defined(TARGET_I386) || defined(TARGET_X86_64) #include "hw/i386/xen_arch_hvm.h" -#elif defined(TARGET_ARM ) || defined(TARGET_ARM_64 ) +#elif defined(TARGET_ARM ) || defined(TARGET_AARCH64 ) #include "hw/arm/xen_arch_hvm.h" #endifThis is a no-difference change, but I'm picking this up for qemu-stable - just to remove a wrong code example for possible copy-paste errors :)
Good idea, thank you!
RFC PATCH 2/18 hw/vfio/common: Get target page size using runtime helpers
In reply to Philippe Mathieu-DaudéPrefer runtime helpers to get target page size.
--- hw/vfio/common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
hw/vfio/common.c +6 -3
@@ -30,6 +30,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "exec/target_page.h" #include "hw/hw.h" #include "qemu/error-report.h" #include "qemu/main-loop.h"
@@ -395,10 +396,12 @@ static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontainer,VFIORamDiscardListener *vrdl;/* Ignore some corner cases not relevant in practice. */ -g_assert (QEMU_IS_ALIGNED (section->offset_within_region,TARGET_PAGE_SIZE )); +g_assert (QEMU_IS_ALIGNED (section->offset_within_region, +qemu_target_page_size ()));g_assert (QEMU_IS_ALIGNED (section->offset_within_address_space, -TARGET_PAGE_SIZE )); -g_assert (QEMU_IS_ALIGNED (int128_get64 (section->size),TARGET_PAGE_SIZE )); +qemu_target_page_size ())); +g_assert (QEMU_IS_ALIGNED (int128_get64 (section->size), +qemu_target_page_size ())); vrdl =g_new0 (VFIORamDiscardListener,1 ); vrdl->bcontainer = bcontainer;
Signature · 1 line
2.47.1
Re: [RFC PATCH 02/18] hw/vfio/common: Get target page size using runtime helpers
Quoted 22 lines · Philippe Mathieu-Daudé
Prefer runtime helpers to get target page size.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/vfio/common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)hw/vfio/common.c +1
-0@@ -30,6 +30,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "exec/target_page.h" #include "hw/hw.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" @@ -395,10 +396,12 @@ static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontainer,VFIORamDiscardListener *vrdl;
hw/vfio/common.c static void vfio_register_ram_discard_listener(VFIOContainerBase *bcontainer, · line 404
Quoted 10 lines
hw/vfio/common.c +5
-3/* Ignore some corner cases not relevant in practice. */ -g_assert (QEMU_IS_ALIGNED (section->offset_within_region,TARGET_PAGE_SIZE )); +g_assert (QEMU_IS_ALIGNED (section->offset_within_region, +qemu_target_page_size ()));g_assert (QEMU_IS_ALIGNED (section->offset_within_address_space, -TARGET_PAGE_SIZE )); -g_assert (QEMU_IS_ALIGNED (int128_get64 (section->size),TARGET_PAGE_SIZE )); +qemu_target_page_size ())); +g_assert (QEMU_IS_ALIGNED (int128_get64 (section->size), +qemu_target_page_size ()));
It would be worth storing this in a local variable, I think.
r~
RFC PATCH 3/18 include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition
In reply to Philippe Mathieu-DaudéEnsure common code never use this target specific definition.
--- include/exec/poison.h | 1 + 1 file changed, 1 insertion(+)
include/exec/poison.h +1 -0
@@ -47,6 +47,7 @@#pragma GCC poison TARGET_PAGE_MASK#pragma GCC poison TARGET_PAGE_BITS#pragma GCC poison TARGET_PAGE_ALIGN +#pragma GCC poison TARGET_PHYS_ADDR_SPACE_BITS#pragma GCC poison CPU_INTERRUPT_HARD#pragma GCC poison CPU_INTERRUPT_EXITTB
Signature · 1 line
2.47.1
Re: [RFC PATCH 03/18] include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition
Quoted 12 lines · Philippe Mathieu-Daudé
Ensure common code never use this target specific definition.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/poison.h | 1 + 1 file changed, 1 insertion(+)include/exec/poison.h +0
-0
include/exec/poison.h line 53
Quoted 7 lines
include/exec/poison.h +1
-0@@ -47,6 +47,7 @@#pragma GCC poison TARGET_PAGE_MASK#pragma GCC poison TARGET_PAGE_BITS#pragma GCC poison TARGET_PAGE_ALIGN +#pragma GCC poison TARGET_PHYS_ADDR_SPACE_BITS#pragma GCC poison CPU_INTERRUPT_HARD#pragma GCC poison CPU_INTERRUPT_EXITTB
r~
RFC PATCH 4/18 qemu: Introduce 'qemu/legacy_binary_info.h'
In reply to Philippe Mathieu-DaudéIntroduce an API to get information specific to a binary from the binary name (argv[0]).
Initialize it from qemu_init() on system emulation.
--- meson.build | 2 +- include/qemu/legacy_binary_info.h | 14 +++ legacy_binary_info.c | 160 ++++++++++++++++++++++++++++++ system/vl.c | 2 + 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 include/qemu/legacy_binary_info.h create mode 100644 legacy_binary_info.c
meson.build +1 -1
@@ -3767,7 +3767,7 @@ if have_block endif endif -common_ss.add(files('cpu-common.c')) +common_ss.add(files('cpu-common.c', 'legacy_binary_info.c')) specific_ss.add(files('cpu-target.c', 'arch_info-target.c')) subdir('system')
include/qemu/legacy_binary_info.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* QEMU legacy binary helpers +* +* Copyright (c) Linaro +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef QEMU_LEGACY_BINARY_INFO_H +#define QEMU_LEGACY_BINARY_INFO_H + +void legacy_binary_info_init (const char *argv0); + +#endif
legacy_binary_info.c new file +160 -0
160 lines not on this page · raw message
system/vl.c +2 -0
@@ -28,6 +28,7 @@#include "qemu/units.h" #include "qemu/module.h" #include "qemu/arch_info.h" +#include "qemu/legacy_binary_info.h" #include "exec/cpu-common.h" #include "exec/page-vary.h" #include "hw/qdev-properties.h"
@@ -2883,6 +2884,7 @@ void qemu_init(int argc, char **argv)error_init (argv[0 ]);qemu_init_exec_dir (argv[0 ]); +legacy_binary_info_init (argv[0 ]);os_setup_limits ();
Signature · 1 line
2.47.1
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 5 lines · Philippe Mathieu-Daudé
Introduce an API to get information specific to a binary from the binary name (argv[0]).
Initialize it from
qemu_init()on system emulation.
What we want here is more a include/qemu/target_info.h, which will allow to query the name of it, and helper for every architecture:
target_is_aarch64()target_is_ppc64()
...
Eventually, we can add combined getters like:target_is_64bit()
...
Naming "legacy" something that will be present in the long term is not the best move I think.
Quoted 229 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- meson.build | 2 +- include/qemu/legacy_binary_info.h | 14 +++ legacy_binary_info.c | 160 ++++++++++++++++++++++++++++++ system/vl.c | 2 + 4 files changed, 177 insertions(+), 1 deletion(-)create mode 100644
include/qemu/legacy_binary_info.hcreate mode 100644legacy_binary_info.cmeson.build +1
-1@@ -3767,7 +3767,7 @@ if have_block endif endif -common_ss.add(files('cpu-common.c')) +common_ss.add(files('cpu-common.c', 'legacy_binary_info.c')) specific_ss.add(files('cpu-target.c', 'arch_info-target.c')) subdir('system')include/qemu/legacy_binary_info.h new file +14
-0@@ -0,0 +1,14 @@ +/* +* QEMU legacy binary helpers +* +* Copyright (c) Linaro +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef QEMU_LEGACY_BINARY_INFO_H +#define QEMU_LEGACY_BINARY_INFO_H + +void legacy_binary_info_init (const char *argv0); + +#endif legacy_binary_info.c new file +160
-0@@ -0,0 +1,160 @@ +/* +* QEMU legacy binary helpers +* +* Copyright (c) Linaro +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "qemu/arch_info.h" +#include "qemu/legacy_binary_info.h" + +typedef struct LegacyBinaryInfo { +const char *binary_name; +QemuArchBit arch_bit; +}LegacyBinaryInfo ; + +/* List alphabetically sorted by binary_name */ +static const LegacyBinaryInfo legacy_binary_infos[] = { + { + .binary_name ="qemu-system-aarch64" , + .arch_bit =QEMU_ARCH_BIT_ARM , + }, + { + .binary_name ="qemu-system-alpha" , + .arch_bit =QEMU_ARCH_BIT_ALPHA , + }, + { + .binary_name ="qemu-system-arm" , + .arch_bit =QEMU_ARCH_BIT_ARM , + }, + { + .binary_name ="qemu-system-avr" , + .arch_bit =QEMU_ARCH_BIT_AVR , + }, + { + .binary_name ="qemu-system-hppa" , + .arch_bit =QEMU_ARCH_BIT_HPPA , + }, + { + .binary_name ="qemu-system-i386" , + .arch_bit =QEMU_ARCH_BIT_I386 , + }, + { + .binary_name ="qemu-system-loongarch64" , + .arch_bit =QEMU_ARCH_BIT_LOONGARCH , + }, + { + .binary_name ="qemu-system-m68k" , + .arch_bit =QEMU_ARCH_BIT_M68K , + }, + { + .binary_name ="qemu-system-microblaze" , + .arch_bit =QEMU_ARCH_BIT_MICROBLAZE , + }, + { + .binary_name ="qemu-system-microblazeel" , + .arch_bit =QEMU_ARCH_BIT_MICROBLAZE , + }, + { + .binary_name ="qemu-system-mips" , + .arch_bit =QEMU_ARCH_BIT_MIPS , + }, + { + .binary_name ="qemu-system-mips64" , + .arch_bit =QEMU_ARCH_BIT_MIPS , + }, + { + .binary_name ="qemu-system-mips64el" , + .arch_bit =QEMU_ARCH_BIT_MIPS , + }, + { + .binary_name ="qemu-system-mipsel" , + .arch_bit =QEMU_ARCH_BIT_MIPS , + }, + { + .binary_name ="qemu-system-or1k" , + .arch_bit =QEMU_ARCH_BIT_OPENRISC , + }, + { + .binary_name ="qemu-system-ppc" , + .arch_bit =QEMU_ARCH_BIT_PPC , + }, + { + .binary_name ="qemu-system-ppc64" , + .arch_bit =QEMU_ARCH_BIT_PPC , + }, + { + .binary_name ="qemu-system-riscv32" , + .arch_bit =QEMU_ARCH_BIT_RISCV , + }, + { + .binary_name ="qemu-system-riscv64" , + .arch_bit =QEMU_ARCH_BIT_RISCV , + }, + { + .binary_name ="qemu-system-rx" , + .arch_bit =QEMU_ARCH_BIT_RX , + }, + { + .binary_name ="qemu-system-s390x" , + .arch_bit =QEMU_ARCH_BIT_S390X , + }, + { + .binary_name ="qemu-system-sh4" , + .arch_bit =QEMU_ARCH_BIT_SH4 , + }, + { + .binary_name ="qemu-system-sh4eb" , + .arch_bit =QEMU_ARCH_BIT_SH4 , + }, + { + .binary_name ="qemu-system-sparc" , + .arch_bit =QEMU_ARCH_BIT_SPARC , + }, + { + .binary_name ="qemu-system-sparc64" , + .arch_bit =QEMU_ARCH_BIT_SPARC , + }, + { + .binary_name ="qemu-system-tricore" , + .arch_bit =QEMU_ARCH_BIT_TRICORE , + }, + { + .binary_name ="qemu-system-x86_64" , + .arch_bit =QEMU_ARCH_BIT_I386 , + }, + { + .binary_name ="qemu-system-xtensa" , + .arch_bit =QEMU_ARCH_BIT_XTENSA , + }, + { + .binary_name ="qemu-system-xtensaeb" , + .arch_bit =QEMU_ARCH_BIT_XTENSA , + }, +}; + +static int current_index =-1 ; + +void legacy_binary_info_init (const char *argv0) +{ +g_auto (GStrv) tokens =g_strsplit (argv0,G_DIR_SEPARATOR_S ,-1 ); +unsigned count =0 ; +const char *binary_name; + +while (tokens[count]) { + count++; + } +assert (count >0 ); + binary_name = tokens[count -1 ]; + +for (size_t i =0 ; i <ARRAY_SIZE (legacy_binary_infos); i++) { +if (!strcmp (legacy_binary_infos[i].binary_name, binary_name)) { + current_index = i; +return ; + } + } +fprintf (stderr,"Missing legacy info for '%s' binary.\n" , binary_name); +abort (); +}system/vl.c +2
-0@@ -28,6 +28,7 @@#include "qemu/units.h" #include "qemu/module.h" #include "qemu/arch_info.h" +#include "qemu/legacy_binary_info.h" #include "exec/cpu-common.h" #include "exec/page-vary.h" #include "hw/qdev-properties.h" @@ -2883,6 +2884,7 @@ void qemu_init(int argc, char **argv)error_init (argv[0 ]);qemu_init_exec_dir (argv[0 ]); +legacy_binary_info_init (argv[0 ]);os_setup_limits ();
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 13 lines · Pierrick Bouvier
Quoted 5 lines · Philippe Mathieu-Daudé
Introduce an API to get information specific to a binary from the binary name (argv[0]).
Initialize it from
qemu_init()on system emulation.What we want here is more a
include/qemu/target_info.h, which will allow to query the name of it, and helper for every architecture:
target_is_aarch64()target_is_ppc64()
...
Quoted 5 lines
Eventually, we can add combined getters like:
target_is_64bit()
...Naming "legacy" something that will be present in the long term is not the best move I think.
FWIW, I agree, this should rather be target_is_64bit() or something similar, like target_words_bigendian() ?
Thomas
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 14 lines · Thomas Huth
Quoted 13 lines · Pierrick Bouvier
Quoted 5 lines · Philippe Mathieu-Daudé
Introduce an API to get information specific to a binary from the binary name (argv[0]).
Initialize it from
qemu_init()on system emulation.What we want here is more a
include/qemu/target_info.h, which will allow to query the name of it, and helper for every architecture:
target_is_aarch64()target_is_ppc64()
...
Quoted 7 lines
Quoted 5 lines
Eventually, we can add combined getters like:
target_is_64bit()
...Naming "legacy" something that will be present in the long term is not the best move I think.
FWIW, I agree, this should rather be
target_is_64bit()or something similar, liketarget_words_bigendian()?
This API is to allow refactoring code for heterogeneous emulation, without changing user-facing behavior of current qemu-system binaries, which I now consider as 'legacy'.
Once all current restrictions removed, the new qemu-system-heterogeneous binary is expected to run any combination of targets.
qemu-system-$target will be a call to qemu-system-heterogeneous with a restricted subset, possibly in the form of:
$ qemu-system-heterogeneous --target aarch64-softmmu
^ equivalent of today's qemu-system-aarch64
If you don't like 'qemu_legacy_binary_' prefix, I can use 'qemu_single_binary_' instead.
target_is_64bit() is misleading, for example in:
$ qemu-system-aarch64 -M zynqmp
we create 64-bit and 32-bit ARM cores.
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 4 lines
This API is to allow refactoring code for heterogeneous emulation, without changing user-facing behavior of current qemu-system binaries, which I now consider as 'legacy'.
Quoted 8 lines
Once all current restrictions removed, the new qemu-system-heterogeneous binary is expected to run any combination of targets.
qemu-system-$target will be a call to qemu-system-heterogeneous with a restricted subset, possibly in the form of:
$ qemu-system-heterogeneous --target aarch64-softmmu
Or just qemu-system I guess.
^ equivalent of today's qemu-system-aarch64
Quoted 4 lines
If you don't like '
qemu_legacy_binary_' prefix, I can use 'qemu_single_binary_' instead.
Still there is a problem with renaming binaries (both the "qemu-kvm" case and the good/bad case that Richard pointed out).
I think you should try creating two versions of system/arch_init.c, so that it has a separate implementation for heterogeneous vs. single-target binaries. Then you can keep separate linking steps for single-target binaries and you naturally get the right target info from either the target-specific arch_init-single.c, or the --target option for arch_init-multi.c.
(Is --target even necessary? As long as you have a way disambiguate same-named machines like -M virt, and have no default machine in the multi-target binary, you shouldn't need it).
target_is_64bit() is misleading, for example in:
Quoted 5 lines
$ qemu-system-aarch64 -M zynqmpwe create 64-bit and 32-bit ARM cores.
Agreed, bit size and endianness should only matter in the CPU code.
Paolo
Quoted 1 line
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 18 lines · Paolo Bonzini
Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 4 lines
This API is to allow refactoring code for heterogeneous emulation, without changing user-facing behavior of current qemu-system binaries, which I now consider as 'legacy'.
Quoted 8 lines
Once all current restrictions removed, the new qemu-system-heterogeneous binary is expected to run any combination of targets.
qemu-system-$target will be a call to qemu-system-heterogeneous with a restricted subset, possibly in the form of:
$ qemu-system-heterogeneous --target aarch64-softmmuOr just qemu-system I guess.
Quoted 8 lines
^ equivalent of today's qemu-system-aarch64
Quoted 4 lines
If you don't like '
qemu_legacy_binary_' prefix, I can use 'qemu_single_binary_' instead.Still there is a problem with renaming binaries (both the "qemu-kvm" case and the good/bad case that Richard pointed out).
We could special case the '-kvm' suffix, because by its nature it implies the current binary build target.
Quoted 11 lines
I think you should try creating two versions of
system/arch_init.c, so that it has a separate implementation for heterogeneous vs. single-target binaries. Then you can keep separate linking steps for single-target binaries and you naturally get the right target info from either the target-specificarch_init-single.c, or the --target option forarch_init-multi.c.(Is --target even necessary? As long as you have a way disambiguate same-named machines like -M virt, and have no default machine in the multi-target binary, you shouldn't need it).
If we did 'query-machines' on qemu-system-heterogeneous, it would return all machines from all targets. To disambiguate naming there are various options
* The query-machines command would have to gain a new 'target' field and we would have to document that uniqness is across the tuple (name, target), not merely name. That's a semantic change.
We would still need a way to express the 'target' when asking to instantiate a machine
* The query-machines command would have to gain a new 'target' paramter so callers can restrict the data they receive back
We would still need a way to express the 'target' when asking to instantiate a machine
* Rename all machine types so they are '<target>-<machine>' The query-machines command doesn't change. Apps would have to "parse" the machine name to see what 'target' each is associated with, or we include an explicit 'target' field in the returned data. Instianting a machine would not need changing
* Require --target CLI arg, meaning query-machines remains unchanged, as does instantiating machines
Any other options ?
The last is the simplest option if we just make --target be defaulted based on the binary name.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 61 lines · Daniel P. Berrangé
Quoted 18 lines · Paolo Bonzini
Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 4 lines
This API is to allow refactoring code for heterogeneous emulation, without changing user-facing behavior of current qemu-system binaries, which I now consider as 'legacy'.
Quoted 8 lines
Once all current restrictions removed, the new qemu-system-heterogeneous binary is expected to run any combination of targets.
qemu-system-$target will be a call to qemu-system-heterogeneous with a restricted subset, possibly in the form of:
$ qemu-system-heterogeneous --target aarch64-softmmuOr just qemu-system I guess.
Quoted 8 lines
^ equivalent of today's qemu-system-aarch64
Quoted 4 lines
If you don't like '
qemu_legacy_binary_' prefix, I can use 'qemu_single_binary_' instead.Still there is a problem with renaming binaries (both the "qemu-kvm" case and the good/bad case that Richard pointed out).
We could special case the '-kvm' suffix, because by its nature it implies the current binary build target.
Quoted 11 lines
I think you should try creating two versions of
system/arch_init.c, so that it has a separate implementation for heterogeneous vs. single-target binaries. Then you can keep separate linking steps for single-target binaries and you naturally get the right target info from either the target-specificarch_init-single.c, or the --target option forarch_init-multi.c.(Is --target even necessary? As long as you have a way disambiguate same-named machines like -M virt, and have no default machine in the multi-target binary, you shouldn't need it).
If we did 'query-machines' on qemu-system-heterogeneous, it would return all machines from all targets. To disambiguate naming there are various options
* The query-machines command would have to gain a new 'target' field and we would have to document that uniqness is across the tuple (name, target), not merely name. That's a semantic change.
We would still need a way to express the 'target' when asking to instantiate a machine
* The query-machines command would have to gain a new 'target' paramter so callers can restrict the data they receive back
We would still need a way to express the 'target' when asking to instantiate a machine
Quoted 6 lines
* Rename all machine types so they are '<target>-<machine>' The query-machines command doesn't change. Apps would have to "parse" the machine name to see what 'target' each is associated with, or we include an explicit 'target' field in the returned data. Instianting a machine would not need changing
I think -machine m68k:virt could work, -M help would list machines like:
arm:raspi
i386:pc
etc.
Management apps could easily find : to separate arch but those that don't care about arch would just work and list more possible machines. Some machines like pc or mac99 that may appear differently in different single arch binary might need to get resolved first. Maybe need a way to search machine list by pattern e.g. as -machine x86_64:help.
I tend to agree with Peter that if a multi binary qemu-system-arm would be able to also create the 64 bit machines that's not a problem as long as all the 32 bit machines still work the same. This would just make qemu-system-arm and qemu-system-aarch64 the same or maybe you can set the search pattern from command name so qemu-system-arm -M help would be the same as qemu-system -M arm:help.
Allowing renaming binaries and still keep single arch behaviour probably needs to keep a way to build single arch binaries so you can't convert everything to runtime check and drop #ifdefs.
Regards,
BALATON Zoltan
Quoted 11 lines
* Require --target CLI arg, meaning query-machines remains unchanged, as does instantiating machines
Any other options ?
The last is the simplest option if we just make --target be defaulted based on the binary name.
With regards,
Daniel
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 75 lines · BALATON Zoltan
Quoted 61 lines · Daniel P. Berrangé
Quoted 18 lines · Paolo Bonzini
Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 4 lines
This API is to allow refactoring code for heterogeneous emulation, without changing user-facing behavior of current qemu-system binaries, which I now consider as 'legacy'.
Quoted 8 lines
Once all current restrictions removed, the new qemu-system-heterogeneous binary is expected to run any combination of targets.
qemu-system-$target will be a call to qemu-system-heterogeneous with a restricted subset, possibly in the form of:
$ qemu-system-heterogeneous --target aarch64-softmmuOr just qemu-system I guess.
Quoted 8 lines
^ equivalent of today's qemu-system-aarch64
Quoted 4 lines
If you don't like '
qemu_legacy_binary_' prefix, I can use 'qemu_single_binary_' instead.Still there is a problem with renaming binaries (both the "qemu-kvm" case and the good/bad case that Richard pointed out).
We could special case the '-kvm' suffix, because by its nature it implies the current binary build target.
Quoted 11 lines
I think you should try creating two versions of
system/arch_init.c, so that it has a separate implementation for heterogeneous vs. single-target binaries. Then you can keep separate linking steps for single-target binaries and you naturally get the right target info from either the target-specificarch_init-single.c, or the --target option forarch_init-multi.c.(Is --target even necessary? As long as you have a way disambiguate same-named machines like -M virt, and have no default machine in the multi-target binary, you shouldn't need it).
If we did 'query-machines' on qemu-system-heterogeneous, it would return all machines from all targets. To disambiguate naming there are various options
* The query-machines command would have to gain a new 'target' field and we would have to document that uniqness is across the tuple (name, target), not merely name. That's a semantic change.
We would still need a way to express the 'target' when asking to instantiate a machine
* The query-machines command would have to gain a new 'target' paramter so callers can restrict the data they receive back
We would still need a way to express the 'target' when asking to instantiate a machine
Quoted 6 lines
* Rename all machine types so they are '<target>-<machine>' The query-machines command doesn't change. Apps would have to "parse" the machine name to see what 'target' each is associated with, or we include an explicit 'target' field in the returned data. Instianting a machine would not need changing
I think -machine m68k:virt could work, -M help would list machines like:
arm:raspi
i386:pc
etc.
Quoted 5 lines
Management apps could easily find : to separate arch but those that don't care about arch would just work and list more possible machines. Some machines like pc or mac99 that may appear differently in different single arch binary might need to get resolved first. Maybe need a way to search machine list by pattern e.g. as -machine x86_64:help.
...except that custom structures/formats in command line args is something we've tried very hard to eliminate in Qemu, and instead model everything as a distinct fields, using QAPI, so...
.. if you're meaning "arm:raspi" as a short hand for "target:machine"
that would be a design anti-pattern, b
...if you're meaning that "arm:raspi" is the full machine name, to be
strictly treated as an opaque string that would be acceptable.
I rather think the latter would not end up being treated as an opaque string though - the tempetation to parse it & assign semantics to the pieces is just too great. So I'm not a fan of that approach.
From a QAPI design best pratice POV, the requirement would be for
-machine target=arm,name=raspi
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 92 lines · Daniel P. Berrangé
Quoted 75 lines · BALATON Zoltan
Quoted 61 lines · Daniel P. Berrangé
Quoted 18 lines · Paolo Bonzini
Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 4 lines
This API is to allow refactoring code for heterogeneous emulation, without changing user-facing behavior of current qemu-system binaries, which I now consider as 'legacy'.
Quoted 8 lines
Once all current restrictions removed, the new qemu-system-heterogeneous binary is expected to run any combination of targets.
qemu-system-$target will be a call to qemu-system-heterogeneous with a restricted subset, possibly in the form of:
$ qemu-system-heterogeneous --target aarch64-softmmuOr just qemu-system I guess.
Quoted 8 lines
^ equivalent of today's qemu-system-aarch64
Quoted 4 lines
If you don't like '
qemu_legacy_binary_' prefix, I can use 'qemu_single_binary_' instead.Still there is a problem with renaming binaries (both the "qemu-kvm" case and the good/bad case that Richard pointed out).
We could special case the '-kvm' suffix, because by its nature it implies the current binary build target.
Quoted 11 lines
I think you should try creating two versions of
system/arch_init.c, so that it has a separate implementation for heterogeneous vs. single-target binaries. Then you can keep separate linking steps for single-target binaries and you naturally get the right target info from either the target-specificarch_init-single.c, or the --target option forarch_init-multi.c.(Is --target even necessary? As long as you have a way disambiguate same-named machines like -M virt, and have no default machine in the multi-target binary, you shouldn't need it).
If we did 'query-machines' on qemu-system-heterogeneous, it would return all machines from all targets. To disambiguate naming there are various options
* The query-machines command would have to gain a new 'target' field and we would have to document that uniqness is across the tuple (name, target), not merely name. That's a semantic change.
We would still need a way to express the 'target' when asking to instantiate a machine
* The query-machines command would have to gain a new 'target' paramter so callers can restrict the data they receive back
We would still need a way to express the 'target' when asking to instantiate a machine
Quoted 6 lines
* Rename all machine types so they are '<target>-<machine>' The query-machines command doesn't change. Apps would have to "parse" the machine name to see what 'target' each is associated with, or we include an explicit 'target' field in the returned data. Instianting a machine would not need changing
I think -machine m68k:virt could work, -M help would list machines like:
arm:raspi
i386:pc
etc.Quoted 5 lines
Management apps could easily find : to separate arch but those that don't care about arch would just work and list more possible machines. Some machines like pc or mac99 that may appear differently in different single arch binary might need to get resolved first. Maybe need a way to search machine list by pattern e.g. as -machine x86_64:help.
...except that custom structures/formats in command line args is something we've tried very hard to eliminate in Qemu, and instead model everything as a distinct fields, using QAPI, so...
.. if you're meaning "arm:raspi" as a short hand for "target:machine"
that would be a design anti-pattern, b...if you're meaning that "arm:raspi" is the full machine name, to be
strictly treated as an opaque string that would be acceptable.
Quoted 7 lines
I rather think the latter would not end up being treated as an opaque string though - the tempetation to parse it & assign semantics to the pieces is just too great. So I'm not a fan of that approach.
From a QAPI design best pratice POV, the requirement would be for
-machine target=arm,name=raspi
As long as I don't have to type that and can use -M arm:raspi as a shorthand that's OK but then we could just make an exception for this and combine target and machine name here for simplicity. Unless it's simpler to internally use separate name and target attributes and implement a command line shorthand. You'll also need a way to display machine list with target and name in a way that's easy to parse for tools for which the target:name format seems like a trivial way. So I don't mind how you rationalise it and call all of it the machine name or if it's implemented as separate name and target attributes but please try to keep the command line something a human can use too.
Regards,
BALATON Zoltan
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 101 lines · BALATON Zoltan
Quoted 92 lines · Daniel P. Berrangé
Quoted 75 lines · BALATON Zoltan
Quoted 61 lines · Daniel P. Berrangé
Quoted 18 lines · Paolo Bonzini
Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 4 lines
This API is to allow refactoring code for heterogeneous emulation, without changing user-facing behavior of current qemu-system binaries, which I now consider as 'legacy'.
Quoted 8 lines
Once all current restrictions removed, the new qemu-system-heterogeneous binary is expected to run any combination of targets.
qemu-system-$target will be a call to qemu-system-heterogeneous with a restricted subset, possibly in the form of:
$ qemu-system-heterogeneous --target aarch64-softmmuOr just qemu-system I guess.
Quoted 8 lines
^ equivalent of today's qemu-system-aarch64
Quoted 4 lines
If you don't like '
qemu_legacy_binary_' prefix, I can use 'qemu_single_binary_' instead.Still there is a problem with renaming binaries (both the "qemu-kvm" case and the good/bad case that Richard pointed out).
We could special case the '-kvm' suffix, because by its nature it implies the current binary build target.
Quoted 11 lines
I think you should try creating two versions of
system/arch_init.c, so that it has a separate implementation for heterogeneous vs. single-target binaries. Then you can keep separate linking steps for single-target binaries and you naturally get the right target info from either the target-specificarch_init-single.c, or the --target option forarch_init-multi.c.(Is --target even necessary? As long as you have a way disambiguate same-named machines like -M virt, and have no default machine in the multi-target binary, you shouldn't need it).
If we did 'query-machines' on qemu-system-heterogeneous, it would return all machines from all targets. To disambiguate naming there are various options
* The query-machines command would have to gain a new 'target' field and we would have to document that uniqness is across the tuple (name, target), not merely name. That's a semantic change.
We would still need a way to express the 'target' when asking to instantiate a machine
* The query-machines command would have to gain a new 'target' paramter so callers can restrict the data they receive back
We would still need a way to express the 'target' when asking to instantiate a machine
Quoted 6 lines
* Rename all machine types so they are '<target>-<machine>' The query-machines command doesn't change. Apps would have to "parse" the machine name to see what 'target' each is associated with, or we include an explicit 'target' field in the returned data. Instianting a machine would not need changing
I think -machine m68k:virt could work, -M help would list machines like:
arm:raspi
i386:pc
etc.Quoted 5 lines
Management apps could easily find : to separate arch but those that don't care about arch would just work and list more possible machines. Some machines like pc or mac99 that may appear differently in different single arch binary might need to get resolved first. Maybe need a way to search machine list by pattern e.g. as -machine x86_64:help.
...except that custom structures/formats in command line args is something we've tried very hard to eliminate in Qemu, and instead model everything as a distinct fields, using QAPI, so...
.. if you're meaning "arm:raspi" as a short hand for "target:machine"
that would be a design anti-pattern, b...if you're meaning that "arm:raspi" is the full machine name, to be
strictly treated as an opaque string that would be acceptable.Quoted 7 lines
I rather think the latter would not end up being treated as an opaque string though - the tempetation to parse it & assign semantics to the pieces is just too great. So I'm not a fan of that approach.
From a QAPI design best pratice POV, the requirement would be for
-machine target=arm,name=raspi
Quoted 11 lines
As long as I don't have to type that and can use -M arm:raspi as a shorthand that's OK but then we could just make an exception for this and combine target and machine name here for simplicity. Unless it's simpler to internally use separate name and target attributes and implement a command line shorthand. You'll also need a way to display machine list with target and name in a way that's easy to parse for tools for which the target:name format seems like a trivial way. So I don't mind how you rationalise it and call all of it the machine name or if it's implemented as separate name and target attributes but please try to keep the command line something a human can use too.
Mentioning heterogeneous emulation (i.e., running various cpu architectures concurrently in the same process) is an interesting topic, but it's way far beyond the scope of current series, I feel that everyone starts to get lost a bit here.
Creating a single binary combining all existing QEMU architectures should *not* have any impact on the existing cli. It's just a code reorganisation, without any user visible change. Please notice it's just a single binary, not something introducing heterogeneous emulation.
A missing piece in this series is a new driver (i.e. a new main()) forwarding (argc, argv) to the correct entry point, and adding an option '--target' to allow people to override or disambiguate the automatically detected target. This detection will be based on symlink name used to invoke the binary. For the binary itself, why not simply call it: ./qemu, or ./qemu-system (if the scope is only system emulation).
To come back to heterogeneous topic, even though we can be sure everyone will have an opinion on the command line interface for that, I'm not sure this is the first question we should answer. There are more important technical questions and refactorings to solve, before even thinking about how to use it.
A simple and good first step could be to have a "magical" board combining different processing units having different architectures. Having this will already imply to tackle a lot of technical issues. Then, maybe, it will be productive to debate about what the command line interface should look like to have something generic. Maybe it's not even something we'll need.
Regards,
Pierrick
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 114 lines · Pierrick Bouvier
Quoted 101 lines · BALATON Zoltan
Quoted 92 lines · Daniel P. Berrangé
Quoted 75 lines · BALATON Zoltan
Quoted 61 lines · Daniel P. Berrangé
Quoted 18 lines · Paolo Bonzini
Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 4 lines
This API is to allow refactoring code for heterogeneous emulation, without changing user-facing behavior of current qemu-system binaries, which I now consider as 'legacy'.
Quoted 8 lines
Once all current restrictions removed, the new qemu-system-heterogeneous binary is expected to run any combination of targets.
qemu-system-$target will be a call to qemu-system-heterogeneous with a restricted subset, possibly in the form of:
$ qemu-system-heterogeneous --target aarch64-softmmuOr just qemu-system I guess.
Quoted 8 lines
^ equivalent of today's qemu-system-aarch64
Quoted 4 lines
If you don't like '
qemu_legacy_binary_' prefix, I can use 'qemu_single_binary_' instead.Still there is a problem with renaming binaries (both the "qemu-kvm" case and the good/bad case that Richard pointed out).
We could special case the '-kvm' suffix, because by its nature it implies the current binary build target.
Quoted 11 lines
I think you should try creating two versions of
system/arch_init.c, so that it has a separate implementation for heterogeneous vs. single-target binaries. Then you can keep separate linking steps for single-target binaries and you naturally get the right target info from either the target-specificarch_init-single.c, or the --target option forarch_init-multi.c.(Is --target even necessary? As long as you have a way disambiguate same-named machines like -M virt, and have no default machine in the multi-target binary, you shouldn't need it).
If we did 'query-machines' on qemu-system-heterogeneous, it would return all machines from all targets. To disambiguate naming there are various options
* The query-machines command would have to gain a new 'target' field and we would have to document that uniqness is across the tuple (name, target), not merely name. That's a semantic change.
We would still need a way to express the 'target' when asking to instantiate a machine
* The query-machines command would have to gain a new 'target' paramter so callers can restrict the data they receive back
We would still need a way to express the 'target' when asking to instantiate a machine
Quoted 6 lines
* Rename all machine types so they are '<target>-<machine>' The query-machines command doesn't change. Apps would have to "parse" the machine name to see what 'target' each is associated with, or we include an explicit 'target' field in the returned data. Instianting a machine would not need changing
I think -machine m68k:virt could work, -M help would list machines like:
arm:raspi
i386:pc
etc.Quoted 5 lines
Management apps could easily find : to separate arch but those that don't care about arch would just work and list more possible machines. Some machines like pc or mac99 that may appear differently in different single arch binary might need to get resolved first. Maybe need a way to search machine list by pattern e.g. as -machine x86_64:help.
...except that custom structures/formats in command line args is something we've tried very hard to eliminate in Qemu, and instead model everything as a distinct fields, using QAPI, so...
.. if you're meaning "arm:raspi" as a short hand for "target:machine"
that would be a design anti-pattern, b...if you're meaning that "arm:raspi" is the full machine name, to be
strictly treated as an opaque string that would be acceptable.Quoted 7 lines
I rather think the latter would not end up being treated as an opaque string though - the tempetation to parse it & assign semantics to the pieces is just too great. So I'm not a fan of that approach.
From a QAPI design best pratice POV, the requirement would be for
-machine target=arm,name=raspi
Quoted 11 lines
As long as I don't have to type that and can use -M arm:raspi as a shorthand that's OK but then we could just make an exception for this and combine target and machine name here for simplicity. Unless it's simpler to internally use separate name and target attributes and implement a command line shorthand. You'll also need a way to display machine list with target and name in a way that's easy to parse for tools for which the target:name format seems like a trivial way. So I don't mind how you rationalise it and call all of it the machine name or if it's implemented as separate name and target attributes but please try to keep the command line something a human can use too.
Quoted 1 line
Mentioning heterogeneous emulation (i.e., running various cpu architectures concurrently in the same process) is an interesting topic, but it's way far beyond the scope of current series, I feel that everyone starts to get lost a bit here.
The above wasn't about heterogenous emulation but about single binary. That still needs a way to select the machine to emulate.
Quoted 3 lines
Creating a single binary combining all existing QEMU architectures should *not* have any impact on the existing cli. It's just a code reorganisation, without any user visible change. Please notice it's just a single binary, not something introducing heterogeneous emulation.
A missing piece in this series is a new driver (i.e. a new
main()) forwarding (argc, argv) to the correct entry point, and adding an option '--target' to allow people to override or disambiguate the automatically detected target.
So it would have impact on existing CLI as it needs introducing at least one new option. Please note QEMU options are single dash so this could be -target or -T for short then one could do qemu-system -T arm -M raspi. This is another possible CLI for this. For machines that only exist in one arch the target option may not be needed.
Quoted 1 line
This detection will be based on symlink name used to invoke the binary. For the binary itself, why not simply call it: ./qemu, or ./qemu-system (if the scope is only system emulation).
This might not work if people want to rename the symlinked name although checking only the prefix could solve that.
Quoted 1 line
To come back to heterogeneous topic, even though we can be sure everyone will have an opinion on the command line interface for that, I'm not sure this is the first question we should answer. There are more important technical questions and refactorings to solve, before even thinking about how to use it.
We haven't discussed heterogenous emulation yet and what exact command line syntax to use can wait but discussing what command line option is needed and how to represent it might influence how the internal implementation will be or how easy it will be to implement such command line so it's good to consider that now as it may influence the design. You'll need to store target somewhere so the command line can list it or select it so deciding if it should be an Object property or Machine or Device property might also have impact on the possible command line syntax and vice versa so maybe it's not something you can totally ignore.
Quoted 1 line
A simple and good first step could be to have a "magical" board combining different processing units having different architectures. Having this will already imply to tackle a lot of technical issues. Then, maybe, it will be productive to debate about what the command line interface should look like to have something generic. Maybe it's not even something we'll need.
This isn't something that was discussed above and I agree it's not something to discuss yet.
Regards,
BALATON Zoltan
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
In reply to Philippe Mathieu-DaudéIl mer 5 mar 2025, 16:39 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 9 lines
legacy_binary_info.c new file +7
-0+for (size_t i =0 ; i <ARRAY_SIZE (legacy_binary_infos); i++) { +if (!strcmp (legacy_binary_infos[i].binary_name, binary_name)) { + current_index = i; +return ; + } + } + fprintf(stderr, "Missing legacy info for '%s' binary.\n",
binary_name);
Wouldn't this crash if a binary is renamed to qemu-kvm or anything else but its original name? There should be a default target in the binary, and this function should only be called it there's none; but it should also use the normal Error** interface instead of aborting.
Also do not call things legacy, as Pierrick also said and explained.
Paolo
+ abort();
Quoted 25 lines
(quoted diff) +1
-0+}system/vl.c +2
-1@@ -28,6 +28,7 @@#include "qemu/units.h" #include "qemu/module.h" #include "qemu/arch_info.h" +#include "qemu/legacy_binary_info.h" #include "exec/cpu-common.h" #include "exec/page-vary.h" #include "hw/qdev-properties.h" @@ -2883,6 +2884,7 @@ void qemu_init(int argc, char **argv)error_init (argv[0 ]);qemu_init_exec_dir (argv[0 ]); +legacy_binary_info_init (argv[0 ]);os_setup_limits (); --2.47.1
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
In reply to Philippe Mathieu-Daudélegacy_binary_info.c line 150
Quoted 11 lines · Philippe Mathieu-Daudé
legacy_binary_info.c new file +11
-0+void legacy_binary_info_init (const char *argv0) +{ +g_auto (GStrv) tokens =g_strsplit (argv0,G_DIR_SEPARATOR_S ,-1 ); +unsigned count =0 ; +const char *binary_name; + +while (tokens[count]) { + count++; + } +assert (count >0 ); + binary_name = tokens[count -1 ];
This is g_path_get_basename().
legacy_binary_info.c line 160
Quoted 10 lines
legacy_binary_info.c new file +10
-0+ +for (size_t i =0 ; i <ARRAY_SIZE (legacy_binary_infos); i++) { +if (!strcmp (legacy_binary_infos[i].binary_name, binary_name)) { + current_index = i; +return ; + } + } +fprintf (stderr,"Missing legacy info for '%s' binary.\n" , binary_name); +abort (); +}
I'm with Paolo that this should not abort here; Error is better. Even if the caller supplies error_fatal.
When testing for errors before and after a patch, I often rename the binary, e.g. qemu-system-aarch64-good / qemu-system-aarch64-bad. Leaving it in the same build directory is required in order to let it find the uninstalled rom images.
Is there a way we can preserve something akin to this?
Do we need to add the -target command-line option that Pierrick mooted?
r~
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 29 lines · Richard Henderson
legacy_binary_info.c line 150
Quoted 11 lines · Philippe Mathieu-Daudé
legacy_binary_info.c new file +11
-0+void legacy_binary_info_init (const char *argv0) +{ +g_auto (GStrv) tokens =g_strsplit (argv0,G_DIR_SEPARATOR_S ,-1 ); +unsigned count =0 ; +const char *binary_name; + +while (tokens[count]) { + count++; + } +assert (count >0 ); + binary_name = tokens[count -1 ];This is
g_path_get_basename().legacy_binary_info.c line 160
Quoted 10 lines
legacy_binary_info.c new file +10
-0+ +for (size_t i =0 ; i <ARRAY_SIZE (legacy_binary_infos); i++) { +if (!strcmp (legacy_binary_infos[i].binary_name, binary_name)) { + current_index = i; +return ; + } + } +fprintf (stderr,"Missing legacy info for '%s' binary.\n" , binary_name); +abort (); +}I'm with Paolo that this should not abort here; Error is better. Even if the caller supplies
error_fatal.
Quoted 6 lines
When testing for errors before and after a patch, I often rename the binary, e.g. qemu-system-aarch64-good / qemu-system-aarch64-bad. Leaving it in the same build directory is required in order to let it find the uninstalled rom images.
Is there a way we can preserve something akin to this?
Replacign !strcmp with g_str_has_prefix in the above code would be an simple option to preseve the use of custom suffixes, along with special casing on existence of 'kvm' in the name.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
In reply to Richard HendersonCc'ing Markus.
Quoted 13 lines · Richard Henderson
legacy_binary_info.c line 157
Quoted 10 lines · Philippe Mathieu-Daudé
legacy_binary_info.c new file +8
-0+void legacy_binary_info_init (const char *argv0) +{ + for (size_t i = 0; i < ARRAY_SIZE(legacy_binary_infos); i++) { + if (!strcmp(legacy_binary_infos[i].binary_name, binary_name)) { + current_index = i; + return; + } + }
Quoted 2 lines
When testing for errors before and after a patch, I often rename the binary, e.g. qemu-system-aarch64-good / qemu-system-aarch64-bad.
I'd not qemu-system-microblazeel-good to match qemu-system-microblaze.
Quoted 5 lines
Leaving it in the same build directory is required in order to let it find the uninstalled rom images.
Is there a way we can preserve something akin to this?
Do we need to add the -target command-line option that Pierrick mooted?
Not that easy, CLI is evaluated *after* QOM types are registered. IIUC we'd need to add this as a -preconfig option, Markus is that right?
Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
Quoted 16 lines · Philippe Mathieu-Daudé
Cc'ing Markus.
Quoted 11 lines · Richard Henderson
Quoted 10 lines · Philippe Mathieu-Daudé
legacy_binary_info.c new file +8
-0+void legacy_binary_info_init (const char *argv0) +{ + for (size_t i = 0; i < ARRAY_SIZE(legacy_binary_infos); i++) { + if (!strcmp(legacy_binary_infos[i].binary_name, binary_name)) { + current_index = i; + return; + } + }
Quoted 9 lines
Quoted 2 lines
When testing for errors before and after a patch, I often rename the binary, e.g. qemu-system-aarch64-good / qemu-system-aarch64-bad.
I'd not qemu-system-microblazeel-good to match qemu-system-microblaze.
Quoted 4 lines
Leaving it in the same build directory is required in order to let it find the uninstalled rom images.
Is there a way we can preserve something akin to this?
Do we need to add the -target command-line option that Pierrick mooted?
Having behavior depend on the binary name is problematic. When users run it with some other name (renamed binary, link to binary), behavior changes, which is generally not desired and may be quite confusing.
I guess you want to do it here to replace multiple binaries by a single one with several names. Correct?
The stupid solution is to configure the single binary's behavior the non-clever way with command line options such as -target, then provide compatibility wrappers that run the single binary with suitable options.
Drawback: wrappers are slow, ugly, and can also be confusing. Say when you rename just the wrapper to -good and -bad.
If we want to go with behavior depending on the binary name, we could try to reduce confusion by making unorthodox names fail cleanly. Say make -target optional only when the binary name matches exactly.
Quoted 2 lines
Not that easy, CLI is evaluated *after* QOM types are registered. IIUC we'd need to add this as a -preconfig option, Markus is that right?
Ah, the startup mess. I don't remember a thing. Except for the need to have QMP up and running before any non-trivial startup. To get that, the command line needs to be processed this early, too.
-preconfig is a disgusting hack to delay parts of startup until it's explicitly triggered in the monitor. Not a general solution for "need to configurate more before startup", and not sure it helps here.
RFC PATCH 5/18 qemu: Introduce legacy_binary_is_64bit() helper
In reply to Philippe Mathieu-DaudéIntroduce legacy_binary_is_64bit() to check at runtime if a binary is compiled with TARGET_LONG_BITS == 64.
--- include/qemu/legacy_binary_info.h | 3 +++ legacy_binary_info.c | 37 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
include/qemu/legacy_binary_info.h +3 -0
@@ -11,4 +11,7 @@void legacy_binary_info_init (const char *argv0); +/* Return runtime equivalent of TARGET_LONG_BITS == 64 check */ +bool legacy_binary_is_64bit (void ); +#endif
legacy_binary_info.c +37 -0
@@ -13,6 +13,7 @@typedef struct LegacyBinaryInfo {const char *binary_name;QemuArchBit arch_bit; +unsigned long_bits; }LegacyBinaryInfo ;/* List alphabetically sorted by binary_name */
@@ -20,118 +21,147 @@ static const LegacyBinaryInfo legacy_binary_infos[] = { { .binary_name = "qemu-system-aarch64", .arch_bit = QEMU_ARCH_BIT_ARM, + .long_bits = 64, }, { .binary_name = "qemu-system-alpha", .arch_bit = QEMU_ARCH_BIT_ALPHA, + .long_bits = 64, }, { .binary_name = "qemu-system-arm", .arch_bit = QEMU_ARCH_BIT_ARM, + .long_bits = 32, }, { .binary_name = "qemu-system-avr", .arch_bit = QEMU_ARCH_BIT_AVR, + .long_bits = 32, }, { .binary_name = "qemu-system-hppa", .arch_bit = QEMU_ARCH_BIT_HPPA, + .long_bits = 64, }, { .binary_name = "qemu-system-i386", .arch_bit = QEMU_ARCH_BIT_I386, + .long_bits = 32, }, { .binary_name = "qemu-system-loongarch64", .arch_bit = QEMU_ARCH_BIT_LOONGARCH, + .long_bits = 64, }, { .binary_name = "qemu-system-m68k", .arch_bit = QEMU_ARCH_BIT_M68K, + .long_bits = 32, }, { .binary_name = "qemu-system-microblaze", .arch_bit = QEMU_ARCH_BIT_MICROBLAZE, + .long_bits = 64, }, { .binary_name = "qemu-system-microblazeel", .arch_bit = QEMU_ARCH_BIT_MICROBLAZE, + .long_bits = 64, }, { .binary_name = "qemu-system-mips", .arch_bit = QEMU_ARCH_BIT_MIPS, + .long_bits = 64, }, { .binary_name = "qemu-system-mips64", .arch_bit = QEMU_ARCH_BIT_MIPS, + .long_bits = 64, }, { .binary_name = "qemu-system-mips64el", .arch_bit = QEMU_ARCH_BIT_MIPS, + .long_bits = 64, }, { .binary_name = "qemu-system-mipsel", .arch_bit = QEMU_ARCH_BIT_MIPS, + .long_bits = 32, }, { .binary_name = "qemu-system-or1k", .arch_bit = QEMU_ARCH_BIT_OPENRISC, + .long_bits = 32, }, { .binary_name = "qemu-system-ppc", .arch_bit = QEMU_ARCH_BIT_PPC, + .long_bits = 32, }, { .binary_name = "qemu-system-ppc64", .arch_bit = QEMU_ARCH_BIT_PPC, + .long_bits = 64, }, { .binary_name = "qemu-system-riscv32", .arch_bit = QEMU_ARCH_BIT_RISCV, + .long_bits = 32, }, { .binary_name = "qemu-system-riscv64", .arch_bit = QEMU_ARCH_BIT_RISCV, + .long_bits = 64, }, { .binary_name = "qemu-system-rx", .arch_bit = QEMU_ARCH_BIT_RX, + .long_bits = 32, }, { .binary_name = "qemu-system-s390x", .arch_bit = QEMU_ARCH_BIT_S390X, + .long_bits = 64, }, { .binary_name = "qemu-system-sh4", .arch_bit = QEMU_ARCH_BIT_SH4, + .long_bits = 32, }, { .binary_name = "qemu-system-sh4eb", .arch_bit = QEMU_ARCH_BIT_SH4, + .long_bits = 32, }, { .binary_name = "qemu-system-sparc", .arch_bit = QEMU_ARCH_BIT_SPARC, + .long_bits = 32, }, { .binary_name = "qemu-system-sparc64", .arch_bit = QEMU_ARCH_BIT_SPARC, + .long_bits = 64, }, { .binary_name = "qemu-system-tricore", .arch_bit = QEMU_ARCH_BIT_TRICORE, + .long_bits = 32, }, { .binary_name = "qemu-system-x86_64", .arch_bit = QEMU_ARCH_BIT_I386, + .long_bits = 64, }, { .binary_name = "qemu-system-xtensa", .arch_bit = QEMU_ARCH_BIT_XTENSA, + .long_bits = 32, }, { .binary_name = "qemu-system-xtensaeb", .arch_bit = QEMU_ARCH_BIT_XTENSA, + .long_bits = 32, }, };
@@ -151,6 +181,7 @@ void legacy_binary_info_init(const char *argv0)for (size_t i =0 ; i <ARRAY_SIZE (legacy_binary_infos); i++) {if (!strcmp (legacy_binary_infos[i].binary_name, binary_name)) { +assert (legacy_binary_infos[i].long_bits); current_index = i;return ; }
@@ -158,3 +189,9 @@ void legacy_binary_info_init(const char *argv0)fprintf (stderr,"Missing legacy info for '%s' binary.\n" , binary_name);abort (); } + +bool legacy_binary_is_64bit (void ) +{ +assert (current_index !=-1 ); +return legacy_binary_infos[current_index].long_bits ==64 ; +}
Signature · 1 line
2.47.1
RFC PATCH 6/18 hw/mips/mipssim: Replace TARGET_MIPS64 by legacy_binary_is_64bit()
In reply to Philippe Mathieu-DaudéFor legacy MIPS binaries, legacy_binary_is_64bit() is equivalent of the compile time TARGET_MIPS64 definition.
--- hw/mips/mipssim.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
hw/mips/mipssim.c +5 -10
@@ -28,6 +28,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/datadir.h" +#include "qemu/legacy_binary_info.h" #include "exec/address-spaces.h" #include "hw/clock.h" #include "hw/mips/mips.h"
@@ -152,13 +153,10 @@ mips_mipssim_init(MachineState *machine)CPUMIPSState *env;ResetData *reset_info;int bios_size; +unsigned clock_hz = (legacy_binary_is_64bit () ?6 :12 ) *1000 *1000 ; cpuclk =clock_new (OBJECT (machine),"cpu-refclk" ); -#ifdef TARGET_MIPS64 -clock_set_hz (cpuclk,6000000 );/* 6 MHz */ -#else -clock_set_hz (cpuclk,12000000 );/* 12 MHz */ -#endif +clock_set_hz (cpuclk, clock_hz);/* Init CPUs. */ cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk,
@@ -241,11 +239,8 @@ static void mips_mipssim_machine_init(MachineClass *mc) { mc->desc ="MIPS MIPSsim platform" ; mc->init = mips_mipssim_init; -#ifdef TARGET_MIPS64 - mc->default_cpu_type =MIPS_CPU_TYPE_NAME ("5Kf" ); -#else - mc->default_cpu_type =MIPS_CPU_TYPE_NAME ("24Kf" ); -#endif + mc->default_cpu_type =legacy_binary_is_64bit () ?MIPS_CPU_TYPE_NAME ("5Kf" ) + :MIPS_CPU_TYPE_NAME ("24Kf" ); mc->default_ram_id ="mips_mipssim.ram" ; }
Signature · 1 line
2.47.1
RFC PATCH 7/18 hw/mips/malta: Replace TARGET_MIPS64 by legacy_binary_is_64bit()
In reply to Philippe Mathieu-DaudéFor legacy MIPS binaries, legacy_binary_is_64bit() is equivalent of the compile time TARGET_MIPS64 definition.
--- hw/mips/malta.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
hw/mips/malta.c +3 -5
@@ -26,6 +26,7 @@#include "qemu/units.h" #include "qemu/bitops.h" #include "qemu/datadir.h" +#include "qemu/legacy_binary_info.h" #include "qemu/cutils.h" #include "qemu/guest-random.h" #include "exec/tswap.h"
@@ -1300,11 +1301,8 @@ static void mips_malta_machine_init(MachineClass *mc) mc->block_default_type =IF_IDE ; mc->max_cpus =16 ; mc->is_default = true; -#ifdef TARGET_MIPS64 - mc->default_cpu_type =MIPS_CPU_TYPE_NAME ("20Kc" ); -#else - mc->default_cpu_type =MIPS_CPU_TYPE_NAME ("24Kf" ); -#endif + mc->default_cpu_type =legacy_binary_is_64bit () ?MIPS_CPU_TYPE_NAME ("20Kc" ) + :MIPS_CPU_TYPE_NAME ("24Kf" ); mc->default_ram_id ="mips_malta.ram" ;compat_props_add (mc->compat_props, malta_compat, malta_compat_len); }
Signature · 1 line
2.47.1
RFC PATCH 8/18 hw/i386: Inline TARGET_DEFAULT_CPU_TYPE definition
In reply to Philippe Mathieu-DaudéFor legacy x86 binaries, legacy_binary_is_64bit() is equivalent of the compile time TARGET_X86_64 definition. Use it in place in machine class_init() handlers, removing the need on TARGET_X86_64.
--- target/i386/cpu.h | 6 ------ hw/i386/microvm.c | 5 ++++- hw/i386/pc.c | 5 ++++- hw/i386/xen/xen-pvh.c | 5 ++++- 4 files changed, 12 insertions(+), 9 deletions(-)
target/i386/cpu.h +0 -6
@@ -2555,12 +2555,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);#define CPU_RESOLVING_TYPE TYPE_X86_CPU -#ifdef TARGET_X86_64 -#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu64") -#else -#define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu32") -#endif -#define cpu_list x86_cpu_list/* MMU modes definitions */
hw/i386/microvm.c +4 -1
@@ -19,6 +19,7 @@#include "qemu/error-report.h" #include "qemu/cutils.h" #include "qemu/units.h" +#include "qemu/legacy_binary_info.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "qapi/qapi-visit-common.h"
@@ -654,7 +655,9 @@ static void microvm_class_init(ObjectClass *oc, void *data) mc->has_hotpluggable_cpus = false; mc->auto_enable_numa_with_memhp = false; mc->auto_enable_numa_with_memdev = false; - mc->default_cpu_type =TARGET_DEFAULT_CPU_TYPE ; + mc->default_cpu_type =legacy_binary_is_64bit () + ?X86_CPU_TYPE_NAME ("qemu64" ) + :X86_CPU_TYPE_NAME ("qemu32" ); mc->nvdimm_supported = false; mc->default_ram_id ="microvm.ram" ;
hw/i386/pc.c +4 -1
@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/legacy_binary_info.h" #include "hw/i386/pc.h" #include "hw/char/serial-isa.h" #include "hw/char/parallel.h"
@@ -1794,7 +1795,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) hc->plug = pc_machine_device_plug_cb; hc->unplug_request = pc_machine_device_unplug_request_cb; hc->unplug = pc_machine_device_unplug_cb; - mc->default_cpu_type =TARGET_DEFAULT_CPU_TYPE ; + mc->default_cpu_type =legacy_binary_is_64bit () + ?X86_CPU_TYPE_NAME ("qemu64" ) + :X86_CPU_TYPE_NAME ("qemu32" ); mc->nvdimm_supported = true; mc->smp_props.dies_supported = true; mc->smp_props.modules_supported = true;
hw/i386/xen/xen-pvh.c +4 -1
@@ -8,6 +8,7 @@*/ #include "qemu/osdep.h" +#include "qemu/legacy_binary_info.h" #include "qemu/error-report.h" #include "hw/boards.h" #include "system/system.h"
@@ -81,7 +82,9 @@ static void xen_pvh_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="Xen PVH x86 machine" ; - mc->default_cpu_type =TARGET_DEFAULT_CPU_TYPE ; + mc->default_cpu_type =legacy_binary_is_64bit () + ?X86_CPU_TYPE_NAME ("qemu64" ) + :X86_CPU_TYPE_NAME ("qemu32" );/* mc->max_cpus holds the MAX value allowed in the -smp cmd-line opts. */ mc->max_cpus =HVM_MAX_VCPUS ;
Signature · 1 line
2.47.1
RFC PATCH 9/18 hw/ppc/mac: Replace TARGET_PPC64 by legacy_binary_is_64bit()
In reply to Philippe Mathieu-DaudéFor legacy PowerPC binaries, legacy_binary_is_64bit() is equivalent of the compile time TARGET_PPC64 definition.
--- hw/ppc/mac_newworld.c | 9 ++++----- hw/ppc/mac_oldworld.c | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-)
hw/ppc/mac_newworld.c +4 -5
@@ -49,6 +49,7 @@#include "qemu/osdep.h" #include "qemu/datadir.h" #include "qemu/units.h" +#include "qemu/legacy_binary_info.h" #include "qapi/error.h" #include "hw/ppc/ppc.h" #include "hw/qdev-properties.h"
@@ -581,11 +582,9 @@ static void core99_machine_class_init(ObjectClass *oc, void *data) mc->default_display ="std" ; mc->default_nic ="sungem" ; mc->kvm_type = core99_kvm_type; -#ifdef TARGET_PPC64 - mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("970fx_v3.1" ); -#else - mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("7400_v2.9" ); -#endif + mc->default_cpu_type =legacy_binary_is_64bit () + ?POWERPC_CPU_TYPE_NAME ("970fx_v3.1" ) + :POWERPC_CPU_TYPE_NAME ("7400_v2.9" ); mc->default_ram_id ="ppc_core99.ram" ; mc->ignore_boot_device_suffixes = true; fwc->get_dev_path = core99_fw_dev_path;
hw/ppc/mac_oldworld.c +2 -3
@@ -27,6 +27,7 @@#include "qemu/osdep.h" #include "qemu/datadir.h" #include "qemu/units.h" +#include "qemu/legacy_binary_info.h" #include "qapi/error.h" #include "hw/ppc/ppc.h" #include "hw/qdev-properties.h"
@@ -416,9 +417,7 @@ static void heathrow_class_init(ObjectClass *oc, void *data) mc->block_default_type =IF_IDE ;/* SMP is not supported currently */ mc->max_cpus =1 ; -#ifndef TARGET_PPC64 - mc->is_default = true; -#endif + mc->is_default = !legacy_binary_is_64bit ();/* TOFIX "cad" when Mac floppy is implemented */ mc->default_boot_order ="cd" ; mc->kvm_type = heathrow_kvm_type;
Signature · 1 line
2.47.1
RFC PATCH 10/18 qemu: Introduce legacy_binary_is_big_endian() helper
In reply to Philippe Mathieu-DaudéIntroduce legacy_binary_endianness() to return the endianness of a legacy binary, and legacy_binary_is_big_endian() being equivalent of compile time TARGET_BIG_ENDIAN definition.
--- include/qemu/legacy_binary_info.h | 8 ++++++ legacy_binary_info.c | 43 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+)
include/qemu/legacy_binary_info.h +8 -0
@@ -9,9 +9,17 @@#ifndef QEMU_LEGACY_BINARY_INFO_H #define QEMU_LEGACY_BINARY_INFO_H +#include "qapi/qapi-types-common.h" +void legacy_binary_info_init (const char *argv0);/* Return runtime equivalent of TARGET_LONG_BITS == 64 check */ bool legacy_binary_is_64bit (void ); +/* Return runtime equivalent of TARGET_BIG_ENDIAN definition */ +bool legacy_binary_is_big_endian (void ); + +/* Return endianness of legacy binary */ +EndianMode legacy_binary_endianness (void ); +#endif
legacy_binary_info.c +43 -0
208 lines not on this page · raw message
Signature · 1 line
2.47.1
Re: [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper
Quoted 9 lines · Philippe Mathieu-Daudé
Introduce
legacy_binary_endianness()to return the endianness of a legacy binary, andlegacy_binary_is_big_endian()being equivalent of compile timeTARGET_BIG_ENDIANdefinition.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/qemu/legacy_binary_info.h | 8 ++++++ legacy_binary_info.c | 43 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+)
We already have target_words_bigendian() ... why do we need yet another function?
Thomas
Re: [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper
Quoted 5 lines · Thomas Huth
Quoted 4 lines · Philippe Mathieu-Daudé
Introduce
legacy_binary_endianness()to return the endianness of a legacy binary, andlegacy_binary_is_big_endian()being equivalent of compile timeTARGET_BIG_ENDIANdefinition.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/qemu/legacy_binary_info.h| 8 ++++++ legacy_binary_info.c | 43 +++++++++++++++++++++++++++++++2 files changed, 51 insertions(+)We already have
target_words_bigendian()... why do we need yet another function?
target_words_bigendian() depends on a compile time constant that we want to get rid of: TARGET_BIG_ENDIAN.
Also, since vCPUs can be configured in different endianness, both the method and definition are misleading, what they mean is "the *binary* uses BIG endianness by default".
For example we can now build a TARGET_BIG_ENDIAN microblaze binary with all vCPU core instantiated in little endianness.
Since unified binary won't have particular endianness knowledge (still, machines will), I suggest:
target_words_bigendian() -> qemu_legacy_binary_is_bigendian()
RFC PATCH 11/18 hw/mips/jazz: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian
In reply to Philippe Mathieu-DaudéFor legacy binaries, legacy_binary_is_big_endian() is equivalent of the compile time TARGET_BIG_ENDIAN definition.
--- hw/mips/jazz.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
hw/mips/jazz.c +11 -12
@@ -24,6 +24,7 @@#include "qemu/osdep.h" #include "qemu/datadir.h" +#include "qemu/legacy_binary_info.h" #include "hw/clock.h" #include "hw/mips/mips.h" #include "hw/intc/i8259.h"
@@ -59,12 +60,6 @@ enum jazz_model_e { JAZZ_PICA61, }; -#if TARGET_BIG_ENDIAN -#define BIOS_FILENAME "mips_bios.bin" -#else -#define BIOS_FILENAME "mipsel_bios.bin" -#endif -static void main_cpu_reset (void *opaque) {MIPSCPU *cpu = opaque;
@@ -120,7 +115,8 @@ static const MemoryRegionOps dma_dummy_ops = { };static void mips_jazz_init_net (IOMMUMemoryRegion *rc4030_dma_mr, -DeviceState *rc4030,MemoryRegion *dp8393x_prom) +DeviceState *rc4030,MemoryRegion *dp8393x_prom, +bool is_big_endian) {DeviceState *dev;SysBusDevice *sysbus;
@@ -136,7 +132,7 @@ static void mips_jazz_init_net(IOMMUMemoryRegion *rc4030_dma_mr, dev =qdev_new ("dp8393x" );qdev_set_nic_properties (dev, nd);qdev_prop_set_uint8 (dev,"it_shift" ,2 ); -qdev_prop_set_bit (dev,"big_endian" ,TARGET_BIG_ENDIAN ); +qdev_prop_set_bit (dev,"big_endian" , is_big_endian);object_property_set_link (OBJECT (dev),"dma_mr" ,OBJECT (rc4030_dma_mr), &error_abort); sysbus =SYS_BUS_DEVICE (dev);
@@ -194,6 +190,9 @@ static void mips_jazz_init(MachineState *machine,MemoryRegion *bios2 =g_new (MemoryRegion,1 );SysBusESPState *sysbus_esp;ESPState *esp; +bool is_big_endian =legacy_binary_is_big_endian (); +const char *default_bios_filename = is_big_endian ?"mips_bios.bin" + :"mipsel_bios.bin" ; static const struct { unsigned freq_hz; unsigned pll_mult;
@@ -212,8 +211,7 @@ static void mips_jazz_init(MachineState *machine, * ext_clk[jazz_model].pll_mult);/* init CPUs */ - cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk, -TARGET_BIG_ENDIAN ); + cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk, is_big_endian); env = &cpu->env;qemu_register_reset (main_cpu_reset, cpu);
@@ -245,7 +243,8 @@ static void mips_jazz_init(MachineState *machine,memory_region_add_subregion (address_space,0xfff00000LL , bios2);/* load the BIOS image. */ - filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , machine->firmware ?:BIOS_FILENAME ); + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , machine->firmware + ?: default_bios_filename);if (filename) { bios_size =load_image_targphys (filename,0xfff00000LL ,MAGNUM_BIOS_SIZE );
@@ -329,7 +328,7 @@ static void mips_jazz_init(MachineState *machine, }/* Network controller */ -mips_jazz_init_net (rc4030_dma_mr, rc4030, dp8393x_prom); +mips_jazz_init_net (rc4030_dma_mr, rc4030, dp8393x_prom, is_big_endian);/* SCSI adapter */ dev =qdev_new (TYPE_SYSBUS_ESP );
Signature · 1 line
2.47.1
RFC PATCH 12/18 hw/mips/mipssim: Use legacy_binary_is_big_endian()
In reply to Philippe Mathieu-DaudéFor legacy binaries, legacy_binary_is_big_endian() is equivalent of the compile time TARGET_BIG_ENDIAN definition.
--- hw/mips/mipssim.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
hw/mips/mipssim.c +9 -12
@@ -47,12 +47,6 @@#define BIOS_SIZE (4 * MiB) -#if TARGET_BIG_ENDIAN -#define BIOS_FILENAME "mips_bios.bin" -#else -#define BIOS_FILENAME "mipsel_bios.bin" -#endif - static struct _loaderparams { int ram_size; const char *kernel_filename;
@@ -65,7 +59,7 @@ typedef struct ResetData {uint64_t vector; } ResetData; -static uint64_t load_kernel (void ) +static uint64_t load_kernel (bool is_big_endian) {uint64_t entry, kernel_high, initrd_size;long kernel_size;
@@ -75,7 +69,7 @@ static uint64_t load_kernel(void) cpu_mips_kseg0_to_phys,NULL , &entry,NULL , &kernel_high,NULL , -TARGET_BIG_ENDIAN ?ELFDATA2MSB :ELFDATA2LSB , + is_big_endian ?ELFDATA2MSB :ELFDATA2LSB , EM_MIPS, 1, 0);if (kernel_size <0 ) { error_report("could not load kernel '%s': %s",
@@ -153,14 +147,16 @@ mips_mipssim_init(MachineState *machine)CPUMIPSState *env;ResetData *reset_info;int bios_size; +bool is_big_endian =legacy_binary_is_big_endian (); +const char *default_bios_filename = is_big_endian ?"mips_bios.bin" + :"mipsel_bios.bin" ;unsigned clock_hz = (legacy_binary_is_64bit () ?6 :12 ) *1000 *1000 ; cpuclk =clock_new (OBJECT (machine),"cpu-refclk" );clock_set_hz (cpuclk, clock_hz);/* Init CPUs. */ - cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk, -TARGET_BIG_ENDIAN ); + cpu =mips_cpu_create_with_clock (machine->cpu_type, cpuclk, is_big_endian); env = &cpu->env; reset_info =g_new0 (ResetData,1 );
@@ -177,7 +173,8 @@ mips_mipssim_init(MachineState *machine)/* Map the BIOS / boot exception handler. */ memory_region_add_subregion (address_space_mem,0x1fc00000LL , bios);/* Load a BIOS / boot exception handler image. */ - filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , machine->firmware ?:BIOS_FILENAME ); + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , machine->firmware + ?: default_bios_filename);if (filename) { bios_size =load_image_targphys (filename,0x1fc00000LL ,BIOS_SIZE );g_free (filename);
@@ -199,7 +196,7 @@ mips_mipssim_init(MachineState *machine) loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; - reset_info->vector =load_kernel (); + reset_info->vector =load_kernel (is_big_endian); }/* Init CPU internal devices. */
Signature · 1 line
2.47.1
RFC PATCH 13/18 hw/xtensa/sim: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian
In reply to Philippe Mathieu-DaudéFor legacy binaries, legacy_binary_is_big_endian() is equivalent of the compile time TARGET_BIG_ENDIAN definition.
--- hw/xtensa/sim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/xtensa/sim.c +3 -1
@@ -26,6 +26,7 @@*/ #include "qemu/osdep.h" +#include "qemu/legacy_binary_info.h" #include "qapi/error.h" #include "system/reset.h" #include "system/system.h"
@@ -101,7 +102,8 @@ void xtensa_sim_load_kernel(XtensaCPU *cpu, MachineState *machine)uint64_t elf_entry;int success =load_elf (kernel_filename,NULL , translate_phys_addr, cpu, &elf_entry,NULL ,NULL ,NULL , -TARGET_BIG_ENDIAN ?ELFDATA2MSB :ELFDATA2LSB , +legacy_binary_is_big_endian () ?ELFDATA2MSB + :ELFDATA2LSB ,EM_XTENSA ,0 ,0 );if (success >0 ) {
Signature · 1 line
2.47.1
RFC PATCH 14/18 hw/xtensa/xtfpga: Check endianness via legacy_binary_is_big_endian()
In reply to Philippe Mathieu-DaudéFor legacy binaries, legacy_binary_is_big_endian() is equivalent of the compile time TARGET_BIG_ENDIAN definition.
--- hw/xtensa/xtfpga.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
hw/xtensa/xtfpga.c +7 -5
@@ -27,6 +27,7 @@#include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/legacy_binary_info.h" #include "qapi/error.h" #include "cpu.h" #include "system/system.h"
@@ -238,6 +239,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)uint32_t freq =10000000 ;int n;unsigned int smp_cpus = machine->smp.cpus; +bool is_big_endian =legacy_binary_is_big_endian ();if (smp_cpus >1 ) { mx_pic =xtensa_mx_pic_init (31 );
@@ -311,7 +313,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) dinfo =drive_get (IF_PFLASH ,0 ,0 );if (dinfo) { - flash =xtfpga_flash_init (system_io, board, dinfo,TARGET_BIG_ENDIAN ); + flash =xtfpga_flash_init (system_io, board, dinfo, is_big_endian); }/* Use presence of kernel file name as 'boot from SRAM' switch. */
@@ -399,7 +401,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)uint64_t elf_entry;int success =load_elf (kernel_filename,NULL , translate_phys_addr, cpu, &elf_entry,NULL ,NULL ,NULL , -TARGET_BIG_ENDIAN ?ELFDATA2MSB :ELFDATA2LSB , + is_big_endian ?ELFDATA2MSB :ELFDATA2LSB ,EM_XTENSA ,0 ,0 );if (success >0 ) { entry_point = elf_entry;
@@ -437,9 +439,9 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)0x21 ,0xfe ,0xff ,/* l32r a2, entry_a2 */ 0xa0, 0x00, 0x00, /* jx a0 */ }; -const size_t boot_sz =TARGET_BIG_ENDIAN ?sizeof (boot_be) - :sizeof (boot_le); -uint8_t *boot =TARGET_BIG_ENDIAN ? boot_be : boot_le; +const size_t boot_sz = is_big_endian ?sizeof (boot_be) + :sizeof (boot_le); +uint8_t *boot = is_big_endian ? boot_be : boot_le;uint32_t entry_pc =tswap32 (entry_point);uint32_t entry_a2 =tswap32 (tagptr);
Signature · 1 line
2.47.1
RFC PATCH 15/18 hw/microblaze/petalogix_ml605_mmu: Use legacy_binary_is_big_endian()
In reply to Philippe Mathieu-DaudéFor legacy binaries, legacy_binary_is_big_endian() is equivalent of the compile time TARGET_BIG_ENDIAN definition.
--- hw/microblaze/petalogix_ml605_mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/microblaze/petalogix_ml605_mmu.c +2 -2
@@ -27,6 +27,7 @@#include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/legacy_binary_info.h" #include "qapi/error.h" #include "cpu.h" #include "hw/sysbus.h"
@@ -80,8 +81,7 @@ petalogix_ml605_init(MachineState *machine)MemoryRegion *phys_lmb_bram =g_new (MemoryRegion,1 );MemoryRegion *phys_ram =g_new (MemoryRegion,1 );qemu_irq irq[32 ]; -EndianMode endianness =TARGET_BIG_ENDIAN ?ENDIAN_MODE_BIG - :ENDIAN_MODE_LITTLE ; +EndianMode endianness =legacy_binary_endianness ();/* init CPUs */ cpu =MICROBLAZE_CPU (object_new (TYPE_MICROBLAZE_CPU ));
Signature · 1 line
2.47.1
RFC PATCH 16/18 hw/microblaze/petalogix_s3adsp1800_mmu: Use legacy_binary_is_big_endian
In reply to Philippe Mathieu-DaudéFor legacy binaries, legacy_binary_is_big_endian() is equivalent of the compile time TARGET_BIG_ENDIAN definition.
--- hw/microblaze/petalogix_s3adsp1800_mmu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
hw/microblaze/petalogix_s3adsp1800_mmu.c +8 -5
@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/legacy_binary_info.h" #include "qapi/error.h" #include "cpu.h" #include "hw/sysbus.h"
@@ -71,13 +72,12 @@ petalogix_s3adsp1800_init(MachineState *machine)MemoryRegion *phys_ram =g_new (MemoryRegion,1 );qemu_irq irq[32 ];MemoryRegion *sysmem =get_system_memory (); -EndianMode endianness =TARGET_BIG_ENDIAN ?ENDIAN_MODE_BIG - :ENDIAN_MODE_LITTLE ; +EndianMode endianness =legacy_binary_endianness (); cpu =MICROBLAZE_CPU (object_new (TYPE_MICROBLAZE_CPU ));object_property_set_str (OBJECT (cpu),"version" ,"7.10.d" , &error_abort);object_property_set_bool (OBJECT (cpu),"little-endian" , - !TARGET_BIG_ENDIAN , &error_abort); + endianness ==ENDIAN_MODE_LITTLE , &error_abort);qdev_realize (DEVICE (cpu),NULL , &error_abort);/* Attach emulated BRAM through the LMB. */
@@ -135,7 +135,8 @@ petalogix_s3adsp1800_init(MachineState *machine)create_unimplemented_device ("xps_gpio" ,GPIO_BASEADDR ,0x10000 ); -microblaze_load_kernel (cpu, !TARGET_BIG_ENDIAN , ddr_base, ram_size, +microblaze_load_kernel (cpu, endianness ==ENDIAN_MODE_LITTLE , + ddr_base, ram_size, machine->initrd_filename,BINARY_DEVICE_TREE_FILE ,NULL );
@@ -145,7 +146,9 @@ static void petalogix_s3adsp1800_machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->desc ="PetaLogix linux refdesign for xilinx Spartan 3ADSP1800" ; + mc->desc =legacy_binary_endianness () ==ENDIAN_MODE_LITTLE + ?"PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (little endian)" + :"PetaLogix linux refdesign for xilinx Spartan 3ADSP1800 (big endian)" ; mc->init = petalogix_s3adsp1800_init; mc->is_default = true; }
Signature · 1 line
2.47.1
RFC PATCH 17/18 meson: Allow symlinking system emulation binaries
In reply to Philippe Mathieu-DaudéThe 'legacy binary' API allows checking target specific features at runtime by comparing the argv[0] binary name.
Add few lines to easily symlink indentical targets (see next commit).
---
This is ugly meson, but the point is to show a prototype.
One problem is we can not run 'make check-$suite-$target' anymore :(
--- meson.build | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
meson.build +16 -0
@@ -3251,6 +3251,9 @@ host_kconfig = \ ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ] +aliased_targets = [] +aliased_target = {} + default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host actual_target_dirs = [] fdt_required = []
@@ -3273,6 +3276,9 @@ foreach target : target_dirs endif config_target += { 'CONFIG_BSD_USER': 'y' } elif target.endswith('softmmu') + if config_target['TARGET_NAME'] in aliased_targets + continue + endif config_target += { 'CONFIG_SYSTEM_ONLY': 'y' } config_target += { 'CONFIG_SOFTMMU': 'y' } endif
@@ -4307,6 +4313,16 @@ foreach target : target_dirs link_args: link_args, win_subsystem: exe['win_subsystem']) + if target_name in aliased_target + exe_alias = 'qemu-system-' + aliased_target[target_name] + emulators += {exe_alias : custom_target(exe_alias, + input: [emulator], + output: exe_alias, + command: ['ln', '-f', '@INPUT@', '@OUTPUT@'], + install : true, + install_dir : get_option('bindir'))} + endif + if host_os == 'darwin' icon = 'pc-bios/qemu.rsrc' build_input = [emulator, files(icon)]
Signature · 1 line
2.47.1
RFC PATCH 18/18 configs/targets: Merge qemu-system-microblaze{el} binaries
In reply to Philippe Mathieu-Daudéqemu-system-microblaze and qemu-system-microblazeel binaries are functionally equivalent (except the default endianness).
By using legacy_binary_is_big_endian() to get the binary endianness at runtime, we can merge both binaries (using a symlink).
--- configs/targets/microblazeel-softmmu.mak | 8 -------- meson.build | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 configs/targets/microblazeel-softmmu.mak
configs/targets/microblazeel-softmmu.mak deleted +0 -8
@@ -1,8 +0,0 @@ -TARGET_ARCH=microblaze -TARGET_SUPPORTS_MTTCG=y -# needed by boot.c -TARGET_NEED_FDT=y -TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml -# System mode can address up to 64 bits via lea/sea instructions. -# TODO: These bypass the mmu, so we could emulate these differently. -TARGET_LONG_BITS=64
meson.build +2 -2
@@ -3251,8 +3251,8 @@ host_kconfig = \ ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ] -aliased_targets = [] -aliased_target = {} +aliased_targets = ['microblazeel'] +aliased_target = {'microblaze': 'microblazeel'} default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host actual_target_dirs = []
Signature · 1 line
2.47.1