From: Eric Auger <eric.auger@redhat.com>
To: Shameer Kolothum <shameerkolothum@gmail.com>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, cohuck@redhat.com, sebott@redhat.com,
berrange@redhat.com, maz@kernel.org, oliver.upton@linux.dev,
armbru@redhat.com, linuxarm@huawei.com, wangzhou1@hisilicon.com,
jiangkunkun@huawei.com, jonathan.cameron@huawei.com,
salil.mehta@huawei.com, yangjinqian1@huawei.com,
shameerali.kolothum.thodi@huawei.com
Subject: Re: [RFC PATCH RESEND 4/4] hw/arm/virt: Add Target Implementation CPU support
Date: Sat, 9 Aug 2025 18:21:06 +0200 [thread overview]
Message-ID: <5c4dab6f-6e14-4a05-b967-b9068144a079@redhat.com> (raw)
In-Reply-To: <20250801074730.28329-5-shameerkolothum@gmail.com>
Hi Shameer,
On 8/1/25 9:47 AM, Shameer Kolothum wrote:
> From: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
>
> Add the impl-cpu property to virt machine. This will enable
> user to specify the target implementation CPUs as the example
> below:
>
> ...
> -M impl-cpu.0.midr=1,impl-cpu.0.revidr=1,impl-cpu.0.aidr=1,\
> impl-cpu.1.midr=2,impl-cpu.1.revidr=2,impl-cpu.1.aidr=2 \
>
> Make use of helper functions to check the KVM support for target
> Impl CPUs and if supported set the user specified target CPUs.
I think you need to document the new virt options in
docs/system/arm/virt.rst
>
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> hw/arm/virt.c | 66 +++++++++++++++++++++++++++++++++++++++++++
> include/hw/arm/virt.h | 3 ++
> 2 files changed, 69 insertions(+)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index a96452f17a..72a0cd3ea8 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -71,6 +71,7 @@
> #include "hw/firmware/smbios.h"
> #include "qapi/visitor.h"
> #include "qapi/qapi-visit-common.h"
> +#include "qapi/qapi-visit-machine.h"
> #include "qobject/qlist.h"
> #include "standard-headers/linux/input.h"
> #include "hw/arm/smmuv3.h"
> @@ -2232,6 +2233,20 @@ static void machvirt_init(MachineState *machine)
> exit(1);
> }
>
> + if (vms->target_cpus_num) {
> + if (!kvm_enabled()) {
> + error_report("Target Impl CPU requested, but not supported "
> + "without KVM");
> + exit(1);
> + }
> +
> + if (!kvm_arm_target_impl_cpus_supported()) {
> + error_report("Target Impl CPU requested, but not supported by KVM");
> + exit(1);
> + }
> + kvm_arm_set_target_impl_cpus(vms->target_cpus_num, vms->target_cpus);
> + }
> +
> create_fdt(vms);
>
> assert(possible_cpus->len == max_cpus);
> @@ -2666,6 +2681,45 @@ static void virt_set_oem_table_id(Object *obj, const char *value,
> strncpy(vms->oem_table_id, value, 8);
> }
>
> +static void virt_set_target_impl_cpus(Object *obj, Visitor *v,
> + const char *name, void *opaque,
> + Error **errp)
> +{
> + VirtMachineState *vms = VIRT_MACHINE(obj);
> + ArmTargetImplCPUList *list = NULL;
> + ArmTargetImplCPUList *iter = NULL;
> + ArmTargetImplCPU *target_cpus;
> + uint64_t target_num = 0;
> + int i;
> +
> + visit_type_ArmTargetImplCPUList(v, name, &list, errp);
> + if (!list) {
> + return;
> + }
> +
> + for (iter = list; iter; iter = iter->next) {
> + target_num++;
> + }
> +
> + target_cpus = g_new0(ArmTargetImplCPU, target_num);
> + for (i = 0, iter = list; iter; iter = iter->next, i++) {
> + target_cpus[i].midr = iter->value->midr;
> + target_cpus[i].revidr = iter->value->revidr;
> + target_cpus[i].aidr = iter->value->aidr;
> + }
Can't you avoid having both an array and a list. Can you use the list
all the way?
> + vms->target_cpus_num = target_num;
> + vms->target_cpus = target_cpus;
> + vms->target_cpus_list = list;
> +}
> +
> +static void virt_get_target_impl_cpus(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> +{
> + VirtMachineState *vms = VIRT_MACHINE(obj);
> + ArmTargetImplCPUList **list = &vms->target_cpus_list;
> +
> + visit_type_ArmTargetImplCPUList(v, name, list, errp);
> +}
>
> bool virt_is_acpi_enabled(VirtMachineState *vms)
> {
> @@ -3326,6 +3380,18 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
> "Override the default value of field OEM Table ID "
> "in ACPI table header."
> "The string may be up to 8 bytes in size");
> + object_class_property_add(oc, "impl-cpu", "ArmTargetImplCPU",
> + virt_get_target_impl_cpus,
> + virt_set_target_impl_cpus,
> + NULL, NULL);
> + object_class_property_set_description(oc, "impl-cpu",
> + "Describe target implementation CPU in the format: "
> + "impl-cpu.0.midr=1,"
> + "impl-cpu.0.revidr=1,"
> + "impl-cpu.0.aidr=1,"
> + "impl-cpu.1.midr=2,"
> + "impl-cpu.1.revidr=2,"
> + "impl-cpu.1.aidr=2");
>
> }
>
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index c8e94e6aed..cf462fcb37 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -180,6 +180,9 @@ struct VirtMachineState {
> char *oem_id;
> char *oem_table_id;
> bool ns_el2_virt_timer_irq;
> + uint64_t target_cpus_num;
> + ArmTargetImplCPU *target_cpus;
> + ArmTargetImplCPUList *target_cpus_list;
> };
>
> #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
Thanks
Eric
next prev parent reply other threads:[~2025-08-09 16:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 7:47 [RFC PATCH RESEND 0/4] hw/arm/virt: Add support for Target Implementation CPUs Shameer Kolothum
2025-08-01 7:47 ` [RFC PATCH RESEND 1/4] target/arm/kvm: Introduce helper to check target impl CPU support Shameer Kolothum
2025-08-09 16:21 ` Eric Auger
2025-08-01 7:47 ` [RFC PATCH RESEND 2/4] target/arm/kvm: Add QAPI struct ArmTargetImplCPU Shameer Kolothum
2025-08-09 16:23 ` Eric Auger
2025-08-01 7:47 ` [RFC PATCH RESEND 3/4] target/arm/kvm: Handle KVM Target Imp CPU hypercalls Shameer Kolothum
2025-09-19 10:51 ` Sebastian Ott
2025-08-01 7:47 ` [RFC PATCH RESEND 4/4] hw/arm/virt: Add Target Implementation CPU support Shameer Kolothum
2025-08-09 16:21 ` Eric Auger [this message]
2025-08-01 8:31 ` [RFC PATCH RESEND 0/4] hw/arm/virt: Add support for Target Implementation CPUs Cornelia Huck
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=5c4dab6f-6e14-4a05-b967-b9068144a079@redhat.com \
--to=eric.auger@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=cohuck@redhat.com \
--cc=jiangkunkun@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=linuxarm@huawei.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=salil.mehta@huawei.com \
--cc=sebott@redhat.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shameerkolothum@gmail.com \
--cc=wangzhou1@hisilicon.com \
--cc=yangjinqian1@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).