diff mbox series

[RFC,V2,17/37] arm/virt/acpi: Build CPUs AML with CPU Hotplug support

Message ID 20230926100436.28284-18-salil.mehta@huawei.com (mailing list archive)
State New, archived
Headers show
Series Support of Virtual CPU Hotplug for ARMv8 Arch | expand

Commit Message

Salil Mehta Sept. 26, 2023, 10:04 a.m. UTC
Support of vCPU Hotplug requires sequence of ACPI handshakes between Qemu and
Guest kernel when a vCPU is plugged or unplugged. Most of the AML code to
support these handshakes already exists. This AML need to be build during VM
init for ARM architecture as well if the GED support exists.

Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 hw/arm/virt-acpi-build.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Gavin Shan Sept. 28, 2023, 1:36 a.m. UTC | #1
Hi Salil,

On 9/26/23 20:04, Salil Mehta wrote:
> Support of vCPU Hotplug requires sequence of ACPI handshakes between Qemu and
> Guest kernel when a vCPU is plugged or unplugged. Most of the AML code to
> support these handshakes already exists. This AML need to be build during VM
> init for ARM architecture as well if the GED support exists.
> 
> Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
> ---
>   hw/arm/virt-acpi-build.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 6b674231c2..d27df5030e 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -858,7 +858,18 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>        * the RTC ACPI device at all when using UEFI.
>        */
>       scope = aml_scope("\\_SB");
> -    acpi_dsdt_add_cpus(scope, vms);
> +    /* if GED is enabled then cpus AML shall be added as part build_cpus_aml */
> +    if (vms->acpi_dev) {
> +        CPUHotplugFeatures opts = {
> +             .acpi_1_compatible = false,
> +             .has_legacy_cphp = false
> +        };
> +
> +        build_cpus_aml(scope, ms, opts, memmap[VIRT_CPUHP_ACPI].base,
> +                       "\\_SB", NULL, AML_SYSTEM_MEMORY);
> +    } else {
> +        acpi_dsdt_add_cpus(scope, vms);
> +    }
>       acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
>                          (irqmap[VIRT_UART] + ARM_SPI_BASE));
>       if (vmc->acpi_expose_flash) {

I don't think it's enough to check vms->acpi_dev. vCPU hotplug needn't to be
supported even vms->acpi_dev exists. For example when vGICv2 instead of
vGICv3 is enabled, and so on.

Thanks,
Gavin
Salil Mehta Oct. 16, 2023, 10:05 p.m. UTC | #2
> From: Gavin Shan <gshan@redhat.com>
> Sent: Thursday, September 28, 2023 2:36 AM
> To: Salil Mehta <salil.mehta@huawei.com>; qemu-devel@nongnu.org; qemu-
> arm@nongnu.org
> Cc: maz@kernel.org; jean-philippe@linaro.org; Jonathan Cameron
> <jonathan.cameron@huawei.com>; lpieralisi@kernel.org;
> peter.maydell@linaro.org; richard.henderson@linaro.org;
> imammedo@redhat.com; andrew.jones@linux.dev; david@redhat.com;
> philmd@linaro.org; eric.auger@redhat.com; will@kernel.org; ardb@kernel.org;
> oliver.upton@linux.dev; pbonzini@redhat.com; mst@redhat.com;
> rafael@kernel.org; borntraeger@linux.ibm.com; alex.bennee@linaro.org;
> linux@armlinux.org.uk; darren@os.amperecomputing.com;
> ilkka@os.amperecomputing.com; vishnu@os.amperecomputing.com;
> karl.heubaum@oracle.com; miguel.luis@oracle.com; salil.mehta@opnsrc.net;
> zhukeqian <zhukeqian1@huawei.com>; wangxiongfeng (C)
> <wangxiongfeng2@huawei.com>; wangyanan (Y) <wangyanan55@huawei.com>;
> jiakernel2@gmail.com; maobibo@loongson.cn; lixianglai@loongson.cn
> Subject: Re: [PATCH RFC V2 17/37] arm/virt/acpi: Build CPUs AML with CPU
> Hotplug support
> 
> Hi Salil,
> 
> On 9/26/23 20:04, Salil Mehta wrote:
> > Support of vCPU Hotplug requires sequence of ACPI handshakes between Qemu
> and
> > Guest kernel when a vCPU is plugged or unplugged. Most of the AML code to
> > support these handshakes already exists. This AML need to be build during VM
> > init for ARM architecture as well if the GED support exists.
> >
> > Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
> > ---
> >   hw/arm/virt-acpi-build.c | 13 ++++++++++++-
> >   1 file changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> > index 6b674231c2..d27df5030e 100644
> > --- a/hw/arm/virt-acpi-build.c
> > +++ b/hw/arm/virt-acpi-build.c
> > @@ -858,7 +858,18 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> VirtMachineState *vms)
> >        * the RTC ACPI device at all when using UEFI.
> >        */
> >       scope = aml_scope("\\_SB");
> > -    acpi_dsdt_add_cpus(scope, vms);
> > +    /* if GED is enabled then cpus AML shall be added as part build_cpus_aml */
> > +    if (vms->acpi_dev) {
> > +        CPUHotplugFeatures opts = {
> > +             .acpi_1_compatible = false,
> > +             .has_legacy_cphp = false
> > +        };
> > +
> > +        build_cpus_aml(scope, ms, opts, memmap[VIRT_CPUHP_ACPI].base,
> > +                       "\\_SB", NULL, AML_SYSTEM_MEMORY);
> > +    } else {
> > +        acpi_dsdt_add_cpus(scope, vms);
> > +    }
> >       acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
> >                          (irqmap[VIRT_UART] + ARM_SPI_BASE));
> >       if (vmc->acpi_expose_flash) {
> 
> I don't think it's enough to check vms->acpi_dev. vCPU hotplug needn't to be
> supported even vms->acpi_dev exists. For example when vGICv2 instead of
> vGICv3 is enabled, and so on.

Good catch.

'mc->has_hotpluggable_cpus' has to be added. Will fix.

Thanks
Salil.
diff mbox series

Patch

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 6b674231c2..d27df5030e 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -858,7 +858,18 @@  build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
      * the RTC ACPI device at all when using UEFI.
      */
     scope = aml_scope("\\_SB");
-    acpi_dsdt_add_cpus(scope, vms);
+    /* if GED is enabled then cpus AML shall be added as part build_cpus_aml */
+    if (vms->acpi_dev) {
+        CPUHotplugFeatures opts = {
+             .acpi_1_compatible = false,
+             .has_legacy_cphp = false
+        };
+
+        build_cpus_aml(scope, ms, opts, memmap[VIRT_CPUHP_ACPI].base,
+                       "\\_SB", NULL, AML_SYSTEM_MEMORY);
+    } else {
+        acpi_dsdt_add_cpus(scope, vms);
+    }
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
     if (vmc->acpi_expose_flash) {