- coro: support live patch for libcare
- tests/acpi: Update expected ACPI tables for vcpu hotplug(update BinDir)
- arm/virt: Require mc->has_hotpluggable_cpus for cold-plugged vcpu
- arm/virt: Consider has_ged when set mc->has_hotpluggable_cpus
- arm/virt-acpi: Require possible_cpu_arch_ids for build_cpus_aml()
- acpi/ged: Remove cpuhp field of ged
- acpi/ged: Init cpu hotplug only when machine support it
- intc/gicv3: Fixes for vcpu hotplug
- arm/kvm: Set psci smccc filter only with vcpu hotplug
- accel/kvm: Use correct id for parked vcpu
- arm/virt: Fix adjudgement of core_id for vcpu hotplugged
- arm/virt.c: Convey local_err when set psci-conduit
- system/cpus: Fix resume_all_vcpus() under vCPU hotplug condition
- system/cpus: Fix pause_all_vcpus() under concurrent environment
- acpi/cpu: Fix cpu_hotplug_hw_init()
- arm/cpu: Some fixes for arm_cpu_unrealizefn()
- system/physmem: Fix possible double free when destroy cpu as
- hw/arm/virt: Expose cold-booted CPUs as MADT GICC Enabled
- tcg/mttcg: enable threads to unregister in tcg_ctxs[]
- hw/arm: Support hotplug capability check using _OSC method
- target/arm/kvm,tcg: Register/Handle SMCCC hypercall exits to VMM/Qemu
- target/arm/kvm: Write CPU state back to KVM on reset
- target/arm: Add support of *unrealize* ARMCPU during vCPU Hot-unplug
- physmem,gdbstub: Common helping funcs/changes to *unrealize* vCPU
- hw/arm: Changes required for reset and to support next boot
- arm/virt: Update the guest(via GED) about CPU hot-(un)plug events
- hw/intc/arm-gicv3*: Changes required to (re)init the vCPU register info
- hw/arm,gicv3: Changes to update GIC with vCPU hot-plug notification
- arm/virt: Changes to (un)wire GICC<->vCPU IRQs during hot-(un)plug
- arm/virt: Add/update basic hot-(un)plug framework
- hw/acpi: Update ACPI GED framework to support vCPU Hotplug
- arm/virt: Release objects for *disabled* possible vCPUs after init
- hw/acpi: Make _MAT method optional
- hw/arm: MADT Tbl change to size the guest with possible vCPUs
- hw/acpi: Update GED _EVT method AML with cpu scan
- hw/acpi: ACPI/AML Changes to reflect the correct _STA.{PRES,ENA} Bits to Guest
- arm/virt: Make ARM vCPU *present* status ACPI *persistent*
- arm/virt/acpi: Build CPUs AML with CPU Hotplug support
- tests/acpi/bios-tables-test: Allow changes to virt/DSDT file
- acpi/cpu: Add cpu_cppc building support
- arm/virt/acpi: Factor out CPPC building from DSDT CPU aml
- hw/acpi: Update CPUs AML with cpu-(ctrl)dev change
- arm/virt: Create GED dev before *disabled* CPU Objs are destroyed
- arm/virt: Add cpu hotplug events to GED during creation
- hw/acpi: Init GED framework with cpu hotplug events
- hw/acpi: Use qemu_present_cpu() API in ACPI CPU hotplug init
- hw/acpi: Add ACPI CPU hotplug init stub
- arm/acpi: Enable ACPI support for vcpu hotplug
- hw/acpi: Move CPU ctrl-dev MMIO region len macro to common header file
- arm/virt: Init PMU at host for all possible vcpus
- arm/virt,gicv3: Changes to pre-size GIC with possible vcpus @machine init
- arm/virt,kvm: Pre-create disabled possible vCPUs @machine init
- accel/kvm: Extract common KVM vCPU {creation,parking} code
- arm/virt,target/arm: Machine init time change common to vCPU {cold|hot}-plug
- hw/arm/virt: Move setting of common CPU properties in a function
- cpus-common: Add common CPU utility for possible vCPUs
- arm/virt,target/arm: Add new ARMCPU {socket,cluster,core,thread}-id property
Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
145 lines
4.2 KiB
Diff
145 lines
4.2 KiB
Diff
From 444de91551c1e141a76bf3dae4cebee9dbd57b49 Mon Sep 17 00:00:00 2001
|
|
From: Salil Mehta <salil.mehta@huawei.com>
|
|
Date: Wed, 6 May 2020 02:48:49 +0100
|
|
Subject: [PATCH] cpus-common: Add common CPU utility for possible vCPUs
|
|
|
|
Adds various utility functions which might be required to fetch or check the
|
|
state of the possible vCPUs. This also introduces concept of *disabled* vCPUs,
|
|
which are part of the *possible* vCPUs but are not part of the *present* vCPU.
|
|
This state shall be used during machine init time to check the presence of
|
|
vcpus.
|
|
|
|
Co-developed-by: Salil Mehta <salil.mehta@huawei.com>
|
|
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
|
Co-developed-by: Keqian Zhu <zhukeqian1@huawei.com>
|
|
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
|
|
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
|
|
---
|
|
cpu-common.c | 31 +++++++++++++++++++++++++
|
|
include/hw/core/cpu.h | 53 +++++++++++++++++++++++++++++++++++++++++++
|
|
2 files changed, 84 insertions(+)
|
|
|
|
diff --git a/cpu-common.c b/cpu-common.c
|
|
index c81fd72d16..d041a351ab 100644
|
|
--- a/cpu-common.c
|
|
+++ b/cpu-common.c
|
|
@@ -24,6 +24,7 @@
|
|
#include "sysemu/cpus.h"
|
|
#include "qemu/lockable.h"
|
|
#include "trace/trace-root.h"
|
|
+#include "hw/boards.h"
|
|
|
|
QemuMutex qemu_cpu_list_lock;
|
|
static QemuCond exclusive_cond;
|
|
@@ -107,6 +108,36 @@ void cpu_list_remove(CPUState *cpu)
|
|
cpu_list_generation_id++;
|
|
}
|
|
|
|
+CPUState *qemu_get_possible_cpu(int index)
|
|
+{
|
|
+ MachineState *ms = MACHINE(qdev_get_machine());
|
|
+ const CPUArchIdList *possible_cpus = ms->possible_cpus;
|
|
+
|
|
+ assert((index >= 0) && (index < possible_cpus->len));
|
|
+
|
|
+ return CPU(possible_cpus->cpus[index].cpu);
|
|
+}
|
|
+
|
|
+bool qemu_present_cpu(CPUState *cpu)
|
|
+{
|
|
+ return cpu;
|
|
+}
|
|
+
|
|
+bool qemu_enabled_cpu(CPUState *cpu)
|
|
+{
|
|
+ return cpu && !cpu->disabled;
|
|
+}
|
|
+
|
|
+uint64_t qemu_get_cpu_archid(int cpu_index)
|
|
+{
|
|
+ MachineState *ms = MACHINE(qdev_get_machine());
|
|
+ const CPUArchIdList *possible_cpus = ms->possible_cpus;
|
|
+
|
|
+ assert((cpu_index >= 0) && (cpu_index < possible_cpus->len));
|
|
+
|
|
+ return possible_cpus->cpus[cpu_index].arch_id;
|
|
+}
|
|
+
|
|
CPUState *qemu_get_cpu(int index)
|
|
{
|
|
CPUState *cpu;
|
|
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
|
|
index c0c8320413..c30636a936 100644
|
|
--- a/include/hw/core/cpu.h
|
|
+++ b/include/hw/core/cpu.h
|
|
@@ -538,6 +538,17 @@ struct CPUState {
|
|
GArray *plugin_mem_cbs;
|
|
#endif
|
|
|
|
+ /*
|
|
+ * Some architectures do not allow *presence* of vCPUs to be changed
|
|
+ * after guest has booted using information specified by VMM/firmware
|
|
+ * via ACPI MADT at the boot time. Thus to enable vCPU hotplug on these
|
|
+ * architectures possible vCPU can have CPUState object in 'disabled'
|
|
+ * state or can also not have CPUState object at all. This is possible
|
|
+ * when vCPU Hotplug is supported and vCPUs are 'yet-to-be-plugged' in
|
|
+ * the QOM or have been hot-unplugged.
|
|
+ * By default every CPUState is enabled as of now across all archs.
|
|
+ */
|
|
+ bool disabled;
|
|
/* TODO Move common fields from CPUArchState here. */
|
|
int cpu_index;
|
|
int cluster_index;
|
|
@@ -913,6 +924,48 @@ static inline bool cpu_in_exclusive_context(const CPUState *cpu)
|
|
*/
|
|
CPUState *qemu_get_cpu(int index);
|
|
|
|
+/**
|
|
+ * qemu_get_possible_cpu:
|
|
+ * @index: The CPUState@cpu_index value of the CPU to obtain.
|
|
+ * Input index MUST be in range [0, Max Possible CPUs)
|
|
+ *
|
|
+ * If CPUState object exists,then it gets a CPU matching
|
|
+ * @index in the possible CPU array.
|
|
+ *
|
|
+ * Returns: The possible CPU or %NULL if CPU does not exist.
|
|
+ */
|
|
+CPUState *qemu_get_possible_cpu(int index);
|
|
+
|
|
+/**
|
|
+ * qemu_present_cpu:
|
|
+ * @cpu: The vCPU to check
|
|
+ *
|
|
+ * Checks if the vCPU is amongst the present possible vcpus.
|
|
+ *
|
|
+ * Returns: True if it is present possible vCPU else false
|
|
+ */
|
|
+bool qemu_present_cpu(CPUState *cpu);
|
|
+
|
|
+/**
|
|
+ * qemu_enabled_cpu:
|
|
+ * @cpu: The vCPU to check
|
|
+ *
|
|
+ * Checks if the vCPU is enabled.
|
|
+ *
|
|
+ * Returns: True if it is 'enabled' else false
|
|
+ */
|
|
+bool qemu_enabled_cpu(CPUState *cpu);
|
|
+
|
|
+/**
|
|
+ * qemu_get_cpu_archid:
|
|
+ * @cpu_index: possible vCPU for which arch-id needs to be retreived
|
|
+ *
|
|
+ * Fetches the vCPU arch-id from the present possible vCPUs.
|
|
+ *
|
|
+ * Returns: arch-id of the possible vCPU
|
|
+ */
|
|
+uint64_t qemu_get_cpu_archid(int cpu_index);
|
|
+
|
|
/**
|
|
* cpu_exists:
|
|
* @id: Guest-exposed CPU ID to lookup.
|
|
--
|
|
2.27.0
|
|
|