From: Miguel Luis <miguel.luis@oracle.com>
To: Salil Mehta <salil.mehta@huawei.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
"Michael S . Tsirkin" <mst@redhat.com>,
"Marc Zyngier" <maz@kernel.org>,
"Jean-Philippe Brucker" <jean-philippe@linaro.org>,
"Jonathan Cameron" <jonathan.cameron@huawei.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Igor Mammedov" <imammedo@redhat.com>,
"andrew.jones@linux.dev" <andrew.jones@linux.dev>,
"david@redhat.com" <david@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Eric Auger" <eric.auger@redhat.com>,
"Will Deacon" <will@kernel.org>,
"Ard Biesheuvel" <ardb@kernel.org>,
"oliver.upton@linux.dev" <oliver.upton@linux.dev>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"gshan@redhat.com" <gshan@redhat.com>,
"rafael@kernel.org" <rafael@kernel.org>,
"borntraeger@linux.ibm.com" <borntraeger@linux.ibm.com>,
"alex.bennee@linaro.org" <alex.bennee@linaro.org>,
"npiggin@gmail.com" <npiggin@gmail.com>,
"harshpb@linux.ibm.com" <harshpb@linux.ibm.com>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
"darren@os.amperecomputing.com" <darren@os.amperecomputing.com>,
"ilkka@os.amperecomputing.com" <ilkka@os.amperecomputing.com>,
"vishnu@os.amperecomputing.com" <vishnu@os.amperecomputing.com>,
"Karl Heubaum" <karl.heubaum@oracle.com>,
"salil.mehta@opnsrc.net" <salil.mehta@opnsrc.net>,
"zhukeqian1@huawei.com" <zhukeqian1@huawei.com>,
"wangxiongfeng2@huawei.com" <wangxiongfeng2@huawei.com>,
"wangyanan55@huawei.com" <wangyanan55@huawei.com>,
"jiakernel2@gmail.com" <jiakernel2@gmail.com>,
"maobibo@loongson.cn" <maobibo@loongson.cn>,
"lixianglai@loongson.cn" <lixianglai@loongson.cn>,
"shahuang@redhat.com" <shahuang@redhat.com>,
"zhao1.liu@intel.com" <zhao1.liu@intel.com>,
"linuxarm@huawei.com" <linuxarm@huawei.com>,
"gustavo.romero@linaro.org" <gustavo.romero@linaro.org>
Subject: Re: [PATCH RFC V4 02/33] cpu-common: Add common CPU utility for possible vCPUs
Date: Thu, 10 Oct 2024 14:47:01 +0000 [thread overview]
Message-ID: <23D4A389-FEB6-4C24-93B5-2D775F208390@oracle.com> (raw)
In-Reply-To: <20241009031815.250096-3-salil.mehta@huawei.com>
Hi Salil,
> On 9 Oct 2024, at 03:17, Salil Mehta <salil.mehta@huawei.com> wrote:
>
> This patch adds various utility functions that may be required to fetch or check
> the state of possible vCPUs. It also introduces the concept of *disabled* vCPUs,
> which are part of the *possible* vCPUs but are not enabled. This state will be
> used during machine initialization and later during the plugging or unplugging
> of vCPUs. We release the QOM CPU objects for all disabled vCPUs.
>
> 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 | 21 ++++++++++++++++++++
> include/hw/core/cpu.h | 46 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 67 insertions(+)
>
> diff --git a/cpu-common.c b/cpu-common.c
> index 6b262233a3..4a446f6f7f 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;
> @@ -108,6 +109,26 @@ 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;
I don’t feel qemu_present_cpu should be needed as cpus are implicitly present as
an initialization premise and arm/virt being the only user of this now.
Thanks
Miguel
> +}
> +
> +bool qemu_enabled_cpu(CPUState *cpu)
> +{
> + return cpu && !cpu->disabled;
> +}
> +
> CPUState *qemu_get_cpu(int index)
> {
> CPUState *cpu;
> diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
> index 1c9c775df6..73a4e4cce1 100644
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -538,6 +538,20 @@ struct CPUState {
> CPUPluginState *plugin_state;
> #endif
>
> + /*
> + * In the guest kernel, the presence of vCPUs is determined by information
> + * provided by the VMM or firmware via the ACPI MADT at boot time. Some
> + * architectures do not allow modifications to this configuration after
> + * the guest has booted. Therefore, for such architectures, hotpluggable
> + * vCPUs are exposed by the VMM as not 'ACPI Enabled' to the kernel.
> + * Within QEMU, such vCPUs (those that are 'yet-to-be-plugged' or have
> + * been hot-unplugged) may either have a `CPUState` object in a 'disabled'
> + * state or may not have a `CPUState` object at all.
> + *
> + * By default, `CPUState` objects are enabled across all architectures.
> + */
> + bool disabled;
> +
> /* TODO Move common fields from CPUArchState here. */
> int cpu_index;
> int cluster_index;
> @@ -924,6 +938,38 @@ 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);
> +
> /**
> * cpu_exists:
> * @id: Guest-exposed CPU ID to lookup.
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-10-10 14:48 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 3:17 [PATCH RFC V4 00/33] Support of Virtual CPU Hotplug for ARMv8 Arch Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 01/33] arm/virt, target/arm: Add new ARMCPU {socket, cluster, core, thread}-id property Salil Mehta via
2024-10-10 14:15 ` [PATCH RFC V4 01/33] arm/virt,target/arm: Add new ARMCPU {socket,cluster,core,thread}-id property Miguel Luis
2024-10-09 3:17 ` [PATCH RFC V4 02/33] cpu-common: Add common CPU utility for possible vCPUs Salil Mehta via
2024-10-10 14:47 ` Miguel Luis [this message]
2024-10-11 9:25 ` Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 03/33] hw/arm/virt: Disable vCPU hotplug for *unsupported* Accel or GIC Type Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 04/33] hw/arm/virt: Move setting of common vCPU properties in a function Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 05/33] arm/virt, target/arm: Machine init time change common to vCPU {cold|hot}-plug Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 06/33] arm/virt, kvm: Pre-create disabled possible vCPUs @machine init Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 07/33] arm/virt, gicv3: Changes to pre-size GIC with " Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 08/33] arm/virt, gicv3: Introduce GICv3 CPU Interface *accessibility* flag and checks Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 09/33] hw/intc/arm-gicv3*: Changes required to (re)init the GICv3 vCPU Interface Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 10/33] arm/acpi: Enable ACPI support for vCPU hotplug Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 11/33] arm/virt: Enhance GED framework to handle vCPU hotplug events Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 12/33] arm/virt: Create GED device before *disabled* vCPU Objects are destroyed Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 13/33] arm/virt: Init PMU at host for all possible vCPUs Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 14/33] arm/virt: Release objects for *disabled* possible vCPUs after init Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 15/33] arm/virt/acpi: Update ACPI DSDT Tbl to include CPUs AML with hotplug support Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 16/33] hw/acpi: Make _MAT method optional Salil Mehta via
2024-10-09 3:17 ` [PATCH RFC V4 17/33] hw/arm/acpi: MADT Tbl change to size the guest with possible vCPUs Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 18/33] hw/acpi: Simulate *persistent* vCPU presence to Guest in ACPI _STA.{PRES, ENA} Bits Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 19/33] target/arm: Force ARM vCPU *present* status ACPI *persistent* Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 20/33] arm/virt: Add/update basic hot-(un)plug framework Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 21/33] arm/virt: Changes to (un)wire GICC<->vCPU IRQs during hot-(un)plug Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 22/33] hw/arm, gicv3: Changes to notify GICv3 CPU state with vCPU hot-(un)plug event Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 23/33] hw/arm: Changes required for reset and to support next boot Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 24/33] arm/virt: Update the guest(via GED) about vCPU hot-(un)plug events Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 25/33] target/arm/cpu: Check if hotplugged ARM vCPU's FEAT match existing Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 26/33] tcg: Update tcg_register_thread() leg to handle region alloc for hotplugged vCPU Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 27/33] target/arm: Add support to *unrealize* ARMCPU during vCPU Hot-unplug Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 28/33] tcg/mttcg: Introduce MTTCG thread unregistration leg Salil Mehta via
2024-10-09 3:18 ` [PATCH RFC V4 29/33] hw/intc/arm_gicv3_common: Add GICv3CPUState 'accessible' flag migration handling Salil Mehta via
2024-10-09 3:37 ` [PATCH RFC V4 30/33] target/arm/kvm, tcg: Handle SMCCC hypercall exits in VMM during PSCI_CPU_{ON, OFF} Salil Mehta via
2024-10-09 3:37 ` [PATCH RFC V4 31/33] target/arm/kvm: Write vCPU's state back to KVM on cold-reset Salil Mehta via
2024-10-09 3:37 ` [PATCH RFC V4 32/33] hw/intc/arm_gicv3_kvm: Pause all vCPU to ensure locking in KVM of resetting vCPU Salil Mehta via
2024-10-09 3:37 ` [PATCH RFC V4 33/33] hw/arm/virt: Expose cold-booted vCPUs as MADT GICC *Enabled* Salil Mehta via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23D4A389-FEB6-4C24-93B5-2D775F208390@oracle.com \
--to=miguel.luis@oracle.com \
--cc=alex.bennee@linaro.org \
--cc=andrew.jones@linux.dev \
--cc=ardb@kernel.org \
--cc=borntraeger@linux.ibm.com \
--cc=darren@os.amperecomputing.com \
--cc=david@redhat.com \
--cc=eric.auger@redhat.com \
--cc=gshan@redhat.com \
--cc=gustavo.romero@linaro.org \
--cc=harshpb@linux.ibm.com \
--cc=ilkka@os.amperecomputing.com \
--cc=imammedo@redhat.com \
--cc=jean-philippe@linaro.org \
--cc=jiakernel2@gmail.com \
--cc=jonathan.cameron@huawei.com \
--cc=karl.heubaum@oracle.com \
--cc=linux@armlinux.org.uk \
--cc=linuxarm@huawei.com \
--cc=lixianglai@loongson.cn \
--cc=lpieralisi@kernel.org \
--cc=maobibo@loongson.cn \
--cc=maz@kernel.org \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rafael@kernel.org \
--cc=richard.henderson@linaro.org \
--cc=salil.mehta@huawei.com \
--cc=salil.mehta@opnsrc.net \
--cc=shahuang@redhat.com \
--cc=vishnu@os.amperecomputing.com \
--cc=wangxiongfeng2@huawei.com \
--cc=wangyanan55@huawei.com \
--cc=will@kernel.org \
--cc=zhao1.liu@intel.com \
--cc=zhukeqian1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).