[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC V3 13/29] arm/virt: Make ARM vCPU *present* status ACPI *pers
From: |
Salil Mehta |
Subject: |
[PATCH RFC V3 13/29] arm/virt: Make ARM vCPU *present* status ACPI *persistent* |
Date: |
Fri, 14 Jun 2024 00:36:23 +0100 |
ARM arch does not allow CPUs presence to be changed [1] after kernel has booted.
Hence, firmware/ACPI/Qemu must ensure persistent view of the vCPUs to the Guest
kernel even when they are not present in the QoM i.e. are unplugged or are
yet-to-be-plugged
References:
[1] Check comment 5 in the bugzilla entry
Link: https://bugzilla.tianocore.org/show_bug.cgi?id=4481#c5
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
cpu-common.c | 6 ++++++
hw/arm/virt.c | 7 +++++++
include/hw/core/cpu.h | 21 +++++++++++++++++++++
3 files changed, 34 insertions(+)
diff --git a/cpu-common.c b/cpu-common.c
index 49d2a50835..e4b4dee99a 100644
--- a/cpu-common.c
+++ b/cpu-common.c
@@ -128,6 +128,12 @@ bool qemu_enabled_cpu(CPUState *cpu)
return cpu && !cpu->disabled;
}
+bool qemu_persistent_cpu(CPUState *cpu)
+{
+ /* cpu state can be faked to the guest via acpi */
+ return cpu && cpu->acpi_persistent;
+}
+
uint64_t qemu_get_cpu_archid(int cpu_index)
{
MachineState *ms = MACHINE(qdev_get_machine());
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 5f98162587..9d33f30a6a 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -3016,6 +3016,13 @@ static void virt_cpu_pre_plug(HotplugHandler
*hotplug_dev, DeviceState *dev,
return;
}
virt_cpu_set_properties(OBJECT(cs), cpu_slot, errp);
+
+ /*
+ * To give persistent presence view of vCPUs to the guest, ACPI might need
+ * to fake the presence of the vCPUs to the guest but keep them disabled.
+ * This shall be used during the init of ACPI Hotplug state and hot-unplug
+ */
+ cs->acpi_persistent = true;
}
static void virt_cpu_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 62e68611c0..e13e542177 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -540,6 +540,14 @@ struct CPUState {
* every CPUState is enabled across all architectures.
*/
bool disabled;
+ /*
+ * On certain architectures, to provide a persistent view of the 'presence'
+ * of vCPUs to the guest, ACPI might need to fake the 'presence' of the
+ * vCPUs but keep them ACPI-disabled for the guest. This is achieved by
+ * returning `_STA.PRES=True` and `_STA.Ena=False` for the unplugged vCPUs
+ * in QEMU QoM.
+ */
+ bool acpi_persistent;
/* TODO Move common fields from CPUArchState here. */
int cpu_index;
@@ -959,6 +967,19 @@ bool qemu_present_cpu(CPUState *cpu);
*/
bool qemu_enabled_cpu(CPUState *cpu);
+/**
+ * qemu_persistent_cpu:
+ * @cpu: The vCPU to check
+ *
+ * Checks if the vCPU state should always be reflected as *present* via ACPI
+ * to the Guest. By default, this is False on all architectures and has to be
+ * explicity set during initialization.
+ *
+ * Returns: True if it is ACPI 'persistent' CPU
+ *
+ */
+bool qemu_persistent_cpu(CPUState *cpu);
+
/**
* qemu_get_cpu_archid:
* @cpu_index: possible vCPU for which arch-id needs to be retreived
--
2.34.1
- [PATCH RFC V3 03/29] hw/arm/virt: Limit number of possible vCPUs for unsupported Accel or GIC Type, (continued)
- [PATCH RFC V3 03/29] hw/arm/virt: Limit number of possible vCPUs for unsupported Accel or GIC Type, Salil Mehta, 2024/06/13
- [PATCH RFC V3 04/29] hw/arm/virt: Move setting of common CPU properties in a function, Salil Mehta, 2024/06/13
- [PATCH RFC V3 05/29] arm/virt, target/arm: Machine init time change common to vCPU {cold|hot}-plug, Salil Mehta, 2024/06/13
- [PATCH RFC V3 06/29] arm/virt, kvm: Pre-create disabled possible vCPUs @machine init, Salil Mehta, 2024/06/13
- [PATCH RFC V3 07/29] arm/virt, gicv3: Changes to pre-size GIC with possible vcpus @machine init, Salil Mehta, 2024/06/13
- [PATCH RFC V3 08/29] arm/virt: Init PMU at host for all possible vcpus, Salil Mehta, 2024/06/13
- [PATCH RFC V3 09/29] arm/acpi: Enable ACPI support for vcpu hotplug, Salil Mehta, 2024/06/13
- [PATCH RFC V3 10/29] arm/virt: Add cpu hotplug events to GED during creation, Salil Mehta, 2024/06/13
- [PATCH RFC V3 11/29] arm/virt: Create GED dev before *disabled* CPU Objs are destroyed, Salil Mehta, 2024/06/13
- [PATCH RFC V3 12/29] arm/virt/acpi: Build CPUs AML with CPU Hotplug support, Salil Mehta, 2024/06/13
- [PATCH RFC V3 13/29] arm/virt: Make ARM vCPU *present* status ACPI *persistent*,
Salil Mehta <=
- [PATCH RFC V3 14/29] hw/acpi: ACPI/AML Changes to reflect the correct _STA.{PRES, ENA} Bits to Guest, Salil Mehta, 2024/06/13
- [PATCH RFC V3 15/29] hw/arm: MADT Tbl change to size the guest with possible vCPUs, Salil Mehta, 2024/06/13
- [PATCH RFC V3 16/29] hw/acpi: Make _MAT method optional, Salil Mehta, 2024/06/13
- [PATCH RFC V3 17/29] arm/virt: Release objects for *disabled* possible vCPUs after init, Salil Mehta, 2024/06/13
- [PATCH RFC V3 18/29] arm/virt: Add/update basic hot-(un)plug framework, Salil Mehta, 2024/06/13
- [PATCH RFC V3 19/29] arm/virt: Changes to (un)wire GICC<->vCPU IRQs during hot-(un)plug, Salil Mehta, 2024/06/13
- [PATCH RFC V3 20/29] hw/arm, gicv3: Changes to update GIC with vCPU hot-plug notification, Salil Mehta, 2024/06/13
- [PATCH RFC V3 21/29] hw/intc/arm-gicv3*: Changes required to (re)init the vCPU register info, Salil Mehta, 2024/06/13
- [PATCH RFC V3 22/29] arm/virt: Update the guest(via GED) about CPU hot-(un)plug events, Salil Mehta, 2024/06/13
- [PATCH RFC V3 23/29] hw/arm: Changes required for reset and to support next boot, Salil Mehta, 2024/06/13