[PATCH v3 08/11] target/arm/cpu: Expose x-mig-hidden-regs and x-mig-safe-missing-regs properties

Eric Auger posted 11 patches 2 months, 2 weeks ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, 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>
There is a newer version of this series
[PATCH v3 08/11] target/arm/cpu: Expose x-mig-hidden-regs and x-mig-safe-missing-regs properties
Posted by Eric Auger 2 months, 2 weeks ago
Allows to set both array properties along with arm cpus. Their "x-" prefix
reminds that those shall be used carefully for distro specific use cases
to garantee cross kernel migration.

This will allow to define such compat machine props like:

    static GlobalProperty arm_virt_kernel_compat_10_1[] = {
        /* KVM_REG_ARM_VENDOR_HYP_BMAP_2 */
        { TYPE_ARM_CPU, "x-mig-hidden-regs", "0x6030000000160003" },
        { TYPE_ARM_CPU, "x-mig-safe-missing-regs",
          /* TCR_EL1, PIRE0_EL1, PIR_EL1 */
          "0x603000000013c103, 0x603000000013c512, 0x603000000013c513" },
    }

The first one means KVM_REG_ARM_VENDOR_HYP_BMAP_2 shall always
been hidden for machine types older than 10.1. The second one means
that along with 10.1 machine type we may receive in the incoming
migration stream, 3 registers that are unknown on destination.

Obvioulsy, using the reg index as defined in
linux/Documentation/virt/kvm/api.rst is not user friendly. However
those options, prefixed with "x-" are supposed to be used
rarely by people who know the details.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 target/arm/cpu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 066746d76f..c41774cb4c 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -2248,6 +2248,11 @@ static const Property arm_cpu_properties[] = {
     DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, backcompat_cntfrq, false),
     DEFINE_PROP_BOOL("backcompat-pauth-default-use-qarma5", ARMCPU,
                       backcompat_pauth_default_use_qarma5, false),
+    DEFINE_PROP_ARRAY("x-mig-hidden-regs", ARMCPU,
+                      nr_hidden_regs, hidden_regs, qdev_prop_uint64, uint64_t),
+    DEFINE_PROP_ARRAY("x-mig-safe-missing-regs", ARMCPU,
+                      nr_mig_safe_missing_regs, mig_safe_missing_regs,
+                      qdev_prop_uint64, uint64_t),
 };
 
 static const gchar *arm_gdb_arch_name(CPUState *cs)
-- 
2.52.0
Re: [PATCH v3 08/11] target/arm/cpu: Expose x-mig-hidden-regs and x-mig-safe-missing-regs properties
Posted by Cornelia Huck 2 months, 2 weeks ago
On Tue, Nov 25 2025, Eric Auger <eric.auger@redhat.com> wrote:

> Allows to set both array properties along with arm cpus. Their "x-" prefix
> reminds that those shall be used carefully for distro specific use cases
> to garantee cross kernel migration.

s/garantee/enable/ ?

>
> This will allow to define such compat machine props like:
>
>     static GlobalProperty arm_virt_kernel_compat_10_1[] = {
>         /* KVM_REG_ARM_VENDOR_HYP_BMAP_2 */
>         { TYPE_ARM_CPU, "x-mig-hidden-regs", "0x6030000000160003" },
>         { TYPE_ARM_CPU, "x-mig-safe-missing-regs",
>           /* TCR_EL1, PIRE0_EL1, PIR_EL1 */
>           "0x603000000013c103, 0x603000000013c512, 0x603000000013c513" },
>     }
>
> The first one means KVM_REG_ARM_VENDOR_HYP_BMAP_2 shall always
> been hidden for machine types older than 10.1. The second one means

s/been/be/

> that along with 10.1 machine type we may receive in the incoming
> migration stream, 3 registers that are unknown on destination.
>
> Obvioulsy, using the reg index as defined in

s/Obvioulsy/Obviously/

> linux/Documentation/virt/kvm/api.rst is not user friendly. However
> those options, prefixed with "x-" are supposed to be used
> rarely by people who know the details.

"These options are supposed to be used to enable specific, rare cases,
and in general, by people trying to configure distribution defaults
familiar with those specific cases." ?

I'm not sure whether the "x-" prefix is the right choice for "do not use
unless you really know what you're doing", but OTOH, it's the prefix we
have...

>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>  target/arm/cpu.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index 066746d76f..c41774cb4c 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -2248,6 +2248,11 @@ static const Property arm_cpu_properties[] = {
>      DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, backcompat_cntfrq, false),
>      DEFINE_PROP_BOOL("backcompat-pauth-default-use-qarma5", ARMCPU,
>                        backcompat_pauth_default_use_qarma5, false),
> +    DEFINE_PROP_ARRAY("x-mig-hidden-regs", ARMCPU,
> +                      nr_hidden_regs, hidden_regs, qdev_prop_uint64, uint64_t),
> +    DEFINE_PROP_ARRAY("x-mig-safe-missing-regs", ARMCPU,
> +                      nr_mig_safe_missing_regs, mig_safe_missing_regs,
> +                      qdev_prop_uint64, uint64_t),
>  };
>  
>  static const gchar *arm_gdb_arch_name(CPUState *cs)