[RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props

Eric Auger posted 24 patches 6 months, 3 weeks ago
[RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Posted by Eric Auger 6 months, 3 weeks ago
acpi_pcihp VirtMachineClass state flag will allow
to opt in for acpi pci hotplug. This is guarded by a
class no_acpi_pcihp flag to manage compats (<= 10.0
machine types will not support ACPI PCI hotplug).

Machine state acpi_pcihp flag msu be set before the creation
of the GED device which will use it.

Currently the ACPI PCI HP is turned off by default. This will
change later on for 10.1 machine type.

We also introduce properties to allow disabling it.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 include/hw/arm/virt.h |  2 ++
 hw/arm/virt.c         | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index c8e94e6aed..1e9d002880 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -135,6 +135,7 @@ struct VirtMachineClass {
     bool no_tcg_lpa2;
     bool no_ns_el2_virt_timer_irq;
     bool no_nested_smmu;
+    bool no_acpi_pcihp;
 };
 
 struct VirtMachineState {
@@ -156,6 +157,7 @@ struct VirtMachineState {
     bool mte;
     bool dtb_randomness;
     bool second_ns_uart_present;
+    bool acpi_pcihp;
     OnOffAuto acpi;
     VirtGICType gic_version;
     VirtIOMMUType iommu;
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 3e72adaa91..1601750913 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine)
     create_pcie(vms);
 
     if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) {
+        vms->acpi_pcihp &= !vmc->no_acpi_pcihp;
         vms->acpi_dev = create_acpi_ged(vms);
     } else {
+        vms->acpi_pcihp = false;
         create_gpio_devices(vms, VIRT_GPIO, sysmem);
     }
 
@@ -2610,6 +2612,20 @@ static void virt_set_its(Object *obj, bool value, Error **errp)
     vms->its = value;
 }
 
+static bool virt_get_acpi_pcihp(Object *obj, Error **errp)
+{
+    VirtMachineState *vms = VIRT_MACHINE(obj);
+
+    return vms->acpi_pcihp;
+}
+
+static void virt_set_acpi_pcihp(Object *obj, bool value, Error **errp)
+{
+    VirtMachineState *vms = VIRT_MACHINE(obj);
+
+    vms->acpi_pcihp = value;
+}
+
 static bool virt_get_dtb_randomness(Object *obj, Error **errp)
 {
     VirtMachineState *vms = VIRT_MACHINE(obj);
@@ -3327,6 +3343,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
                                           "in ACPI table header."
                                           "The string may be up to 8 bytes in size");
 
+    object_class_property_add_bool(oc, "acpi-pcihp",
+                                   virt_get_acpi_pcihp, virt_set_acpi_pcihp);
+    object_class_property_set_description(oc, "acpi-pcihp",
+                                          "Force acpi pci hotplug");
 }
 
 static void virt_instance_init(Object *obj)
@@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj)
         }
     }
 
+    /* default disallows ACPI PCI hotplug */
+    vms->acpi_pcihp = false;
+
     /* Default disallows iommu instantiation */
     vms->iommu = VIRT_IOMMU_NONE;
 
@@ -3415,8 +3438,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)
 
 static void virt_machine_10_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_10_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_10_0, hw_compat_10_0_len);
+    /* 10.0 and earlier do not support ACPI PCI hotplug */
+    vmc->no_acpi_pcihp = true;
 }
 DEFINE_VIRT_MACHINE(10, 0)
 
-- 
2.49.0
Re: [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Posted by Gustavo Romero 6 months, 1 week ago
Hi Eric,

On 4/28/25 07:25, Eric Auger wrote:
> acpi_pcihp VirtMachineClass state flag will allow
> to opt in for acpi pci hotplug. This is guarded by a
> class no_acpi_pcihp flag to manage compats (<= 10.0
> machine types will not support ACPI PCI hotplug).
> 
> Machine state acpi_pcihp flag msu be set before the creation
                         nit:    ^--- must be set


> of the GED device which will use it.
> 
> Currently the ACPI PCI HP is turned off by default. This will
> change later on for 10.1 machine type.
> 
> We also introduce properties to allow disabling it.
> 
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>   include/hw/arm/virt.h |  2 ++
>   hw/arm/virt.c         | 27 +++++++++++++++++++++++++++
>   2 files changed, 29 insertions(+)
> 
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index c8e94e6aed..1e9d002880 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -135,6 +135,7 @@ struct VirtMachineClass {
>       bool no_tcg_lpa2;
>       bool no_ns_el2_virt_timer_irq;
>       bool no_nested_smmu;
> +    bool no_acpi_pcihp;
>   };
>   
>   struct VirtMachineState {
> @@ -156,6 +157,7 @@ struct VirtMachineState {
>       bool mte;
>       bool dtb_randomness;
>       bool second_ns_uart_present;
> +    bool acpi_pcihp;
>       OnOffAuto acpi;
>       VirtGICType gic_version;
>       VirtIOMMUType iommu;
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 3e72adaa91..1601750913 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine)
>       create_pcie(vms);
>   
>       if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) {
> +        vms->acpi_pcihp &= !vmc->no_acpi_pcihp;
>           vms->acpi_dev = create_acpi_ged(vms);
>       } else {
> +        vms->acpi_pcihp = false;
>           create_gpio_devices(vms, VIRT_GPIO, sysmem);
>       }
>   
> @@ -2610,6 +2612,20 @@ static void virt_set_its(Object *obj, bool value, Error **errp)
>       vms->its = value;
>   }
>   
> +static bool virt_get_acpi_pcihp(Object *obj, Error **errp)
> +{
> +    VirtMachineState *vms = VIRT_MACHINE(obj);
> +
> +    return vms->acpi_pcihp;
> +}
> +
> +static void virt_set_acpi_pcihp(Object *obj, bool value, Error **errp)
> +{
> +    VirtMachineState *vms = VIRT_MACHINE(obj);
> +
> +    vms->acpi_pcihp = value;
> +}
> +
>   static bool virt_get_dtb_randomness(Object *obj, Error **errp)
>   {
>       VirtMachineState *vms = VIRT_MACHINE(obj);
> @@ -3327,6 +3343,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
>                                             "in ACPI table header."
>                                             "The string may be up to 8 bytes in size");
>   
> +    object_class_property_add_bool(oc, "acpi-pcihp",
> +                                   virt_get_acpi_pcihp, virt_set_acpi_pcihp);
> +    object_class_property_set_description(oc, "acpi-pcihp",
> +                                          "Force acpi pci hotplug");

How about "Force ACPI PCI hotplug"?


>   }
>   
>   static void virt_instance_init(Object *obj)
> @@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj)
>           }
>       }
>   
> +    /* default disallows ACPI PCI hotplug */
> +    vms->acpi_pcihp = false;
> +
>       /* Default disallows iommu instantiation */
>       vms->iommu = VIRT_IOMMU_NONE;
>   
> @@ -3415,8 +3438,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)
>   
>   static void virt_machine_10_0_options(MachineClass *mc)
>   {
> +    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
> +
>       virt_machine_10_1_options(mc);
>       compat_props_add(mc->compat_props, hw_compat_10_0, hw_compat_10_0_len);
> +    /* 10.0 and earlier do not support ACPI PCI hotplug */
> +    vmc->no_acpi_pcihp = true;
>   }
>   DEFINE_VIRT_MACHINE(10, 0)
>   

Otherwise,

Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>


Cheers,
Gustavo
Re: [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Posted by Eric Auger 6 months, 1 week ago
Hi Gustavo,

On 5/6/25 2:12 AM, Gustavo Romero wrote:
> Hi Eric,
>
> On 4/28/25 07:25, Eric Auger wrote:
>> acpi_pcihp VirtMachineClass state flag will allow
>> to opt in for acpi pci hotplug. This is guarded by a
>> class no_acpi_pcihp flag to manage compats (<= 10.0
>> machine types will not support ACPI PCI hotplug).
>>
>> Machine state acpi_pcihp flag msu be set before the creation
>                         nit:    ^--- must be set
>
>
>> of the GED device which will use it.
>>
>> Currently the ACPI PCI HP is turned off by default. This will
>> change later on for 10.1 machine type.
>>
>> We also introduce properties to allow disabling it.
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>>   include/hw/arm/virt.h |  2 ++
>>   hw/arm/virt.c         | 27 +++++++++++++++++++++++++++
>>   2 files changed, 29 insertions(+)
>>
>> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
>> index c8e94e6aed..1e9d002880 100644
>> --- a/include/hw/arm/virt.h
>> +++ b/include/hw/arm/virt.h
>> @@ -135,6 +135,7 @@ struct VirtMachineClass {
>>       bool no_tcg_lpa2;
>>       bool no_ns_el2_virt_timer_irq;
>>       bool no_nested_smmu;
>> +    bool no_acpi_pcihp;
>>   };
>>     struct VirtMachineState {
>> @@ -156,6 +157,7 @@ struct VirtMachineState {
>>       bool mte;
>>       bool dtb_randomness;
>>       bool second_ns_uart_present;
>> +    bool acpi_pcihp;
>>       OnOffAuto acpi;
>>       VirtGICType gic_version;
>>       VirtIOMMUType iommu;
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index 3e72adaa91..1601750913 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine)
>>       create_pcie(vms);
>>         if (has_ged && aarch64 && firmware_loaded &&
>> virt_is_acpi_enabled(vms)) {
>> +        vms->acpi_pcihp &= !vmc->no_acpi_pcihp;
>>           vms->acpi_dev = create_acpi_ged(vms);
>>       } else {
>> +        vms->acpi_pcihp = false;
>>           create_gpio_devices(vms, VIRT_GPIO, sysmem);
>>       }
>>   @@ -2610,6 +2612,20 @@ static void virt_set_its(Object *obj, bool
>> value, Error **errp)
>>       vms->its = value;
>>   }
>>   +static bool virt_get_acpi_pcihp(Object *obj, Error **errp)
>> +{
>> +    VirtMachineState *vms = VIRT_MACHINE(obj);
>> +
>> +    return vms->acpi_pcihp;
>> +}
>> +
>> +static void virt_set_acpi_pcihp(Object *obj, bool value, Error **errp)
>> +{
>> +    VirtMachineState *vms = VIRT_MACHINE(obj);
>> +
>> +    vms->acpi_pcihp = value;
>> +}
>> +
>>   static bool virt_get_dtb_randomness(Object *obj, Error **errp)
>>   {
>>       VirtMachineState *vms = VIRT_MACHINE(obj);
>> @@ -3327,6 +3343,10 @@ static void
>> virt_machine_class_init(ObjectClass *oc, void *data)
>>                                             "in ACPI table header."
>>                                             "The string may be up to
>> 8 bytes in size");
>>   +    object_class_property_add_bool(oc, "acpi-pcihp",
>> +                                   virt_get_acpi_pcihp,
>> virt_set_acpi_pcihp);
>> +    object_class_property_set_description(oc, "acpi-pcihp",
>> +                                          "Force acpi pci hotplug");
>
> How about "Force ACPI PCI hotplug"?

Sure.

Thanks!

Eric
>
>
>>   }
>>     static void virt_instance_init(Object *obj)
>> @@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj)
>>           }
>>       }
>>   +    /* default disallows ACPI PCI hotplug */
>> +    vms->acpi_pcihp = false;
>> +
>>       /* Default disallows iommu instantiation */
>>       vms->iommu = VIRT_IOMMU_NONE;
>>   @@ -3415,8 +3438,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)
>>     static void virt_machine_10_0_options(MachineClass *mc)
>>   {
>> +    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
>> +
>>       virt_machine_10_1_options(mc);
>>       compat_props_add(mc->compat_props, hw_compat_10_0,
>> hw_compat_10_0_len);
>> +    /* 10.0 and earlier do not support ACPI PCI hotplug */
>> +    vmc->no_acpi_pcihp = true;
>>   }
>>   DEFINE_VIRT_MACHINE(10, 0)
>>   
>
> Otherwise,
>
> Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
>
>
> Cheers,
> Gustavo
>