From nobody Sat Nov 23 19:26:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729851848; cv=none; d=zohomail.com; s=zohoarc; b=V0HRL8Zqv6xQcM4WMj+4bunZnG43SVR7TVGx+DI6ISeMsDlrfWVpbjZsHc8r4SfpUc2t4SZk0POORAZVEgaJMt3KkIfqD4NGkpQmRjqRwSEOTSeCtJ5GuB59GYNXdKnH+ZzXqAUryC1U7VlQb/h6DzZxv5uPkk8PuHYVCHTTOfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729851848; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8niAlscBVwwCSjLpFwC9rmVeWlBw2tXPGjOWbhlMyKg=; b=bpjDM5IYtOQ5upJfK6HintgmNGfACrfazuqmg02vaQ6QYrVZOOQcLa8BsJiOpoj2KwZbqoTK0L350ruUTYRJCoRGT3JE2gbZucaosa3MBS/b9qON8LwwOX9WiFCBhUPvB7sWRrP5M7VTgPZemK+d74D1G0XPqf61pPkbRwO2f/c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1729851848200866.9298551806196; Fri, 25 Oct 2024 03:24:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4HSw-0005GC-MF; Fri, 25 Oct 2024 06:22:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4HSo-0004TW-MR for qemu-devel@nongnu.org; Fri, 25 Oct 2024 06:22:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4HSl-0000W8-BE for qemu-devel@nongnu.org; Fri, 25 Oct 2024 06:22:38 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-Jkhqw0YEO4OKyY_7Jxd8YA-1; Fri, 25 Oct 2024 06:22:24 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5E7B519560BD; Fri, 25 Oct 2024 10:22:22 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.194.5]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CF9C7196BB7D; Fri, 25 Oct 2024 10:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729851748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8niAlscBVwwCSjLpFwC9rmVeWlBw2tXPGjOWbhlMyKg=; b=ORitAnYfUVIwf/JQm5+EcL0+r1lbhZg5UeuKb/eebMW2rzG+ZWtJvbu8+EdYEzslEaMMhj EJOcmX8Hl9x84huixqetsA+H4WwZ6GLQ1nQK9fIn0NYk/ooovzdkfMgi1sBf7LG0CEZ4Jt jvzmeQAISgx3dcYgzPm0GCPX3AtA9RY= X-MC-Unique: Jkhqw0YEO4OKyY_7Jxd8YA-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, kvmarm@lists.linux.dev, peter.maydell@linaro.org, richard.henderson@linaro.org, alex.bennee@linaro.org, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, shameerali.kolothum.thodi@huawei.com, armbru@redhat.com, berrange@redhat.com, abologna@redhat.com, jdenemar@redhat.com Cc: shahuang@redhat.com, mark.rutland@arm.com, philmd@linaro.org, pbonzini@redhat.com Subject: [RFC 20/21] arm-qmp-cmds: introspection for custom model Date: Fri, 25 Oct 2024 12:17:39 +0200 Message-ID: <20241025101959.601048-21-eric.auger@redhat.com> In-Reply-To: <20241025101959.601048-1-eric.auger@redhat.com> References: <20241025101959.601048-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.263, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729851849618116600 Content-Type: text/plain; charset="utf-8" From: Cornelia Huck Implement the capability to query available options for the custom model. At the moment it only returns SYSREG_* options and values. Excerpt: (QEMU) query-cpu-model-expansion type=3Dfull model=3D{"name":"custom"} {"return": {"model": {"name": "custom", "props": {"SYSREG_ID_AA64PFR0_EL1_EL3": 1224979098931106066, "SYSREG_ID_AA64ISAR2_EL1_CLRBHB": 0, ../.. So this allows the upper stack to detect available writable ID regs and the "host passthrough model" values. Signed-off-by: Eric Auger Signed-off-by: Cornelia Huck --- TODO: Add the moment there is no way to test changing a given ID reg field value. ie: (QEMU) query-cpu-model-expansion type=3Dfull model=3D{"name":"custom", "pro= p":{"SYSREG_ID_AA64ISAR0_EL1_DP":0x13}} --- target/arm/arm-qmp-cmds.c | 56 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c index 3cc8cc738b..4a3f0e6ac6 100644 --- a/target/arm/arm-qmp-cmds.c +++ b/target/arm/arm-qmp-cmds.c @@ -21,6 +21,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "hw/boards.h" #include "kvm_arm.h" #include "qapi/error.h" @@ -98,6 +99,47 @@ static const char *cpu_model_advertised_features[] =3D { NULL }; =20 +static CpuModelExpansionInfo * +arm_query_custom_cpu_model_expansion(Object *obj, CpuModelExpansionType ty= pe, + CpuModelInfo *model, + Error **errp) +{ + /* returns id register map */ + CpuModelExpansionInfo *expansion_info; + ObjectProperty *prop; + ObjectPropertyIterator iter; + QDict *qdict_out; + + expansion_info =3D g_new0(CpuModelExpansionInfo, 1); + expansion_info->model =3D g_malloc0(sizeof(*expansion_info->model)); + expansion_info->model->name =3D g_strdup(model->name); + + qdict_out =3D qdict_new(); + + object_property_iter_init(&iter, obj); + + while ((prop =3D object_property_iter_next(&iter))) { + QObject *value; + + if (!g_str_has_prefix(prop->name, "SYSREG_")) { + continue; + } + value =3D object_property_get_qobject(obj, prop->name, &error_abor= t); + qdict_put_obj(qdict_out, prop->name, value); + } + + if (!qdict_size(qdict_out)) { + qobject_unref(qdict_out); + } else { + expansion_info->model->props =3D QOBJECT(qdict_out); + } + + object_unref(obj); + + + return expansion_info; +} + CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType= type, CpuModelInfo *model, Error **errp) @@ -130,7 +172,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(Cp= uModelExpansionType type, if (kvm_enabled()) { bool supported =3D false; =20 - if (!strcmp(model->name, "host") || !strcmp(model->name, "max")) { + if (!strcmp(model->name, "host") || !strcmp(model->name, "max") || + !strcmp(model->name, "custom")) { /* These are kvmarm's recommended cpu types */ supported =3D true; } else if (current_machine->cpu_type) { @@ -152,6 +195,17 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(C= puModelExpansionType type, =20 obj =3D object_new(object_class_get_name(oc)); =20 + /* The "custom" model is handled differently. */ + if (!strcmp(model->name, "custom")) { + expansion_info =3D arm_query_custom_cpu_model_expansion(obj, type,= model, + errp); + if (*errp) { + object_unref(obj); + return NULL; + } + return expansion_info; + } + if (model->props) { Visitor *visitor; Error *err =3D NULL; --=20 2.41.0