On Thu, 6 Mar 2025 at 09:21, Daniel P. Berrangé <berra...@redhat.com> wrote: > > On Wed, Mar 05, 2025 at 05:12:46PM +0100, Philippe Mathieu-Daudé wrote: > > For legacy ARM binaries, legacy_binary_is_64bit() is > > equivalent of the compile time TARGET_AARCH64 definition. > > > > Use it as TypeInfo::registerable() callback to dynamically > > add Aarch64 specific types in qemu-system-aarch64 binary, > > removing the need of TARGET_AARCH64 #ifdef'ry. > > > > Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> > > --- > > hw/arm/bcm2836.c | 6 ++---- > > hw/arm/raspi.c | 7 +++---- > > 2 files changed, 5 insertions(+), 8 deletions(-) > > > > diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c > > index 95e16806fa1..88a32e5fc20 100644 > > --- a/hw/arm/bcm2836.c > > +++ b/hw/arm/bcm2836.c > > > > @@ -219,12 +218,11 @@ static const TypeInfo bcm283x_types[] = { > > .name = TYPE_BCM2836, > > .parent = TYPE_BCM283X, > > .class_init = bcm2836_class_init, > > -#ifdef TARGET_AARCH64 > > }, { > > .name = TYPE_BCM2837, > > .parent = TYPE_BCM283X, > > + .registerable = legacy_binary_is_64bit, > > .class_init = bcm2837_class_init, > > -#endif > > }, { > > .name = TYPE_BCM283X, > > .parent = TYPE_BCM283X_BASE, > > So historically we have a subset of machines that are only exposed in > the qemu-system-aarch64 binary, and not qemu-system-arm. > > You're attempting to build a single binary to cover both 32 & 64 bit > arm, so need to be able to filter what machines are available to > create when the symlink indicates invokation of the 32-bit binary.
What machines are there that we don't want to provide, though? We don't provide for instance raspi4b in today's qemu-system-arm, but that's because it wouldn't work there: qemu-system-arm doesn't have the 64-bit CPUs. But if we have a single binary that has both 32 and 64 bit arm in it, then the 64-bit CPUs will be in that combined binary. Do we actually need to explicitly forbid the user from saying 'qemu-system-arm -M raspi4b' when qemu-system-arm is a symlink and the command would work fine if it wasn't forbidden? I had assumed that the motivation here was that we'd like to be able to build this C file only once. Currently we have to build it once for the aarch64 target and once for the arm target; to avoid that we would need to determine "does the binary I'm in have the AArch64 CPU types this type depends on" at runtime, not at compile time (which is what the ifdef is doing, effectively). thanks -- PMM