1 Star 0 Fork 120

Jiabo Feng/qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
arm-virt-Don-t-modify-smp.max_cpus-when-vcpu-hotplug.patch 5.25 KB
一键复制 编辑 原始数据 按行查看 历史
Jiabo Feng 提交于 2024-05-10 16:44 . QEMU update to version 8.2.0-12:
From 52909d74ec37e851df3762a6eab1d7a6eeb89fba Mon Sep 17 00:00:00 2001
From: Keqian Zhu <zhukeqian1@huawei.com>
Date: Sun, 28 Apr 2024 12:56:47 +0800
Subject: [PATCH] arm/virt: Don't modify smp.max_cpus when vcpu hotplug
disabled
The smp.max_cpus has been used when create possible_cpus, so
we must not change it after that.
We should use smp.cpus when create cpu and acpi table if vcpu
hotplug is disabled, instead of change smp.max_cpus to smp.cpus
and use it everywhere.
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
---
hw/arm/virt-acpi-build.c | 8 +++++++-
hw/arm/virt.c | 24 ++++++++++++++++++++++--
include/hw/arm/virt.h | 8 +++++++-
3 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 99296fc6d8..179600d4fe 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -814,9 +814,15 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
{
int i;
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
+ MachineState *ms = MACHINE(vms);
const MemMapEntry *memmap = vms->memmap;
AcpiTable table = { .sig = "APIC", .rev = 4, .oem_id = vms->oem_id,
.oem_table_id = vms->oem_table_id };
+ unsigned int max_cpus = ms->smp.max_cpus;
+
+ if (!vms->cpu_hotplug_enabled) {
+ max_cpus = ms->smp.cpus;
+ }
acpi_table_begin(&table, table_data);
/* Local Interrupt Controller Address */
@@ -835,7 +841,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
build_append_int_noprefix(table_data, vms->gic_version, 1);
build_append_int_noprefix(table_data, 0, 3); /* Reserved */
- for (i = 0; i < MACHINE(vms)->smp.max_cpus; i++) {
+ for (i = 0; i < max_cpus; i++) {
CPUState *cpu = qemu_get_possible_cpu(i);
uint64_t physical_base_address = 0, gich = 0, gicv = 0;
uint32_t vgic_interrupt = vms->virt ? ARCH_GIC_MAINT_IRQ : 0;
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index e4473354d4..507b09d96c 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -831,6 +831,10 @@ static void unwire_gic_cpu_irqs(VirtMachineState *vms, CPUState *cs)
int type = vms->gic_version;
int irq;
+ if (!vms->cpu_hotplug_enabled) {
+ max_cpus = ms->smp.cpus;
+ }
+
for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
qdev_disconnect_gpio_out_named(cpudev, NULL, irq);
}
@@ -871,6 +875,10 @@ static void wire_gic_cpu_irqs(VirtMachineState *vms, CPUState *cs)
int intidbase;
int irq;
+ if (!vms->cpu_hotplug_enabled) {
+ max_cpus = ms->smp.cpus;
+ }
+
intidbase = NUM_IRQS + cpu * GIC_INTERNAL;
for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
@@ -915,6 +923,10 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
uint32_t nb_redist_regions = 0;
int revision;
+ if (!vms->cpu_hotplug_enabled) {
+ max_cpus = ms->smp.cpus;
+ }
+
if (vms->gic_version == VIRT_GIC_VERSION_2) {
gictype = gic_class_name();
} else {
@@ -2165,6 +2177,9 @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)
for (n = 0; n < possible_cpus->len; n++) {
cpu = qemu_get_possible_cpu(n);
+ if (!qemu_present_cpu(cpu)) {
+ continue;
+ }
if (vms->pmu) {
assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU));
@@ -2195,6 +2210,9 @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)
if (kvm_enabled() || tcg_enabled()) {
for (n = 0; n < possible_cpus->len; n++) {
cpu = qemu_get_possible_cpu(n);
+ if (!qemu_present_cpu(cpu)) {
+ continue;
+ }
/*
* Now, GIC has been sized with possible CPUs and we dont require
@@ -2511,16 +2529,18 @@ static void machvirt_init(MachineState *machine)
if (machine->smp.max_cpus > smp_cpus) {
warn_report("cpu hotplug feature has been disabled");
}
- machine->smp.max_cpus = smp_cpus;
}
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;
CPUState *cs;
+ if (!vms->cpu_hotplug_enabled && n >= smp_cpus) {
+ break;
+ }
+
cpuobj = object_new(possible_cpus->cpus[n].type);
cs = CPU(cpuobj);
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index 138531f9c1..7a734f07f7 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -210,10 +210,16 @@ static uint32_t virt_redist_capacity(VirtMachineState *vms, int region)
static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
{
uint32_t redist0_capacity = virt_redist_capacity(vms, VIRT_GIC_REDIST);
+ MachineState *ms = MACHINE(vms);
+ unsigned int max_cpus = ms->smp.max_cpus;
+
+ if (!vms->cpu_hotplug_enabled) {
+ max_cpus = ms->smp.cpus;
+ }
assert(vms->gic_version != VIRT_GIC_VERSION_2);
- return (MACHINE(vms)->smp.max_cpus > redist0_capacity &&
+ return (max_cpus > redist0_capacity &&
vms->highmem_redists) ? 2 : 1;
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/JiaboFeng/qemu.git
git@gitee.com:JiaboFeng/qemu.git
JiaboFeng
qemu
qemu
master

搜索帮助