Skip to contentSkip to conversation

hw/arm/virt.c: Fix wrong default cpu type in AARCH64

PATCH In review Zhang Chen 4 participants 8 messages Apr 2, 2025 – Apr 29, 2025

lore
Share & tools
lore

Zhang Chen

author
#0 lore raw

PATCH 1/1 hw/arm/virt.c: Fix wrong default cpu type in AARCH64

Because of the CONFIG_TCG auto enabled, the cpu type "cortex-a15" is mistakenly set to the default AARCH64 target.

---
 hw/arm/virt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/arm/virt.c +3 -2
index a96452f17a..63649e9543 100644
@@ -3178,9 +3178,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
 #ifdef CONFIG_TCG
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
-#else
+#ifdef TARGET_AARCH64
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
-#endif
+#endif /* TARGET_AARCH64 */
+#endif /* CONFIG_TCG */
     mc->valid_cpu_types = valid_cpu_types;
     mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
     mc->kvm_type = virt_kvm_type;
Signature · 1 line
2.49.0
#1 lore raw
Quoted 2 lines · Zhang Chen

Because of the CONFIG_TCG auto enabled, the cpu type "cortex-a15" is mistakenly set to the default AARCH64 target.

This is the correct backward compatible setting. In essence, it means that you *must* supply a -cpu argument.

r~

Quoted 23 lines
---
  hw/arm/virt.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
hw/arm/virt.c +3 -2
index a96452f17a..63649e9543 100644
@@ -3178,9 +3178,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
      mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
  #ifdef CONFIG_TCG
      mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
-#else
+#ifdef TARGET_AARCH64
      mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
-#endif
+#endif /* TARGET_AARCH64 */
+#endif /* CONFIG_TCG */
      mc->valid_cpu_types = valid_cpu_types;
      mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
      mc->kvm_type = virt_kvm_type;
author
#2 lore raw
Quoted 9 lines · Richard Henderson
Quoted 2 lines · Zhang Chen

Because of the CONFIG_TCG auto enabled, the cpu type "cortex-a15" is mistakenly set to the default AARCH64 target.

This is the correct backward compatible setting. In essence, it means that you *must* supply a -cpu argument.

If the "-cpu" is required, the VM should not be started without this argument. If yes, I will skip this patch and submit another one to make QEMU refuse to start without this parameter.

Thanks
Chen

Quoted 27 lines

r~

Quoted 23 lines
---
  hw/arm/virt.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
hw/arm/virt.c +3 -2
index a96452f17a..63649e9543 100644
@@ -3178,9 +3178,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
      mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
  #ifdef CONFIG_TCG
      mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
-#else
+#ifdef TARGET_AARCH64
      mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
-#endif
+#endif /* TARGET_AARCH64 */
+#endif /* CONFIG_TCG */
      mc->valid_cpu_types = valid_cpu_types;
      mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
      mc->kvm_type = virt_kvm_type;
author
#3 lore raw
Quoted 8 lines · Zhang Chen
Quoted 5 lines · Richard Henderson
Quoted 2 lines · Zhang Chen

Because of the CONFIG_TCG auto enabled, the cpu type "cortex-a15" is mistakenly set to the default AARCH64 target.

Quoted 9 lines
Quoted 4 lines

This is the correct backward compatible setting. In essence, it means that you *must* supply a -cpu argument.

If the "-cpu" is required, the VM should not be started without this argument. If yes, I will skip this patch and submit another one to make QEMU refuse to start without this parameter.

Ping... and let me explain this status, it is not just for the default value.
1. The cpu type "cortex-a15" is not the correct backward compatible setting for AARCH64 target.
The ARM cortex-a15 is a 32 bit CPU based on ARMv7-A architecture. It can not boot for AARCH64 target.
For example, the Apple M silicon can not boot with the default -cpu value.

2. Most of QEMU docs does not said user *must* supply a -cpu argument.
https://www.qemu.org/docs/master/system/qemu-manpage.html

Thanks
Chen

Quoted 30 lines

Thanks
Chen

Quoted 27 lines

r~

Quoted 23 lines
---
  hw/arm/virt.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
hw/arm/virt.c +3 -2
index a96452f17a..63649e9543 100644
@@ -3178,9 +3178,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
      mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
  #ifdef CONFIG_TCG
      mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
-#else
+#ifdef TARGET_AARCH64
      mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
-#endif
+#endif /* TARGET_AARCH64 */
+#endif /* CONFIG_TCG */
      mc->valid_cpu_types = valid_cpu_types;
      mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
      mc->kvm_type = virt_kvm_type;
#4 lore raw
Quoted 14 lines · Zhang Chen
Quoted 13 lines · Zhang Chen
Quoted 9 lines · Richard Henderson
Quoted 2 lines · Zhang Chen

Because of the CONFIG_TCG auto enabled, the cpu type "cortex-a15" is mistakenly set to the default AARCH64 target.

This is the correct backward compatible setting. In essence, it means that you *must* supply a -cpu argument.

Quoted 8 lines
Quoted 4 lines

If the "-cpu" is required, the VM should not be started without this argument. If yes, I will skip this patch and submit another one to make QEMU refuse to start without this parameter.

Ping... and let me explain this status, it is not just for the default value.
1. The cpu type "cortex-a15" is not the correct backward compatible setting for AARCH64 target.

IIUC it was meant to be backward compatible for KVM (as in "not TCG"), HVF was not a thing for ARM at this time.

Quoted 3 lines

The ARM cortex-a15 is a 32 bit CPU based on ARMv7-A architecture. It can not boot for AARCH64 target.
For example, the Apple M silicon can not boot with the default -cpu value.

A respin of this series might help you, I'll try to remember to Cc you:
https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 37 lines

2. Most of QEMU docs does not said user *must* supply a -cpu argument.
https://www.qemu.org/docs/master/system/qemu-manpage.html

Thanks
Chen

Quoted 30 lines

Thanks
Chen

Quoted 27 lines

r~

Quoted 23 lines
---
   hw/arm/virt.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
hw/arm/virt.c +3 -2
index a96452f17a..63649e9543 100644
@@ -3178,9 +3178,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
       mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
   #ifdef CONFIG_TCG
       mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
-#else
+#ifdef TARGET_AARCH64
       mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
-#endif
+#endif /* TARGET_AARCH64 */
+#endif /* CONFIG_TCG */
       mc->valid_cpu_types = valid_cpu_types;
       mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
       mc->kvm_type = virt_kvm_type;
author
#5 lore raw
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Zhang Chen
Quoted 13 lines · Zhang Chen
Quoted 9 lines · Richard Henderson
Quoted 2 lines · Zhang Chen

Because of the CONFIG_TCG auto enabled, the cpu type "cortex-a15" is mistakenly set to the default AARCH64 target.

This is the correct backward compatible setting. In essence, it means that you *must* supply a -cpu argument.

Quoted 8 lines
Quoted 4 lines

If the "-cpu" is required, the VM should not be started without this argument. If yes, I will skip this patch and submit another one to make QEMU refuse to start without this parameter.

Ping... and let me explain this status, it is not just for the default value.
1. The cpu type "cortex-a15" is not the correct backward compatible setting for AARCH64 target.

IIUC it was meant to be backward compatible for KVM (as in "not TCG"), HVF was not a thing for ARM at this time.

Quoted 7 lines
Quoted 3 lines

The ARM cortex-a15 is a 32 bit CPU based on ARMv7-A architecture. It can not boot for AARCH64 target.
For example, the Apple M silicon can not boot with the default -cpu value.

A respin of this series might help you, I'll try to remember to Cc you:
https://lore.kernel.org/qemu-devel/[email protected]/

Thanks Philippe, your patch fix the same issue and looks good for me. Let's drop this patch.

Thanks
Chen

Quoted 38 lines
Quoted 37 lines

2. Most of QEMU docs does not said user *must* supply a -cpu argument.
https://www.qemu.org/docs/master/system/qemu-manpage.html

Thanks
Chen

Quoted 30 lines

Thanks
Chen

Quoted 27 lines

r~

Quoted 23 lines
---
   hw/arm/virt.c | 5 +++--
   1 file changed, 3 insertions(+), 2 deletions(-)
hw/arm/virt.c +3 -2
index a96452f17a..63649e9543 100644
@@ -3178,9 +3178,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
       mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
   #ifdef CONFIG_TCG
       mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
-#else
+#ifdef TARGET_AARCH64
       mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
-#endif
+#endif /* TARGET_AARCH64 */
+#endif /* CONFIG_TCG */
       mc->valid_cpu_types = valid_cpu_types;
       mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
       mc->kvm_type = virt_kvm_type;
#6 lore raw
In reply to Zhang Chen
Quoted 20 lines · Zhang Chen
Quoted 8 lines · Zhang Chen
Quoted 5 lines · Richard Henderson
Quoted 2 lines · Zhang Chen

Because of the CONFIG_TCG auto enabled, the cpu type "cortex-a15" is mistakenly set to the default AARCH64 target.

Quoted 9 lines
Quoted 4 lines

This is the correct backward compatible setting. In essence, it means that you *must* supply a -cpu argument.

If the "-cpu" is required, the VM should not be started without this argument. If yes, I will skip this patch and submit another one to make QEMU refuse to start without this parameter.

Quoted 6 lines

Ping... and let me explain this status, it is not just for the default value.
1. The cpu type "cortex-a15" is not the correct backward compatible setting for AARCH64 target.
The ARM cortex-a15 is a 32 bit CPU based on ARMv7-A architecture. It can not boot for AARCH64 target.
For example, the Apple M silicon can not boot with the default -cpu value.

'qemu-system-aarch64' doesn't mean "I want an AArch64 CPU", it just means that you can select AArch64 machines and CPUs. Almost all command lines that work with qemu-system-arm also do the same thing if run with qemu-system-aarch64. So in this case, "qemu-system-aarch64 -M virt" does the same as "qemu-system-arm -M virt", including the CPU type selected.

The Cortex-A15 is now very rarely what anybody wants, but we keep it this way to avoid breaking existing users' command lines. (It works fine if you pass it a 32-bit guest kernel.)

thanks
-- PMM

author
#7 lore raw
Quoted 36 lines · Peter Maydell
Quoted 20 lines · Zhang Chen
Quoted 8 lines · Zhang Chen
Quoted 5 lines · Richard Henderson
Quoted 2 lines · Zhang Chen

Because of the CONFIG_TCG auto enabled, the cpu type "cortex-a15" is mistakenly set to the default AARCH64 target.

Quoted 9 lines
Quoted 4 lines

This is the correct backward compatible setting. In essence, it means that you *must* supply a -cpu argument.

If the "-cpu" is required, the VM should not be started without this argument. If yes, I will skip this patch and submit another one to make QEMU refuse to start without this parameter.

Quoted 6 lines

Ping... and let me explain this status, it is not just for the default value.
1. The cpu type "cortex-a15" is not the correct backward compatible setting for AARCH64 target.
The ARM cortex-a15 is a 32 bit CPU based on ARMv7-A architecture. It can not boot for AARCH64 target.
For example, the Apple M silicon can not boot with the default -cpu value.

'qemu-system-aarch64' doesn't mean "I want an AArch64 CPU", it just means that you can select AArch64 machines and CPUs. Almost all command lines that work with qemu-system-arm also do the same thing if run with qemu-system-aarch64. So in this case, "qemu-system-aarch64 -M virt" does the same as "qemu-system-arm -M virt", including the CPU type selected.

Quoted 3 lines

The Cortex-A15 is now very rarely what anybody wants, but we keep it this way to avoid breaking existing users' command lines. (It works fine if you pass it a 32-bit guest kernel.)

Thanks Peter for the detailed explanation. I got the background of the AArch64. I'm just interested in Apple M silicon with HVF recently.

Thanks
Chen

Quoted 3 lines

thanks
-- PMM