Skip to contentSkip to conversation

hw/arm: Move the "arm-cpu" compat settings out of hw/core/machine.c

PATCH In review Thomas Huth 3 participants 5 messages Jan 20 – Jan 21

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm: Move the "arm-cpu" compat settings out of hw/core/machine.c

From: Thomas Huth <[email protected]>

The hw_compat_* arrays in hw/core/machine.c should be used for generic compat settings that might affect all (or at least multiple) machines. Target specific settings should rather go into the target specific source files instead. For arm/aarch64, the virt machine is the only one that cares about compat settings, so move the "arm-cpu" related switches to hw/arm/virt.c now.

---
 hw/arm/virt.c     | 10 ++++++++++
 hw/core/machine.c |  2 --
 2 files changed, 10 insertions(+), 2 deletions(-)
hw/arm/virt.c +10 -0
index 4badc1a7348..99040e08f6a 100644
@@ -3571,8 +3571,13 @@ DEFINE_VIRT_MACHINE(10, 0)
 
 static void virt_machine_9_2_options(MachineClass *mc)
 {
+    static GlobalProperty compat_9_2[] = {
+        { "arm-cpu", "backcompat-pauth-default-use-qarma5", "true"},
+    };
+
     virt_machine_10_0_options(mc);
     compat_props_add(mc->compat_props, hw_compat_9_2, hw_compat_9_2_len);
+    compat_props_add(mc->compat_props, compat_9_2, G_N_ELEMENTS(compat_9_2));
 }
 DEFINE_VIRT_MACHINE(9, 2)
 
@@ -3589,9 +3594,14 @@ DEFINE_VIRT_MACHINE(9, 1)
 
 static void virt_machine_9_0_options(MachineClass *mc)
 {
+    static GlobalProperty compat_9_0[] = {
+        { "arm-cpu", "backcompat-cntfrq", "true" },
+    };
+
     virt_machine_9_1_options(mc);
     mc->smbios_memory_device_size = 16 * GiB;
     compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len);
+    compat_props_add(mc->compat_props, compat_9_0, G_N_ELEMENTS(compat_9_0));
 }
 DEFINE_VIRT_MACHINE(9, 0)
 
hw/core/machine.c +0 -2
index 6411e68856b..1c1de7b5d18 100644
@@ -59,7 +59,6 @@ GlobalProperty hw_compat_10_0[] = {
 const size_t hw_compat_10_0_len = G_N_ELEMENTS(hw_compat_10_0);
 
 GlobalProperty hw_compat_9_2[] = {
-    { "arm-cpu", "backcompat-pauth-default-use-qarma5", "true"},
     { "virtio-balloon-pci", "vectors", "0" },
     { "virtio-balloon-pci-transitional", "vectors", "0" },
     { "virtio-balloon-pci-non-transitional", "vectors", "0" },
@@ -76,7 +75,6 @@ GlobalProperty hw_compat_9_1[] = {
 const size_t hw_compat_9_1_len = G_N_ELEMENTS(hw_compat_9_1);
 
 GlobalProperty hw_compat_9_0[] = {
-    { "arm-cpu", "backcompat-cntfrq", "true" },
     { "scsi-hd", "migrate-emulated-scsi-request", "false" },
     { "scsi-cd", "migrate-emulated-scsi-request", "false" },
     { "vfio-pci", "skip-vsc-check", "false" },
Signature · 1 line
2.52.0
#1 lore raw
Quoted 9 lines · Thomas Huth

From: Thomas Huth <[email protected]>

The hw_compat_* arrays in hw/core/machine.c should be used for generic compat settings that might affect all (or at least multiple) machines. Target specific settings should rather go into the target specific source files instead. For arm/aarch64, the virt machine is the only one that cares about compat settings, so move the "arm-cpu" related switches to hw/arm/virt.c now.

I think it makes more sense for all the compat stuff to live in one place, rather than being scattered around, unless it is truly machine-specific (which this isn't). The hw/core arrays seem to be where we put compat props which are related to a particular device rather than a specific machine.

thanks
-- PMM

#2 lore raw
Quoted 11 lines · Peter Maydell
Quoted 9 lines · Thomas Huth

From: Thomas Huth <[email protected]>

The hw_compat_* arrays in hw/core/machine.c should be used for generic compat settings that might affect all (or at least multiple) machines. Target specific settings should rather go into the target specific source files instead. For arm/aarch64, the virt machine is the only one that cares about compat settings, so move the "arm-cpu" related switches to hw/arm/virt.c now.

Quoted 3 lines

I think it makes more sense for all the compat stuff to live in one place, rather than being scattered around, unless it is truly machine-specific (which this isn't).

It's only used by the arm virt machine, so it's IMHO machine specific.
If we will ever get other versionized arm machines, they won't use these config knobs, so this never will be shared with another machine.

Quoted 3 lines

The hw/core arrays seem to be where we put compat props which are related to a particular device rather than a specific machine.

IMHO it makes sense if multiple machines use such config knobs, but if it is really only related to one machine ... not so much.

Thomas

#3 lore raw
Quoted 13 lines · Thomas Huth
Quoted 11 lines · Peter Maydell
Quoted 9 lines · Thomas Huth

From: Thomas Huth <[email protected]>

The hw_compat_* arrays in hw/core/machine.c should be used for generic compat settings that might affect all (or at least multiple) machines. Target specific settings should rather go into the target specific source files instead. For arm/aarch64, the virt machine is the only one that cares about compat settings, so move the "arm-cpu" related switches to hw/arm/virt.c now.

Quoted 7 lines
Quoted 3 lines

I think it makes more sense for all the compat stuff to live in one place, rather than being scattered around, unless it is truly machine-specific (which this isn't).

It's only used by the arm virt machine, so it's IMHO machine specific. If we will ever get other versionized arm machines, they won't use these config knobs, so this never will be shared with another machine.

It happens to be only used by the virt board, but that's just a coincidence that we only have one versioned arm board right now. The config knob itself is not at all board specific:
it applies to a device object that is used by many boards and sets a behaviour that would usefully apply to all of them. If we ever did have more arm versioned machines in the future we'd end up with a weird split where compat properties of the CPU object that happened to pre-date the addition of that second machine type would be in one place in the source code, and properties that happened to post-date the second machine type would be somewhere else.

thanks
-- PMM

#4 lore raw
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Thomas Huth
Quoted 2 lines · Peter Maydell
Quoted 1 line · Thomas Huth
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

From: Thomas Huth <[email protected]>

The hw_compat_* arrays in hw/core/machine.c should be used for generic compat settings that might affect all (or at least multiple) machines. Target specific settings should rather go into the target specific source files instead. For arm/aarch64, the virt machine is the only one that cares about compat settings, so move the "arm-cpu" related switches to hw/arm/virt.c now.

FWIW, this is not the only arch-specific setting in there, and I don't think it's really bothersome. There are many compat settings that might not be applicable when you spin up a machine, and that's fine.

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

I think it makes more sense for all the compat stuff to live in one place, rather than being scattered around, unless it is truly machine-specific (which this isn't).

It's only used by the arm virt machine, so it's IMHO machine specific. If we will ever get other versionized arm machines, they won't use these config knobs, so this never will be shared with another machine.

Quoted 11 lines

It happens to be only used by the virt board, but that's just a coincidence that we only have one versioned arm board right now. The config knob itself is not at all board specific:
it applies to a device object that is used by many boards and sets a behaviour that would usefully apply to all of them. If we ever did have more arm versioned machines in the future we'd end up with a weird split where compat properties of the CPU object that happened to pre-date the addition of that second machine type would be in one place in the source code, and properties that happened to post-date the second machine type would be somewhere else.

I think there are only two options that really make sense:
- keep the compat setting where it is
- introduce an arm specific compat array that can be included by the virt machine and any future versioned arm machine

Not sure if the latter is actually worth the hassle.