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

Thomas Huth posted 1 patch 2 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260120122108.131708-1-thuth@redhat.com
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>
hw/arm/virt.c     | 10 ++++++++++
hw/core/machine.c |  2 --
2 files changed, 10 insertions(+), 2 deletions(-)
[PATCH] hw/arm: Move the "arm-cpu" compat settings out of hw/core/machine.c
Posted by Thomas Huth 2 weeks, 3 days ago
From: Thomas Huth <thuth@redhat.com>

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.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/arm/virt.c     | 10 ++++++++++
 hw/core/machine.c |  2 --
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 4badc1a7348..99040e08f6a 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -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)
 
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 6411e68856b..1c1de7b5d18 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -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" },
-- 
2.52.0
Re: [PATCH] hw/arm: Move the "arm-cpu" compat settings out of hw/core/machine.c
Posted by Peter Maydell 2 weeks, 3 days ago
On Tue, 20 Jan 2026 at 12:21, Thomas Huth <thuth@redhat.com> wrote:
>
> From: Thomas Huth <thuth@redhat.com>
>
> 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
Re: [PATCH] hw/arm: Move the "arm-cpu" compat settings out of hw/core/machine.c
Posted by Thomas Huth 2 weeks, 3 days ago
On 20/01/2026 13.55, Peter Maydell wrote:
> On Tue, 20 Jan 2026 at 12:21, Thomas Huth <thuth@redhat.com> wrote:
>>
>> From: Thomas Huth <thuth@redhat.com>
>>
>> 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).

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.

> 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
Re: [PATCH] hw/arm: Move the "arm-cpu" compat settings out of hw/core/machine.c
Posted by Peter Maydell 2 weeks, 3 days ago
On Tue, 20 Jan 2026 at 14:15, Thomas Huth <thuth@redhat.com> wrote:
>
> On 20/01/2026 13.55, Peter Maydell wrote:
> > On Tue, 20 Jan 2026 at 12:21, Thomas Huth <thuth@redhat.com> wrote:
> >>
> >> From: Thomas Huth <thuth@redhat.com>
> >>
> >> 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).
>
> 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
Re: [PATCH] hw/arm: Move the "arm-cpu" compat settings out of hw/core/machine.c
Posted by Cornelia Huck 2 weeks, 2 days ago
On Tue, Jan 20 2026, Peter Maydell <peter.maydell@linaro.org> wrote:

> On Tue, 20 Jan 2026 at 14:15, Thomas Huth <thuth@redhat.com> wrote:
>>
>> On 20/01/2026 13.55, Peter Maydell wrote:
>> > On Tue, 20 Jan 2026 at 12:21, Thomas Huth <thuth@redhat.com> wrote:
>> >>
>> >> From: Thomas Huth <thuth@redhat.com>
>> >>
>> >> 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.

>> >
>> > 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.

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.