- 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>
268 lines
8.6 KiB
Diff
268 lines
8.6 KiB
Diff
From 8ad397f33f8b7d82c0ef72608ef8dc3e0ecba1c2 Mon Sep 17 00:00:00 2001
|
|
From: Salil Mehta <salil.mehta@huawei.com>
|
|
Date: Sat, 9 May 2020 14:38:38 +0100
|
|
Subject: [PATCH] hw/arm,gicv3: Changes to update GIC with vCPU hot-plug
|
|
notification
|
|
|
|
vCPU hot-(un)plug events MUST be notified to the GIC. Introduce a notfication
|
|
mechanism to update any such events to GIC so that it can update its vCPU to GIC
|
|
CPU interface association.
|
|
|
|
This is required to implement a workaround to the limitations posed by the ARM
|
|
architecture. For details about the constraints and workarounds please check
|
|
below slides:
|
|
|
|
Link: https://kvm-forum.qemu.org/2023/talk/9SMPDQ/
|
|
|
|
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>
|
|
---
|
|
hw/arm/virt.c | 27 +++++++++++++--
|
|
hw/intc/arm_gicv3_common.c | 54 +++++++++++++++++++++++++++++-
|
|
hw/intc/arm_gicv3_cpuif_common.c | 5 +++
|
|
hw/intc/gicv3_internal.h | 1 +
|
|
include/hw/arm/virt.h | 1 +
|
|
include/hw/intc/arm_gicv3_common.h | 22 ++++++++++++
|
|
6 files changed, 107 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
|
|
index 97bf4cca11..0312fa366d 100644
|
|
--- a/hw/arm/virt.c
|
|
+++ b/hw/arm/virt.c
|
|
@@ -750,6 +750,16 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms)
|
|
return dev;
|
|
}
|
|
|
|
+static void virt_add_gic_cpuhp_notifier(VirtMachineState *vms)
|
|
+{
|
|
+ MachineClass *mc = MACHINE_GET_CLASS(vms);
|
|
+
|
|
+ if (mc->has_hotpluggable_cpus) {
|
|
+ Notifier *cpuhp_notifier = gicv3_cpuhp_notifier(vms->gic);
|
|
+ notifier_list_add(&vms->cpuhp_notifiers, cpuhp_notifier);
|
|
+ }
|
|
+}
|
|
+
|
|
static void create_its(VirtMachineState *vms)
|
|
{
|
|
const char *itsclass = its_class_name();
|
|
@@ -997,6 +1007,9 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
|
|
} else if (vms->gic_version == VIRT_GIC_VERSION_2) {
|
|
create_v2m(vms);
|
|
}
|
|
+
|
|
+ /* add GIC CPU hot(un)plug update notifier */
|
|
+ virt_add_gic_cpuhp_notifier(vms);
|
|
}
|
|
|
|
static void create_uart(const VirtMachineState *vms, int uart,
|
|
@@ -2481,6 +2494,8 @@ static void machvirt_init(MachineState *machine)
|
|
create_fdt(vms);
|
|
qemu_log("cpu init start\n");
|
|
|
|
+ notifier_list_init(&vms->cpuhp_notifiers);
|
|
+ possible_cpus = mc->possible_cpu_arch_ids(machine);
|
|
assert(possible_cpus->len == max_cpus);
|
|
for (n = 0; n < possible_cpus->len; n++) {
|
|
Object *cpuobj;
|
|
@@ -3133,6 +3148,14 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
|
|
dev, &error_abort);
|
|
}
|
|
|
|
+static void virt_update_gic(VirtMachineState *vms, CPUState *cs)
|
|
+{
|
|
+ GICv3CPUHotplugInfo gic_info = { .gic = vms->gic, .cpu = cs };
|
|
+
|
|
+ /* notify gic to stitch GICC to this new cpu */
|
|
+ notifier_list_notify(&vms->cpuhp_notifiers, &gic_info);
|
|
+}
|
|
+
|
|
static void virt_cpu_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
Error **errp)
|
|
{
|
|
@@ -3215,7 +3238,7 @@ static void virt_cpu_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
* vCPUs have their GIC state initialized during machvit_init().
|
|
*/
|
|
if (vms->acpi_dev) {
|
|
- /* TODO: update GIC about this hotplug change here */
|
|
+ virt_update_gic(vms, cs);
|
|
wire_gic_cpu_irqs(vms, cs);
|
|
}
|
|
|
|
@@ -3301,7 +3324,7 @@ static void virt_cpu_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
/* TODO: update the acpi cpu hotplug state for cpu hot-unplug */
|
|
|
|
unwire_gic_cpu_irqs(vms, cs);
|
|
- /* TODO: update the GIC about this hot unplug change */
|
|
+ virt_update_gic(vms, cs);
|
|
|
|
/* TODO: unregister cpu for reset & update F/W info for the next boot */
|
|
|
|
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
|
|
index ebd99af610..fc87fa9369 100644
|
|
--- a/hw/intc/arm_gicv3_common.c
|
|
+++ b/hw/intc/arm_gicv3_common.c
|
|
@@ -33,7 +33,6 @@
|
|
#include "hw/arm/linux-boot-if.h"
|
|
#include "sysemu/kvm.h"
|
|
|
|
-
|
|
static void gicv3_gicd_no_migration_shift_bug_post_load(GICv3State *cs)
|
|
{
|
|
if (cs->gicd_no_migration_shift_bug) {
|
|
@@ -322,6 +321,56 @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
|
|
}
|
|
}
|
|
|
|
+static int arm_gicv3_get_proc_num(GICv3State *s, CPUState *cpu)
|
|
+{
|
|
+ uint64_t mp_affinity;
|
|
+ uint64_t gicr_typer;
|
|
+ uint64_t cpu_affid;
|
|
+ int i;
|
|
+
|
|
+ mp_affinity = object_property_get_uint(OBJECT(cpu), "mp-affinity", NULL);
|
|
+ /* match the cpu mp-affinity to get the gic cpuif number */
|
|
+ for (i = 0; i < s->num_cpu; i++) {
|
|
+ gicr_typer = s->cpu[i].gicr_typer;
|
|
+ cpu_affid = (gicr_typer >> 32) & 0xFFFFFF;
|
|
+ if (cpu_affid == mp_affinity) {
|
|
+ return i;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return -1;
|
|
+}
|
|
+
|
|
+static void arm_gicv3_cpu_update_notifier(Notifier *notifier, void * data)
|
|
+{
|
|
+ GICv3CPUHotplugInfo *gic_info = (GICv3CPUHotplugInfo *)data;
|
|
+ CPUState *cpu = gic_info->cpu;
|
|
+ int gic_cpuif_num;
|
|
+ GICv3State *s;
|
|
+
|
|
+ s = ARM_GICV3_COMMON(gic_info->gic);
|
|
+
|
|
+ /* this shall get us mapped gicv3 cpuif corresponding to mpidr */
|
|
+ gic_cpuif_num = arm_gicv3_get_proc_num(s, cpu);
|
|
+ if (gic_cpuif_num < 0) {
|
|
+ error_report("Failed to associate cpu %d with any GIC cpuif",
|
|
+ cpu->cpu_index);
|
|
+ abort();
|
|
+ }
|
|
+
|
|
+ /* check if update is for vcpu hot-unplug */
|
|
+ if (qemu_enabled_cpu(cpu)) {
|
|
+ s->cpu[gic_cpuif_num].cpu = NULL;
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ /* re-stitch the gic cpuif to this new cpu */
|
|
+ gicv3_set_gicv3state(cpu, &s->cpu[gic_cpuif_num]);
|
|
+ gicv3_set_cpustate(&s->cpu[gic_cpuif_num], cpu);
|
|
+
|
|
+ /* TODO: initialize the registers info for this newly added cpu */
|
|
+}
|
|
+
|
|
static void arm_gicv3_common_realize(DeviceState *dev, Error **errp)
|
|
{
|
|
GICv3State *s = ARM_GICV3_COMMON(dev);
|
|
@@ -444,6 +493,8 @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp)
|
|
s->cpu[cpuidx - 1].gicr_typer |= GICR_TYPER_LAST;
|
|
}
|
|
|
|
+ s->cpu_update_notifier.notify = arm_gicv3_cpu_update_notifier;
|
|
+
|
|
s->itslist = g_ptr_array_new();
|
|
}
|
|
|
|
@@ -451,6 +502,7 @@ static void arm_gicv3_finalize(Object *obj)
|
|
{
|
|
GICv3State *s = ARM_GICV3_COMMON(obj);
|
|
|
|
+ notifier_remove(&s->cpu_update_notifier);
|
|
g_free(s->redist_region_count);
|
|
}
|
|
|
|
diff --git a/hw/intc/arm_gicv3_cpuif_common.c b/hw/intc/arm_gicv3_cpuif_common.c
|
|
index ff1239f65d..381cf2754b 100644
|
|
--- a/hw/intc/arm_gicv3_cpuif_common.c
|
|
+++ b/hw/intc/arm_gicv3_cpuif_common.c
|
|
@@ -20,3 +20,8 @@ void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s)
|
|
|
|
env->gicv3state = (void *)s;
|
|
};
|
|
+
|
|
+void gicv3_set_cpustate(GICv3CPUState *s, CPUState *cpu)
|
|
+{
|
|
+ s->cpu = cpu;
|
|
+}
|
|
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
|
|
index 29d5cdc1b6..9d4c1209bd 100644
|
|
--- a/hw/intc/gicv3_internal.h
|
|
+++ b/hw/intc/gicv3_internal.h
|
|
@@ -848,5 +848,6 @@ static inline void gicv3_cache_all_target_cpustates(GICv3State *s)
|
|
}
|
|
|
|
void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s);
|
|
+void gicv3_set_cpustate(GICv3CPUState *s, CPUState *cpu);
|
|
|
|
#endif /* QEMU_ARM_GICV3_INTERNAL_H */
|
|
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
|
|
index 5de0185063..069c9f2a09 100644
|
|
--- a/include/hw/arm/virt.h
|
|
+++ b/include/hw/arm/virt.h
|
|
@@ -180,6 +180,7 @@ struct VirtMachineState {
|
|
PCIBus *bus;
|
|
char *oem_id;
|
|
char *oem_table_id;
|
|
+ NotifierList cpuhp_notifiers;
|
|
};
|
|
|
|
#define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
|
|
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
|
|
index 4e2fb518e7..97a48f44b9 100644
|
|
--- a/include/hw/intc/arm_gicv3_common.h
|
|
+++ b/include/hw/intc/arm_gicv3_common.h
|
|
@@ -280,6 +280,7 @@ struct GICv3State {
|
|
GICv3CPUState *gicd_irouter_target[GICV3_MAXIRQ];
|
|
uint32_t gicd_nsacr[DIV_ROUND_UP(GICV3_MAXIRQ, 16)];
|
|
|
|
+ Notifier cpu_update_notifier;
|
|
GICv3CPUState *cpu;
|
|
/* List of all ITSes connected to this GIC */
|
|
GPtrArray *itslist;
|
|
@@ -328,6 +329,27 @@ struct ARMGICv3CommonClass {
|
|
|
|
void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
|
|
const MemoryRegionOps *ops);
|
|
+/**
|
|
+ * Structure used by GICv3 CPU hotplug notifier
|
|
+ */
|
|
+typedef struct GICv3CPUHotplugInfo {
|
|
+ DeviceState *gic; /* GICv3State */
|
|
+ CPUState *cpu;
|
|
+} GICv3CPUHotplugInfo;
|
|
+
|
|
+/**
|
|
+ * gicv3_cpuhp_notifier
|
|
+ *
|
|
+ * Returns CPU hotplug notifier which could be used to update GIC about any
|
|
+ * CPU hot(un)plug events.
|
|
+ *
|
|
+ * Returns: Notifier initialized with CPU Hot(un)plug update function
|
|
+ */
|
|
+static inline Notifier *gicv3_cpuhp_notifier(DeviceState *dev)
|
|
+{
|
|
+ GICv3State *s = ARM_GICV3_COMMON(dev);
|
|
+ return &s->cpu_update_notifier;
|
|
+}
|
|
|
|
/**
|
|
* gicv3_class_name
|
|
--
|
|
2.27.0
|
|
|