* [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 16:53 ` Pierrick Bouvier
` (2 more replies)
2025-03-05 15:39 ` [RFC PATCH 02/18] hw/vfio/common: Get target page size using runtime helpers Philippe Mathieu-Daudé
` (16 subsequent siblings)
17 siblings, 3 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
There is no TARGET_ARM_64 definition. Luckily enough,
when TARGET_AARCH64 is defined, TARGET_ARM also is.
Fixes: 733766cd373 ("hw/arm: introduce xenpvh machine")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/xen/arch_hvm.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h
index c7c515220d2..df39c819c8f 100644
--- a/include/hw/xen/arch_hvm.h
+++ b/include/hw/xen/arch_hvm.h
@@ -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
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
2025-03-05 15:39 ` [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo Philippe Mathieu-Daudé
@ 2025-03-05 16:53 ` Pierrick Bouvier
2025-03-06 1:35 ` Richard Henderson
2025-03-13 8:10 ` Michael Tokarev
2 siblings, 0 replies; 42+ messages in thread
From: Pierrick Bouvier @ 2025-03-05 16:53 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Thomas Huth, Alex Bennée
On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> There is no TARGET_ARM_64 definition. Luckily enough,
> when TARGET_AARCH64 is defined, TARGET_ARM also is.
>
> Fixes: 733766cd373 ("hw/arm: introduce xenpvh machine")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/hw/xen/arch_hvm.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h
> index c7c515220d2..df39c819c8f 100644
> --- a/include/hw/xen/arch_hvm.h
> +++ b/include/hw/xen/arch_hvm.h
> @@ -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
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
2025-03-05 15:39 ` [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo Philippe Mathieu-Daudé
2025-03-05 16:53 ` Pierrick Bouvier
@ 2025-03-06 1:35 ` Richard Henderson
2025-03-13 8:10 ` Michael Tokarev
2 siblings, 0 replies; 42+ messages in thread
From: Richard Henderson @ 2025-03-06 1:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Pierrick Bouvier,
Thomas Huth, Alex Bennée
On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> There is no TARGET_ARM_64 definition. Luckily enough,
> when TARGET_AARCH64 is defined, TARGET_ARM also is.
>
> Fixes: 733766cd373 ("hw/arm: introduce xenpvh machine")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/hw/xen/arch_hvm.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h
> index c7c515220d2..df39c819c8f 100644
> --- a/include/hw/xen/arch_hvm.h
> +++ b/include/hw/xen/arch_hvm.h
> @@ -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
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
2025-03-05 15:39 ` [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo Philippe Mathieu-Daudé
2025-03-05 16:53 ` Pierrick Bouvier
2025-03-06 1:35 ` Richard Henderson
@ 2025-03-13 8:10 ` Michael Tokarev
2025-03-13 9:40 ` Philippe Mathieu-Daudé
2 siblings, 1 reply; 42+ messages in thread
From: Michael Tokarev @ 2025-03-13 8:10 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée, qemu-stable
05.03.2025 18:39, Philippe Mathieu-Daudé wrote:
> There is no TARGET_ARM_64 definition. Luckily enough,
> when TARGET_AARCH64 is defined, TARGET_ARM also is.
>
> Fixes: 733766cd373 ("hw/arm: introduce xenpvh machine")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/hw/xen/arch_hvm.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h
> index c7c515220d2..df39c819c8f 100644
> --- a/include/hw/xen/arch_hvm.h
> +++ b/include/hw/xen/arch_hvm.h
> @@ -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
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo
2025-03-13 8:10 ` Michael Tokarev
@ 2025-03-13 9:40 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-13 9:40 UTC (permalink / raw)
To: Michael Tokarev, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée, qemu-stable
On 13/3/25 09:10, Michael Tokarev wrote:
> 05.03.2025 18:39, Philippe Mathieu-Daudé wrote:
>> There is no TARGET_ARM_64 definition. Luckily enough,
>> when TARGET_AARCH64 is defined, TARGET_ARM also is.
>>
>> Fixes: 733766cd373 ("hw/arm: introduce xenpvh machine")
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> include/hw/xen/arch_hvm.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/hw/xen/arch_hvm.h b/include/hw/xen/arch_hvm.h
>> index c7c515220d2..df39c819c8f 100644
>> --- a/include/hw/xen/arch_hvm.h
>> +++ b/include/hw/xen/arch_hvm.h
>> @@ -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 :)
Good idea, thank you!
^ permalink raw reply [flat|nested] 42+ messages in thread
* [RFC PATCH 02/18] hw/vfio/common: Get target page size using runtime helpers
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-06 1:37 ` Richard Henderson
2025-03-05 15:39 ` [RFC PATCH 03/18] include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition Philippe Mathieu-Daudé
` (15 subsequent siblings)
17 siblings, 1 reply; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
Prefer runtime helpers to get target page size.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/vfio/common.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 7a4010ef4ee..d4c9e59173d 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -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;
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 02/18] hw/vfio/common: Get target page size using runtime helpers
2025-03-05 15:39 ` [RFC PATCH 02/18] hw/vfio/common: Get target page size using runtime helpers Philippe Mathieu-Daudé
@ 2025-03-06 1:37 ` Richard Henderson
0 siblings, 0 replies; 42+ messages in thread
From: Richard Henderson @ 2025-03-06 1:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Pierrick Bouvier,
Thomas Huth, Alex Bennée
On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> Prefer runtime helpers to get target page size.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/vfio/common.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 7a4010ef4ee..d4c9e59173d 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -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()));
It would be worth storing this in a local variable, I think.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 42+ messages in thread
* [RFC PATCH 03/18] include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 01/18] hw/xen/hvm: Fix Aarch64 typo Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 02/18] hw/vfio/common: Get target page size using runtime helpers Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-06 1:37 ` Richard Henderson
2025-03-05 15:39 ` [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h' Philippe Mathieu-Daudé
` (14 subsequent siblings)
17 siblings, 1 reply; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
Ensure common code never use this target specific definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/poison.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/exec/poison.h b/include/exec/poison.h
index 0c4ad04eb97..0ab7f0da1c7 100644
--- a/include/exec/poison.h
+++ b/include/exec/poison.h
@@ -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
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 03/18] include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition
2025-03-05 15:39 ` [RFC PATCH 03/18] include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition Philippe Mathieu-Daudé
@ 2025-03-06 1:37 ` Richard Henderson
0 siblings, 0 replies; 42+ messages in thread
From: Richard Henderson @ 2025-03-06 1:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Pierrick Bouvier,
Thomas Huth, Alex Bennée
On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> Ensure common code never use this target specific definition.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/exec/poison.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/include/exec/poison.h b/include/exec/poison.h
> index 0c4ad04eb97..0ab7f0da1c7 100644
> --- a/include/exec/poison.h
> +++ b/include/exec/poison.h
> @@ -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
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 42+ messages in thread
* [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 03/18] include: Poison TARGET_PHYS_ADDR_SPACE_BITS definition Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 16:59 ` Pierrick Bouvier
` (2 more replies)
2025-03-05 15:39 ` [RFC PATCH 05/18] qemu: Introduce legacy_binary_is_64bit() helper Philippe Mathieu-Daudé
` (13 subsequent siblings)
17 siblings, 3 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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
diff --git a/meson.build b/meson.build
index eaae1da2e92..e4ede6ba06f 100644
--- a/meson.build
+++ b/meson.build
@@ -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')
diff --git a/include/qemu/legacy_binary_info.h b/include/qemu/legacy_binary_info.h
new file mode 100644
index 00000000000..ae67399ebf2
--- /dev/null
+++ b/include/qemu/legacy_binary_info.h
@@ -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
diff --git a/legacy_binary_info.c b/legacy_binary_info.c
new file mode 100644
index 00000000000..0c50fc9248a
--- /dev/null
+++ b/legacy_binary_info.c
@@ -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();
+}
diff --git a/system/vl.c b/system/vl.c
index a41ba4a2d5f..74a062c7fff 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -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
^ permalink raw reply related [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-05 15:39 ` [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h' Philippe Mathieu-Daudé
@ 2025-03-05 16:59 ` Pierrick Bouvier
2025-03-06 7:26 ` Thomas Huth
2025-03-05 19:19 ` Paolo Bonzini
2025-03-06 1:56 ` Richard Henderson
2 siblings, 1 reply; 42+ messages in thread
From: Pierrick Bouvier @ 2025-03-05 16:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Thomas Huth, Alex Bennée
On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> 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.
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> 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
>
> diff --git a/meson.build b/meson.build
> index eaae1da2e92..e4ede6ba06f 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -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')
> diff --git a/include/qemu/legacy_binary_info.h b/include/qemu/legacy_binary_info.h
> new file mode 100644
> index 00000000000..ae67399ebf2
> --- /dev/null
> +++ b/include/qemu/legacy_binary_info.h
> @@ -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
> diff --git a/legacy_binary_info.c b/legacy_binary_info.c
> new file mode 100644
> index 00000000000..0c50fc9248a
> --- /dev/null
> +++ b/legacy_binary_info.c
> @@ -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();
> +}
> diff --git a/system/vl.c b/system/vl.c
> index a41ba4a2d5f..74a062c7fff 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -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();
>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-05 16:59 ` Pierrick Bouvier
@ 2025-03-06 7:26 ` Thomas Huth
2025-03-06 9:26 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 42+ messages in thread
From: Thomas Huth @ 2025-03-06 7:26 UTC (permalink / raw)
To: Pierrick Bouvier, Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Alex Bennée
On 05/03/2025 17.59, Pierrick Bouvier wrote:
> On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
>> 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.
FWIW, I agree, this should rather be target_is_64bit() or something similar,
like target_words_bigendian() ?
Thomas
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 7:26 ` Thomas Huth
@ 2025-03-06 9:26 ` Philippe Mathieu-Daudé
2025-03-06 11:34 ` Paolo Bonzini
0 siblings, 1 reply; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-06 9:26 UTC (permalink / raw)
To: Thomas Huth, Pierrick Bouvier, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Alex Bennée
On 6/3/25 08:26, Thomas Huth wrote:
> On 05/03/2025 17.59, Pierrick Bouvier wrote:
>> On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
>>> 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.
>
> FWIW, I agree, this should rather be target_is_64bit() or something
> similar, like target_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.
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 9:26 ` Philippe Mathieu-Daudé
@ 2025-03-06 11:34 ` Paolo Bonzini
2025-03-06 11:52 ` Daniel P. Berrangé
0 siblings, 1 reply; 42+ messages in thread
From: Paolo Bonzini @ 2025-03-06 11:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Thomas Huth, Pierrick Bouvier, qemu-devel,
Daniel P. Berrangé, Richard Henderson, Alex Bennée
[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]
Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <philmd@linaro.org> ha
scritto:
> 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
>
Or just qemu-system I guess.
^ equivalent of today's qemu-system-aarch64
>
> 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:
>
> $ qemu-system-aarch64 -M zynqmp
>
> we create 64-bit and 32-bit ARM cores.
>
Agreed, bit size and endianness should only matter in the CPU code.
Paolo
>
[-- Attachment #2: Type: text/html, Size: 3017 bytes --]
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 11:34 ` Paolo Bonzini
@ 2025-03-06 11:52 ` Daniel P. Berrangé
2025-03-06 13:45 ` BALATON Zoltan
0 siblings, 1 reply; 42+ messages in thread
From: Daniel P. Berrangé @ 2025-03-06 11:52 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Philippe Mathieu-Daudé, Thomas Huth, Pierrick Bouvier,
qemu-devel, Richard Henderson, Alex Bennée
On Thu, Mar 06, 2025 at 12:34:13PM +0100, Paolo Bonzini wrote:
> Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <philmd@linaro.org> ha
> scritto:
>
> > 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
> >
>
> Or just qemu-system I guess.
>
> ^ equivalent of today's qemu-system-aarch64
> >
> > 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.
>
> 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).
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
--
|: 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 :|
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 11:52 ` Daniel P. Berrangé
@ 2025-03-06 13:45 ` BALATON Zoltan
2025-03-06 15:15 ` Daniel P. Berrangé
0 siblings, 1 reply; 42+ messages in thread
From: BALATON Zoltan @ 2025-03-06 13:45 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: Paolo Bonzini, Philippe Mathieu-Daudé, Thomas Huth,
Pierrick Bouvier, qemu-devel, Richard Henderson, Alex Bennée
[-- Attachment #1: Type: text/plain, Size: 4105 bytes --]
On Thu, 6 Mar 2025, Daniel P. Berrangé wrote:
> On Thu, Mar 06, 2025 at 12:34:13PM +0100, Paolo Bonzini wrote:
>> Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <philmd@linaro.org> ha
>> scritto:
>>
>>> 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
>>>
>>
>> Or just qemu-system I guess.
>>
>> ^ equivalent of today's qemu-system-aarch64
>>>
>>> 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.
>
>>
>> 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).
>
> 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
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
> * 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
>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 13:45 ` BALATON Zoltan
@ 2025-03-06 15:15 ` Daniel P. Berrangé
2025-03-06 15:28 ` BALATON Zoltan
0 siblings, 1 reply; 42+ messages in thread
From: Daniel P. Berrangé @ 2025-03-06 15:15 UTC (permalink / raw)
To: BALATON Zoltan
Cc: Paolo Bonzini, Philippe Mathieu-Daudé, Thomas Huth,
Pierrick Bouvier, qemu-devel, Richard Henderson, Alex Bennée
On Thu, Mar 06, 2025 at 02:45:52PM +0100, BALATON Zoltan wrote:
> On Thu, 6 Mar 2025, Daniel P. Berrangé wrote:
> > On Thu, Mar 06, 2025 at 12:34:13PM +0100, Paolo Bonzini wrote:
> > > Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <philmd@linaro.org> ha
> > > scritto:
> > >
> > > > 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
> > > >
> > >
> > > Or just qemu-system I guess.
> > >
> > > ^ equivalent of today's qemu-system-aarch64
> > > >
> > > > 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.
> >
> > >
> > > 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).
> >
> > 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
>
> 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.
...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
--
|: 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 :|
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 15:15 ` Daniel P. Berrangé
@ 2025-03-06 15:28 ` BALATON Zoltan
2025-03-06 21:45 ` Pierrick Bouvier
0 siblings, 1 reply; 42+ messages in thread
From: BALATON Zoltan @ 2025-03-06 15:28 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: Paolo Bonzini, Philippe Mathieu-Daudé, Thomas Huth,
Pierrick Bouvier, qemu-devel, Richard Henderson, Alex Bennée
[-- Attachment #1: Type: text/plain, Size: 4988 bytes --]
On Thu, 6 Mar 2025, Daniel P. Berrangé wrote:
> On Thu, Mar 06, 2025 at 02:45:52PM +0100, BALATON Zoltan wrote:
>> On Thu, 6 Mar 2025, Daniel P. Berrangé wrote:
>>> On Thu, Mar 06, 2025 at 12:34:13PM +0100, Paolo Bonzini wrote:
>>>> Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <philmd@linaro.org> ha
>>>> scritto:
>>>>
>>>>> 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
>>>>>
>>>>
>>>> Or just qemu-system I guess.
>>>>
>>>> ^ equivalent of today's qemu-system-aarch64
>>>>>
>>>>> 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.
>>>
>>>>
>>>> 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).
>>>
>>> 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
>>
>> 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.
>
> ...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
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
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 15:28 ` BALATON Zoltan
@ 2025-03-06 21:45 ` Pierrick Bouvier
2025-03-07 0:46 ` BALATON Zoltan
0 siblings, 1 reply; 42+ messages in thread
From: Pierrick Bouvier @ 2025-03-06 21:45 UTC (permalink / raw)
To: BALATON Zoltan, Daniel P. Berrangé
Cc: Paolo Bonzini, Philippe Mathieu-Daudé, Thomas Huth,
qemu-devel, Richard Henderson, Alex Bennée
On 3/6/25 07:28, BALATON Zoltan wrote:
> On Thu, 6 Mar 2025, Daniel P. Berrangé wrote:
>> On Thu, Mar 06, 2025 at 02:45:52PM +0100, BALATON Zoltan wrote:
>>> On Thu, 6 Mar 2025, Daniel P. Berrangé wrote:
>>>> On Thu, Mar 06, 2025 at 12:34:13PM +0100, Paolo Bonzini wrote:
>>>>> Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <philmd@linaro.org> ha
>>>>> scritto:
>>>>>
>>>>>> 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
>>>>>>
>>>>>
>>>>> Or just qemu-system I guess.
>>>>>
>>>>> ^ equivalent of today's qemu-system-aarch64
>>>>>>
>>>>>> 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.
>>>>
>>>>>
>>>>> 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).
>>>>
>>>> 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
>>>
>>> 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.
>>
>> ...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
>
> 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
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 21:45 ` Pierrick Bouvier
@ 2025-03-07 0:46 ` BALATON Zoltan
0 siblings, 0 replies; 42+ messages in thread
From: BALATON Zoltan @ 2025-03-07 0:46 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: Daniel P. Berrangé, Paolo Bonzini,
Philippe Mathieu-Daudé, Thomas Huth, qemu-devel,
Richard Henderson, Alex Bennée
[-- Attachment #1: Type: text/plain, Size: 8376 bytes --]
On Thu, 6 Mar 2025, Pierrick Bouvier wrote:
> On 3/6/25 07:28, BALATON Zoltan wrote:
>> On Thu, 6 Mar 2025, Daniel P. Berrangé wrote:
>>> On Thu, Mar 06, 2025 at 02:45:52PM +0100, BALATON Zoltan wrote:
>>>> On Thu, 6 Mar 2025, Daniel P. Berrangé wrote:
>>>>> On Thu, Mar 06, 2025 at 12:34:13PM +0100, Paolo Bonzini wrote:
>>>>>> Il gio 6 mar 2025, 10:27 Philippe Mathieu-Daudé <philmd@linaro.org> ha
>>>>>> scritto:
>>>>>>
>>>>>>> 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
>>>>>>>
>>>>>>
>>>>>> Or just qemu-system I guess.
>>>>>>
>>>>>> ^ equivalent of today's qemu-system-aarch64
>>>>>>>
>>>>>>> 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.
>>>>>
>>>>>>
>>>>>> 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).
>>>>>
>>>>> 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
>>>>
>>>> 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.
>>>
>>> ...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
>>
>> 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.
The above wasn't about heterogenous emulation but about single binary.
That still needs a way to select the machine to emulate.
> 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.
> 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.
> 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.
> 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
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-05 15:39 ` [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h' Philippe Mathieu-Daudé
2025-03-05 16:59 ` Pierrick Bouvier
@ 2025-03-05 19:19 ` Paolo Bonzini
2025-03-06 1:56 ` Richard Henderson
2 siblings, 0 replies; 42+ messages in thread
From: Paolo Bonzini @ 2025-03-05 19:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Daniel P. Berrangé, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée
[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]
Il mer 5 mar 2025, 16:39 Philippe Mathieu-Daudé <philmd@linaro.org> ha
scritto:
> + 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();
> +}
> diff --git a/system/vl.c b/system/vl.c
> index a41ba4a2d5f..74a062c7fff 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -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
>
>
[-- Attachment #2: Type: text/html, Size: 2345 bytes --]
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-05 15:39 ` [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h' Philippe Mathieu-Daudé
2025-03-05 16:59 ` Pierrick Bouvier
2025-03-05 19:19 ` Paolo Bonzini
@ 2025-03-06 1:56 ` Richard Henderson
2025-03-06 12:13 ` Daniel P. Berrangé
2025-03-19 14:25 ` Philippe Mathieu-Daudé
2 siblings, 2 replies; 42+ messages in thread
From: Richard Henderson @ 2025-03-06 1:56 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Pierrick Bouvier,
Thomas Huth, Alex Bennée
On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> +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().
> +
> + 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~
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 1:56 ` Richard Henderson
@ 2025-03-06 12:13 ` Daniel P. Berrangé
2025-03-19 14:25 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 42+ messages in thread
From: Daniel P. Berrangé @ 2025-03-06 12:13 UTC (permalink / raw)
To: Richard Henderson
Cc: Philippe Mathieu-Daudé, qemu-devel, Paolo Bonzini,
Pierrick Bouvier, Thomas Huth, Alex Bennée
On Wed, Mar 05, 2025 at 05:56:46PM -0800, Richard Henderson wrote:
> On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> > +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().
>
> > +
> > + 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?
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
--
|: 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 :|
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-06 1:56 ` Richard Henderson
2025-03-06 12:13 ` Daniel P. Berrangé
@ 2025-03-19 14:25 ` Philippe Mathieu-Daudé
2025-03-22 6:59 ` Markus Armbruster
1 sibling, 1 reply; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-19 14:25 UTC (permalink / raw)
To: Richard Henderson, qemu-devel, Markus Armbruster, Paolo Bonzini
Cc: Daniel P. Berrangé, Pierrick Bouvier, Thomas Huth,
Alex Bennée
Cc'ing Markus.
On 6/3/25 02:56, Richard Henderson wrote:
> On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
>> +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;
>> + }
>> + }
> 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.
> 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?
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h'
2025-03-19 14:25 ` Philippe Mathieu-Daudé
@ 2025-03-22 6:59 ` Markus Armbruster
0 siblings, 0 replies; 42+ messages in thread
From: Markus Armbruster @ 2025-03-22 6:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Richard Henderson, qemu-devel, Paolo Bonzini,
Daniel P. Berrangé, Pierrick Bouvier, Thomas Huth,
Alex Bennée
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Cc'ing Markus.
>
> On 6/3/25 02:56, Richard Henderson wrote:
>> On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
>>> +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;
>>> + }
>>> + }
>
>
>> 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.
>
>> 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.
> 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.
^ permalink raw reply [flat|nested] 42+ messages in thread
* [RFC PATCH 05/18] qemu: Introduce legacy_binary_is_64bit() helper
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 04/18] qemu: Introduce 'qemu/legacy_binary_info.h' Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 06/18] hw/mips/mipssim: Replace TARGET_MIPS64 by legacy_binary_is_64bit() Philippe Mathieu-Daudé
` (12 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
Introduce legacy_binary_is_64bit() to check at runtime if
a binary is compiled with TARGET_LONG_BITS == 64.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/legacy_binary_info.h | 3 +++
legacy_binary_info.c | 37 +++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/include/qemu/legacy_binary_info.h b/include/qemu/legacy_binary_info.h
index ae67399ebf2..2d42e852b7a 100644
--- a/include/qemu/legacy_binary_info.h
+++ b/include/qemu/legacy_binary_info.h
@@ -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
diff --git a/legacy_binary_info.c b/legacy_binary_info.c
index 0c50fc9248a..be50d3f50ea 100644
--- a/legacy_binary_info.c
+++ b/legacy_binary_info.c
@@ -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;
+}
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 06/18] hw/mips/mipssim: Replace TARGET_MIPS64 by legacy_binary_is_64bit()
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 05/18] qemu: Introduce legacy_binary_is_64bit() helper Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 07/18] hw/mips/malta: " Philippe Mathieu-Daudé
` (11 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy MIPS binaries, legacy_binary_is_64bit() is
equivalent of the compile time TARGET_MIPS64 definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/mips/mipssim.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index c530688e769..f94dbdc428b 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -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";
}
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 07/18] hw/mips/malta: Replace TARGET_MIPS64 by legacy_binary_is_64bit()
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 06/18] hw/mips/mipssim: Replace TARGET_MIPS64 by legacy_binary_is_64bit() Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 08/18] hw/i386: Inline TARGET_DEFAULT_CPU_TYPE definition Philippe Mathieu-Daudé
` (10 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy MIPS binaries, legacy_binary_is_64bit() is
equivalent of the compile time TARGET_MIPS64 definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/mips/malta.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 8e9cea70b13..3517e437f26 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -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);
}
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 08/18] hw/i386: Inline TARGET_DEFAULT_CPU_TYPE definition
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 07/18] hw/mips/malta: " Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 09/18] hw/ppc/mac: Replace TARGET_PPC64 by legacy_binary_is_64bit() Philippe Mathieu-Daudé
` (9 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 0ab2e1bdb40..7f3c1ceaca7 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -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 */
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index d0a236c74f3..cc94e1408c6 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -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";
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 63a96cd23f8..936a770aad8 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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;
diff --git a/hw/i386/xen/xen-pvh.c b/hw/i386/xen/xen-pvh.c
index 33c10279763..f0080c83021 100644
--- a/hw/i386/xen/xen-pvh.c
+++ b/hw/i386/xen/xen-pvh.c
@@ -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;
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 09/18] hw/ppc/mac: Replace TARGET_PPC64 by legacy_binary_is_64bit()
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 08/18] hw/i386: Inline TARGET_DEFAULT_CPU_TYPE definition Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper Philippe Mathieu-Daudé
` (8 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy PowerPC binaries, legacy_binary_is_64bit() is
equivalent of the compile time TARGET_PPC64 definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/ppc/mac_newworld.c | 9 ++++-----
hw/ppc/mac_oldworld.c | 5 ++---
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index cb3dc3ab482..60cca313b10 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -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;
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 0dbcea035c3..a8515778e2d 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -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;
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 09/18] hw/ppc/mac: Replace TARGET_PPC64 by legacy_binary_is_64bit() Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-06 7:28 ` Thomas Huth
2025-03-05 15:39 ` [RFC PATCH 11/18] hw/mips/jazz: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian Philippe Mathieu-Daudé
` (7 subsequent siblings)
17 siblings, 1 reply; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
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.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/legacy_binary_info.h | 8 ++++++
legacy_binary_info.c | 43 +++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/include/qemu/legacy_binary_info.h b/include/qemu/legacy_binary_info.h
index 2d42e852b7a..18886a05402 100644
--- a/include/qemu/legacy_binary_info.h
+++ b/include/qemu/legacy_binary_info.h
@@ -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
diff --git a/legacy_binary_info.c b/legacy_binary_info.c
index be50d3f50ea..c9a8e99699e 100644
--- a/legacy_binary_info.c
+++ b/legacy_binary_info.c
@@ -9,10 +9,12 @@
#include "qemu/osdep.h"
#include "qemu/arch_info.h"
#include "qemu/legacy_binary_info.h"
+#include "qapi/qapi-types-common.h"
typedef struct LegacyBinaryInfo {
const char *binary_name;
QemuArchBit arch_bit;
+ EndianMode endianness;
unsigned long_bits;
} LegacyBinaryInfo;
@@ -21,146 +23,175 @@ static const LegacyBinaryInfo legacy_binary_infos[] = {
{
.binary_name = "qemu-system-aarch64",
.arch_bit = QEMU_ARCH_BIT_ARM,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 64,
},
{
.binary_name = "qemu-system-alpha",
.arch_bit = QEMU_ARCH_BIT_ALPHA,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 64,
},
{
.binary_name = "qemu-system-arm",
.arch_bit = QEMU_ARCH_BIT_ARM,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-avr",
.arch_bit = QEMU_ARCH_BIT_AVR,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-hppa",
.arch_bit = QEMU_ARCH_BIT_HPPA,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 64,
},
{
.binary_name = "qemu-system-i386",
.arch_bit = QEMU_ARCH_BIT_I386,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-loongarch64",
.arch_bit = QEMU_ARCH_BIT_LOONGARCH,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 64,
},
{
.binary_name = "qemu-system-m68k",
.arch_bit = QEMU_ARCH_BIT_M68K,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 32,
},
{
.binary_name = "qemu-system-microblaze",
.arch_bit = QEMU_ARCH_BIT_MICROBLAZE,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 64,
},
{
.binary_name = "qemu-system-microblazeel",
.arch_bit = QEMU_ARCH_BIT_MICROBLAZE,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 64,
},
{
.binary_name = "qemu-system-mips",
.arch_bit = QEMU_ARCH_BIT_MIPS,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 64,
},
{
.binary_name = "qemu-system-mips64",
.arch_bit = QEMU_ARCH_BIT_MIPS,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 64,
},
{
.binary_name = "qemu-system-mips64el",
.arch_bit = QEMU_ARCH_BIT_MIPS,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 64,
},
{
.binary_name = "qemu-system-mipsel",
.arch_bit = QEMU_ARCH_BIT_MIPS,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-or1k",
.arch_bit = QEMU_ARCH_BIT_OPENRISC,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-ppc",
.arch_bit = QEMU_ARCH_BIT_PPC,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 32,
},
{
.binary_name = "qemu-system-ppc64",
.arch_bit = QEMU_ARCH_BIT_PPC,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 64,
},
{
.binary_name = "qemu-system-riscv32",
.arch_bit = QEMU_ARCH_BIT_RISCV,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-riscv64",
.arch_bit = QEMU_ARCH_BIT_RISCV,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 64,
},
{
.binary_name = "qemu-system-rx",
.arch_bit = QEMU_ARCH_BIT_RX,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-s390x",
.arch_bit = QEMU_ARCH_BIT_S390X,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 64,
},
{
.binary_name = "qemu-system-sh4",
.arch_bit = QEMU_ARCH_BIT_SH4,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-sh4eb",
.arch_bit = QEMU_ARCH_BIT_SH4,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 32,
},
{
.binary_name = "qemu-system-sparc",
.arch_bit = QEMU_ARCH_BIT_SPARC,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 32,
},
{
.binary_name = "qemu-system-sparc64",
.arch_bit = QEMU_ARCH_BIT_SPARC,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 64,
},
{
.binary_name = "qemu-system-tricore",
.arch_bit = QEMU_ARCH_BIT_TRICORE,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-x86_64",
.arch_bit = QEMU_ARCH_BIT_I386,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 64,
},
{
.binary_name = "qemu-system-xtensa",
.arch_bit = QEMU_ARCH_BIT_XTENSA,
+ .endianness = ENDIAN_MODE_LITTLE,
.long_bits = 32,
},
{
.binary_name = "qemu-system-xtensaeb",
.arch_bit = QEMU_ARCH_BIT_XTENSA,
+ .endianness = ENDIAN_MODE_BIG,
.long_bits = 32,
},
};
@@ -182,6 +213,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);
+ assert(legacy_binary_infos[i].endianness != ENDIAN_MODE_UNSPECIFIED);
current_index = i;
return;
}
@@ -195,3 +227,14 @@ bool legacy_binary_is_64bit(void)
assert(current_index != -1);
return legacy_binary_infos[current_index].long_bits == 64;
}
+
+EndianMode legacy_binary_endianness(void)
+{
+ assert(current_index != -1);
+ return legacy_binary_infos[current_index].endianness;
+}
+
+bool legacy_binary_is_big_endian(void)
+{
+ return legacy_binary_endianness() == ENDIAN_MODE_BIG;
+}
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper
2025-03-05 15:39 ` [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper Philippe Mathieu-Daudé
@ 2025-03-06 7:28 ` Thomas Huth
2025-03-06 14:10 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 42+ messages in thread
From: Thomas Huth @ 2025-03-06 7:28 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Alex Bennée
On 05/03/2025 16.39, Philippe Mathieu-Daudé wrote:
> 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.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> 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
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper
2025-03-06 7:28 ` Thomas Huth
@ 2025-03-06 14:10 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-06 14:10 UTC (permalink / raw)
To: Thomas Huth, qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Alex Bennée
On 6/3/25 08:28, Thomas Huth wrote:
> On 05/03/2025 16.39, Philippe Mathieu-Daudé wrote:
>> 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.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> 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()
^ permalink raw reply [flat|nested] 42+ messages in thread
* [RFC PATCH 11/18] hw/mips/jazz: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 10/18] qemu: Introduce legacy_binary_is_big_endian() helper Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 12/18] hw/mips/mipssim: Use legacy_binary_is_big_endian() Philippe Mathieu-Daudé
` (6 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy binaries, legacy_binary_is_big_endian() is equivalent
of the compile time TARGET_BIG_ENDIAN definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/mips/jazz.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index 1700c3765de..b6f7565f6c5 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -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);
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 12/18] hw/mips/mipssim: Use legacy_binary_is_big_endian()
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 11/18] hw/mips/jazz: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 13/18] hw/xtensa/sim: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian Philippe Mathieu-Daudé
` (5 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy binaries, legacy_binary_is_big_endian() is equivalent
of the compile time TARGET_BIG_ENDIAN definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/mips/mipssim.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index f94dbdc428b..c0959a9e24f 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -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. */
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 13/18] hw/xtensa/sim: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 12/18] hw/mips/mipssim: Use legacy_binary_is_big_endian() Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 14/18] hw/xtensa/xtfpga: Check endianness via legacy_binary_is_big_endian() Philippe Mathieu-Daudé
` (4 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy binaries, legacy_binary_is_big_endian() is
equivalent of the compile time TARGET_BIG_ENDIAN definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/xtensa/sim.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c
index 1cea29c66d4..cd7c6014c3b 100644
--- a/hw/xtensa/sim.c
+++ b/hw/xtensa/sim.c
@@ -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) {
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 14/18] hw/xtensa/xtfpga: Check endianness via legacy_binary_is_big_endian()
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 13/18] hw/xtensa/sim: Replace TARGET_BIG_ENDIAN by legacy_binary_is_big_endian Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 15/18] hw/microblaze/petalogix_ml605_mmu: Use legacy_binary_is_big_endian() Philippe Mathieu-Daudé
` (3 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy binaries, legacy_binary_is_big_endian() is
equivalent of the compile time TARGET_BIG_ENDIAN definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/xtensa/xtfpga.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 3f3677f1c9a..7f0a849b795 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -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);
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 15/18] hw/microblaze/petalogix_ml605_mmu: Use legacy_binary_is_big_endian()
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 14/18] hw/xtensa/xtfpga: Check endianness via legacy_binary_is_big_endian() Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 16/18] hw/microblaze/petalogix_s3adsp1800_mmu: Use legacy_binary_is_big_endian Philippe Mathieu-Daudé
` (2 subsequent siblings)
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy binaries, legacy_binary_is_big_endian() is equivalent
of the compile time TARGET_BIG_ENDIAN definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/microblaze/petalogix_ml605_mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
index 21ad215e442..f324a863772 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -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));
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 16/18] hw/microblaze/petalogix_s3adsp1800_mmu: Use legacy_binary_is_big_endian
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 15/18] hw/microblaze/petalogix_ml605_mmu: Use legacy_binary_is_big_endian() Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 17/18] meson: Allow symlinking system emulation binaries Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 18/18] configs/targets: Merge qemu-system-microblaze{el} binaries Philippe Mathieu-Daudé
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
Philippe Mathieu-Daudé
For legacy binaries, legacy_binary_is_big_endian() is equivalent
of the compile time TARGET_BIG_ENDIAN definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/microblaze/petalogix_s3adsp1800_mmu.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index bdba2006b72..12d4d6c336f 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -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;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 17/18] meson: Allow symlinking system emulation binaries
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 16/18] hw/microblaze/petalogix_s3adsp1800_mmu: Use legacy_binary_is_big_endian Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
2025-03-05 15:39 ` [RFC PATCH 18/18] configs/targets: Merge qemu-system-microblaze{el} binaries Philippe Mathieu-Daudé
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
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).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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(+)
diff --git a/meson.build b/meson.build
index e4ede6ba06f..c2b7ec57739 100644
--- a/meson.build
+++ b/meson.build
@@ -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)]
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [RFC PATCH 18/18] configs/targets: Merge qemu-system-microblaze{el} binaries
2025-03-05 15:39 [RFC PATCH 00/18] hw/microblaze: Quick single binary proof of concept Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2025-03-05 15:39 ` [RFC PATCH 17/18] meson: Allow symlinking system emulation binaries Philippe Mathieu-Daudé
@ 2025-03-05 15:39 ` Philippe Mathieu-Daudé
17 siblings, 0 replies; 42+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-05 15:39 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Thomas Huth, Alex Bennée,
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).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
configs/targets/microblazeel-softmmu.mak | 8 --------
meson.build | 4 ++--
2 files changed, 2 insertions(+), 10 deletions(-)
delete mode 100644 configs/targets/microblazeel-softmmu.mak
diff --git a/configs/targets/microblazeel-softmmu.mak b/configs/targets/microblazeel-softmmu.mak
deleted file mode 100644
index 52cdeae1a28..00000000000
--- a/configs/targets/microblazeel-softmmu.mak
+++ /dev/null
@@ -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
diff --git a/meson.build b/meson.build
index c2b7ec57739..46f97b1b7a7 100644
--- a/meson.build
+++ b/meson.build
@@ -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 = []
--
2.47.1
^ permalink raw reply related [flat|nested] 42+ messages in thread