Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CDF3606A338 for ; Thu, 3 Dec 2026 17:13:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ra8I0kqe Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZAMY-0002LV-L4; Thu, 03 Dec 2026 12:12:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZALG-0008Fu-Ni for qemu-devel@nongnu.org; Thu, 03 Dec 2026 12:11:38 -0500 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 1xZALC-0006j7-TY for qemu-devel@nongnu.org; Thu, 03 Dec 2026 12:11:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796317890; 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=fdGnxGLVf9VcDSHpZ4wyxg9wvHgeX7humQzAHKZirY8=; b=Ra8I0kqeBDJOU1O9DXyn0xrw5b0uki1RQ0zs+SYPHZPbdf/ZfUxtoEdLVCZohrsbO1naqN uy1iUDdkNX5H5eQXtr/TXXXozJQY3EO2013sig7p2me/ZIPJ7H17Es8rqPeRfZoMwrS4m0 RJF4YnOnnNLiceI3icD9Y8A2adfA0XE= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-WmBpkhS4OySssLQY5V5spw-1; Thu, 3 Dec 2026 17:11:24 +0000 X-MC-Unique: WmBpkhS4OySssLQY5V5spw-1 X-Mimecast-MFC-AGG-ID: WmBpkhS4OySssLQY5V5spw_1796317882 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9AD1C18B5F96; Thu, 3 Dec 2026 17:11:18 +0000 (UTC) Received: from eauger-thinkpadp1gen8.rmtfr.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 63FEF195605B; Thu, 3 Dec 2026 17:11:15 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shaju.abraham@nutanix.com, khushit.shah@nutanix.com, richard.henderson@linaro.org, pbonzini@redhat.com, skolothumtho@nvidia.com, philmd@oss.qualcomm.com Cc: armbru@redhat.com, mbawa@redhat.com, cohuck@redhat.com Subject: [PATCH v11 11/20] target/arm/kvm: Implement SYSREG property getter Date: Thu, 3 Dec 2026 18:09:00 +0100 Message-ID: <20261203171020.2594683-12-eric.auger@redhat.com> In-Reply-To: <20261203171020.2594683-1-eric.auger@redhat.com> References: <20261203171020.2594683-1-eric.auger@redhat.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Set SYSREG property values will be recorded in a hash table to be applied later on at vcpu init time. Add this hash table and just implement the getter for now. If the property is explicitly set, the getter returns that value, otherwise it returns the associated cpu->isar.idregs[] value. This array is initially populated using the "max" scratch vcpu initialized with all supported features until the final vcpu gets initialized. Signed-off-by: Eric Auger --- target/arm/cpu.h | 2 ++ target/arm/cpu.c | 5 +++-- target/arm/cpu64.c | 25 ++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9dc09f5637..4cfaafd6ed 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -972,6 +972,8 @@ struct ArchCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; + GHashTable *sysreg_props; + DynamicGDBFeatureInfo dyn_sysreg_feature; DynamicGDBFeatureInfo dyn_svereg_feature; DynamicGDBFeatureInfo dyn_smereg_feature; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index dde03ffdd6..cc1891f945 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1248,8 +1248,8 @@ static void arm_cpu_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); - cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, - NULL, g_free); + cpu->cp_regs = g_hash_table_new(g_direct_hash, g_direct_equal); + cpu->sysreg_props = g_hash_table_new(g_direct_hash, g_direct_equal); QLIST_INIT(&cpu->pre_el_change_hooks); QLIST_INIT(&cpu->el_change_hooks); @@ -1754,6 +1754,7 @@ static void arm_cpu_finalizefn(Object *obj) ARMCPRegMigTolerance *t, *n; g_hash_table_destroy(cpu->cp_regs); + g_hash_table_destroy(cpu->sysreg_props); if (cpu->host_cpu_probe_err) { error_free(cpu->host_cpu_probe_err); diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 003e8fbdf7..d53bd8f3ec 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -815,6 +815,9 @@ static void kvm_arm_set_cpreg_mig_tolerances(ARMCPU *cpu) UINT64_MAX, 0, ToleranceOnlySrcTestValue); } +#define IDREG_FIELD_KEY(reg_idx, field_shift) \ + (((uint64_t)(reg_idx) << 8) | ((uint64_t)(field_shift) & 0xFF)) + static void set_sysreg_prop(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -826,7 +829,27 @@ static void get_sysreg_prop(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - error_setg(errp, "%s getter not yet implemented", name); + ARM64SysRegField *field = (ARM64SysRegField *)opaque; + ARMCPU *cpu = ARM_CPU(obj); + int index = field->index; + int lower = field->shift; + int length = field->length; + gpointer value_ptr; + uint64_t value; + uint64_t key = IDREG_FIELD_KEY(index, lower); + gboolean exists; + + exists = g_hash_table_lookup_extended(cpu->sysreg_props, + GUINT_TO_POINTER(key), NULL, + &value_ptr); + if (exists) { + value = GPOINTER_TO_UINT(value_ptr); + } else { + value = extract64(cpu->isar.idregs[index], lower, length); + } + + visit_type_uint64(v, name, &value, errp); + trace_get_sysreg_prop(name, value); } /** -- 2.56.1