From nobody Sat Apr 11 23:03:22 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772619461; cv=none; d=zohomail.com; s=zohoarc; b=Phujt3/FZvTO8EfTUB8G7e7N5JA6d07h/ZUy8oS7YPmy7LWh2ZNAZbuGJZP7oaj0pWHvOC8j4WBFt5bqjQbsHrFpH26QtOw/YlZWBjFOGViAuQkPirdO3fkT18gF2bbKL85hkICOGOv6vFlOzC7rTWc/2BwNKaewtijOXVqH/MI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772619461; h=Content-Transfer-Encoding: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:Cc; bh=iTlHwn8rYLZPRQjXoSe79P2x9337a1IkyDkbCV1HoWU=; b=CwpgrNwGb1Zri2lEPQvskFeAHvLxED7AAH18+CCYS03SuOaQR8TpvS1G2Bbr1XrGKe5Vm78R66reZlzc1ybiCgEuzSM6d8v+Q77j0fE7S8r+k29XrE0H38AH8W4XbScLVlDzXtjSEGzTPKO+FPgHlDWHtWwhJEFJCXTnjRaBleA= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772619461544769.1058133460078; Wed, 4 Mar 2026 02:17:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxjHX-0002Qf-Eg; Wed, 04 Mar 2026 05:16:43 -0500 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 1vxjHW-0002Q4-4e for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:42 -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 1vxjHU-0008Sn-NA for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:41 -0500 Received: from mx-prod-mc-05.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-640-Yl_Dzu6bPWeIS_cn7Js3YA-1; Wed, 04 Mar 2026 05:16:36 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8D8E01956088; Wed, 4 Mar 2026 10:16:35 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 899A71800576; Wed, 4 Mar 2026 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772619399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iTlHwn8rYLZPRQjXoSe79P2x9337a1IkyDkbCV1HoWU=; b=W7oeXLnXMR9lWOR/KWnOXehmnUWwWq4ozTCVejGR0uHGMjiw2hPYUDtX+VaKMXYUsGgdF/ +YZZcJgE0KqdtSyb8mcb0PX9WeQPbFvH5/szYF4ReKPtVz6r4rdOmKt1aqxp87ADuvo/WZ h65GEa5fsd8xMkeKeFyTrG+xw1Vw8I8= X-MC-Unique: Yl_Dzu6bPWeIS_cn7Js3YA-1 X-Mimecast-MFC-AGG-ID: Yl_Dzu6bPWeIS_cn7Js3YA_1772619395 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, cohuck@redhat.com, sebott@redhat.com, peterx@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 1/7] vmstate: Introduce VMSTATE_VARRAY_INT32_ALLOC Date: Wed, 4 Mar 2026 11:15:40 +0100 Message-ID: <20260304101625.1962633-2-eric.auger@redhat.com> In-Reply-To: <20260304101625.1962633-1-eric.auger@redhat.com> References: <20260304101625.1962633-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: 27 X-Spam_score: 2.7 X-Spam_bar: ++ X-Spam_report: (2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.322, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-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: 1772619464907139100 Content-Type: text/plain; charset="utf-8" Already existing VMSTATE_VARRAY_INT32 requires an array to be pre-allocated, however there are cases when the size is not known in advance and there is no real need to enforce it. Introduce VMSTATE_VARRAY_INT32_ALLOC as we currently have for UINT32 and UINT16. The first user of this variant will be the target/arm/machine.c cpreg indexes/values arrays. Signed-off-by: Eric Auger Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Reviewed-by: Peter Xu --- include/migration/vmstate.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 89f9f49d20a..62c2abd0c49 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -447,6 +447,16 @@ extern const VMStateInfo vmstate_info_qlist; .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 +#define VMSTATE_VARRAY_INT32_ALLOC(_field, _state, _field_num, _version, _= info, _type) {\ + .name =3D (stringify(_field)), \ + .version_id =3D (_version), \ + .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .info =3D &(_info), \ + .size =3D sizeof(_type), \ + .flags =3D VMS_VARRAY_INT32 | VMS_POINTER | VMS_ALLOC, \ + .offset =3D vmstate_offset_pointer(_state, _field, _type), \ +} + #define VMSTATE_VARRAY_UINT32_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ --=20 2.53.0 From nobody Sat Apr 11 23:03:22 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772619467; cv=none; d=zohomail.com; s=zohoarc; b=R2K1UfDyOLXEHvIgcBB+RLLeQRnxlLlZTUz3HhWFDw3p3vy4zgCqBtXLbbBmV/rWvNCzLKU8W78FDm+FRPpDRzRZRYF44v67ih+Dd1U/YmDcd5+Hg8Zla+P8KIEPupf/MXzc6nYr43okcMPL4KHm+38JBhv3GydlqEDPu1ubcRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772619467; h=Content-Transfer-Encoding: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:Cc; bh=HlxXD3SwRBQxQ8pUvaYL9idlSRo9xX0PZQG86dGOGJM=; b=UXwaVFn05KpnPqnmvbIGliqZgK++JAybIinF4EkK92Cna1t5ZpUBrvTwbmW4SRSeloKiNisbwM0bYmA6AAXWaRj0GgGXUWwTQwlHbshKaAMW4FnIG2tST/YrPu/b/i7OlM0lFYXPP6A+kXwIoPYTBn+2H7NhobGou25sNajKRbM= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772619467969235.40752568079245; Wed, 4 Mar 2026 02:17:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxjHb-0002Rl-6U; Wed, 04 Mar 2026 05:16:47 -0500 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 1vxjHZ-0002RI-MP for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxjHX-0008Tb-Ts for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:45 -0500 Received: from mx-prod-mc-06.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-411-s8yti4ZSNE-hs-HIGf5rhA-1; Wed, 04 Mar 2026 05:16:40 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D22E18005B8; Wed, 4 Mar 2026 10:16:39 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0EDE7180035F; Wed, 4 Mar 2026 10:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772619403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HlxXD3SwRBQxQ8pUvaYL9idlSRo9xX0PZQG86dGOGJM=; b=a5H0JM38IsaPBvew8eDNu1s9ynXVCk7xyVXGSrCiWunyecrw8Ag9D7QQ6v/M6Z2ROofrZ9 ewtkLsirc0jrP6+fEqQ+oNWG29L4XlMmuwP1BIVq/QoFdszD/KV3VMim7JxuhvJNokoQTP l45P4p9N5t8g2uZZObG0+lp7TcBoMYM= X-MC-Unique: s8yti4ZSNE-hs-HIGf5rhA-1 X-Mimecast-MFC-AGG-ID: s8yti4ZSNE-hs-HIGf5rhA_1772619399 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, cohuck@redhat.com, sebott@redhat.com, peterx@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 2/7] target/arm/machine: Use VMSTATE_VARRAY_INT32_ALLOC for cpreg arrays Date: Wed, 4 Mar 2026 11:15:41 +0100 Message-ID: <20260304101625.1962633-3-eric.auger@redhat.com> In-Reply-To: <20260304101625.1962633-1-eric.auger@redhat.com> References: <20260304101625.1962633-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.322, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-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: 1772619470817139100 Content-Type: text/plain; charset="utf-8" This removes the need for explicitly allocating cpreg_vmstate arrays. On post save we simply point to cpreg arrays and set the length accordingly. Remove VMSTATE_VARRAY_INT32 for cpreg_vmstate_array_len as now the array is dynamically allocated. Also add a trace point on post_load to trace potential mismatch between the number of incoming cpregs versus current ones. Signed-off-by: Eric Auger Suggested-by: Peter Maydell Reviewed-by: Peter Maydell --- v1 -> v2: - also modifies the allocation of cpureg_vmstate_* in target/arm/whpx/whpx-all.c - added Peter's suggested comment on cpu_pre_save() - free the the vmstate arrays on post_load - add assert on pre_load - fix comment aboy length check in machine.c v2 -> v3: - clear the pointers also in post_save() --- target/arm/helper.c | 5 ----- target/arm/kvm.c | 5 ----- target/arm/machine.c | 45 +++++++++++++++++++++++++++----------- target/arm/whpx/whpx-all.c | 7 ------ target/arm/trace-events | 3 +++ 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 6bfab90981c..7389f2988c4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -265,15 +265,10 @@ void arm_init_cpreg_list(ARMCPU *cpu) if (arraylen) { cpu->cpreg_indexes =3D g_new(uint64_t, arraylen); cpu->cpreg_values =3D g_new(uint64_t, arraylen); - cpu->cpreg_vmstate_indexes =3D g_new(uint64_t, arraylen); - cpu->cpreg_vmstate_values =3D g_new(uint64_t, arraylen); } else { cpu->cpreg_indexes =3D NULL; cpu->cpreg_values =3D NULL; - cpu->cpreg_vmstate_indexes =3D NULL; - cpu->cpreg_vmstate_values =3D NULL; } - cpu->cpreg_vmstate_array_len =3D arraylen; cpu->cpreg_array_len =3D 0; =20 g_hash_table_foreach(cpu->cp_regs, add_cpreg_to_list, cpu); diff --git a/target/arm/kvm.c b/target/arm/kvm.c index eaa065d7261..555083e7aaf 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -864,12 +864,7 @@ static int kvm_arm_init_cpreg_list(ARMCPU *cpu) =20 cpu->cpreg_indexes =3D g_renew(uint64_t, cpu->cpreg_indexes, arraylen); cpu->cpreg_values =3D g_renew(uint64_t, cpu->cpreg_values, arraylen); - cpu->cpreg_vmstate_indexes =3D g_renew(uint64_t, cpu->cpreg_vmstate_in= dexes, - arraylen); - cpu->cpreg_vmstate_values =3D g_renew(uint64_t, cpu->cpreg_vmstate_val= ues, - arraylen); cpu->cpreg_array_len =3D arraylen; - cpu->cpreg_vmstate_array_len =3D arraylen; =20 for (i =3D 0, arraylen =3D 0; i < rlp->n; i++) { uint64_t regidx =3D rlp->reg[i]; diff --git a/target/arm/machine.c b/target/arm/machine.c index bbaae344492..d3d4f2ddc15 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "cpu.h" +#include "trace.h" #include "qemu/error-report.h" #include "system/kvm.h" #include "system/tcg.h" @@ -984,11 +985,14 @@ static int cpu_pre_save(void *opaque) } } =20 + /* + * On outbound migration, send the data in our cpreg_{values,indexes} + * arrays. The migration code will not allocate anything, but just + * reads the data pointed to by the VMSTATE_VARRAY_INT32_ALLOC() field= s. + */ + cpu->cpreg_vmstate_indexes =3D cpu->cpreg_indexes; + cpu->cpreg_vmstate_values =3D cpu->cpreg_values; cpu->cpreg_vmstate_array_len =3D cpu->cpreg_array_len; - memcpy(cpu->cpreg_vmstate_indexes, cpu->cpreg_indexes, - cpu->cpreg_array_len * sizeof(uint64_t)); - memcpy(cpu->cpreg_vmstate_values, cpu->cpreg_values, - cpu->cpreg_array_len * sizeof(uint64_t)); =20 return 0; } @@ -1001,6 +1005,9 @@ static int cpu_post_save(void *opaque) pmu_op_finish(&cpu->env); } =20 + cpu->cpreg_vmstate_indexes =3D NULL; + cpu->cpreg_vmstate_values =3D NULL; + return 0; } =20 @@ -1034,6 +1041,9 @@ static int cpu_pre_load(void *opaque) pmu_op_start(env); } =20 + g_assert(!cpu->cpreg_vmstate_indexes); + g_assert(!cpu->cpreg_vmstate_values); + return 0; } =20 @@ -1043,6 +1053,9 @@ static int cpu_post_load(void *opaque, int version_id) CPUARMState *env =3D &cpu->env; int i, v; =20 + trace_cpu_post_load(cpu->cpreg_vmstate_array_len, + cpu->cpreg_array_len); + /* * Handle migration compatibility from old QEMU which didn't * send the irq-line-state subsection. A QEMU without it did not @@ -1094,6 +1107,11 @@ static int cpu_post_load(void *opaque, int version_i= d) } } =20 + g_free(cpu->cpreg_vmstate_indexes); + g_free(cpu->cpreg_vmstate_values); + cpu->cpreg_vmstate_indexes =3D NULL; + cpu->cpreg_vmstate_values =3D NULL; + /* * Misaligned thumb pc is architecturally impossible. Fail the * incoming migration. For TCG it would trigger the assert in @@ -1167,16 +1185,17 @@ const VMStateDescription vmstate_arm_cpu =3D { VMSTATE_UINT32_ARRAY(env.fiq_regs, ARMCPU, 5), VMSTATE_UINT64_ARRAY(env.elr_el, ARMCPU, 4), VMSTATE_UINT64_ARRAY(env.sp_el, ARMCPU, 4), - /* The length-check must come before the arrays to avoid - * incoming data possibly overflowing the array. + /* + * The length must come before the arrays so we can + * allocate the arrays before their data arrives */ - VMSTATE_INT32_POSITIVE_LE(cpreg_vmstate_array_len, ARMCPU), - VMSTATE_VARRAY_INT32(cpreg_vmstate_indexes, ARMCPU, - cpreg_vmstate_array_len, - 0, vmstate_info_uint64, uint64_t), - VMSTATE_VARRAY_INT32(cpreg_vmstate_values, ARMCPU, - cpreg_vmstate_array_len, - 0, vmstate_info_uint64, uint64_t), + VMSTATE_INT32(cpreg_vmstate_array_len, ARMCPU), + VMSTATE_VARRAY_INT32_ALLOC(cpreg_vmstate_indexes, ARMCPU, + cpreg_vmstate_array_len, + 0, vmstate_info_uint64, uint64_t), + VMSTATE_VARRAY_INT32_ALLOC(cpreg_vmstate_values, ARMCPU, + cpreg_vmstate_array_len, + 0, vmstate_info_uint64, uint64_t), VMSTATE_UINT64(env.exclusive_addr, ARMCPU), VMSTATE_UINT64(env.exclusive_val, ARMCPU), VMSTATE_UINT64(env.exclusive_high, ARMCPU), diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index bb94eac7bf8..c5b108166ac 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -783,12 +783,6 @@ int whpx_init_vcpu(CPUState *cpu) sregs_match_len); arm_cpu->cpreg_values =3D g_renew(uint64_t, arm_cpu->cpreg_values, sregs_match_len); - arm_cpu->cpreg_vmstate_indexes =3D g_renew(uint64_t, - arm_cpu->cpreg_vmstate_indexe= s, - sregs_match_len); - arm_cpu->cpreg_vmstate_values =3D g_renew(uint64_t, - arm_cpu->cpreg_vmstate_values, - sregs_match_len); =20 memset(arm_cpu->cpreg_values, 0, sregs_match_len * sizeof(uint64_t)); =20 @@ -807,7 +801,6 @@ int whpx_init_vcpu(CPUState *cpu) } } arm_cpu->cpreg_array_len =3D sregs_cnt; - arm_cpu->cpreg_vmstate_array_len =3D sregs_cnt; =20 assert(write_cpustate_to_list(arm_cpu, false)); =20 diff --git a/target/arm/trace-events b/target/arm/trace-events index 676d29fe516..2de0406f784 100644 --- a/target/arm/trace-events +++ b/target/arm/trace-events @@ -26,3 +26,6 @@ arm_powerctl_reset_cpu(uint64_t mp_aff) "cpu %" PRIu64 =20 # tcg/psci.c and hvf/hvf.c arm_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t= cpuid) "PSCI Call x0=3D0x%016"PRIx64" x1=3D0x%016"PRIx64" x2=3D0x%016"PRIx= 64" x3=3D0x%016"PRIx64" cpuid=3D0x%x" + +# machine.c +cpu_post_load(uint32_t cpreg_vmstate_array_len, uint32_t cpreg_array_len) = "cpreg_vmstate_array_len=3D%d cpreg_array_len=3D%d" --=20 2.53.0 From nobody Sat Apr 11 23:03:22 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772619461; cv=none; d=zohomail.com; s=zohoarc; b=WIyj2c7IwvNGtsk8BqGqeS89QjLteWR66GUqv1pPco9tY09JYNrkVMqZ68EFypBbG4/pE9F2n2buB2PnWWNa5GEYM+K0JbPiCX/7bPYdHUwzC+YBfnNMVydJMNJfPePPTygjIexwV3lzq4pBQaUqp4nCSWTprLQWmzYYJUBTfiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772619461; h=Content-Transfer-Encoding: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:Cc; bh=lIGaNKkd3Um45QtvQTiKVKpv/SaTG5SFybo4hElOcHI=; b=Fbv7j4si2CRCAGfYIqmXAZIZavL7YjXSKw7qIs/ZbFxxGPogycwvPMyylupRrflmRvN3AIWtk5glI4mHK4UZ6F2yngAAJRSBuXTkEYlfZjgmaEjXtSc6Y3DlYg1Vcnr9scfef0NmVA1VIiLtVVvod+5/MLA0Fw4BGf6Y5LlXwio= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772619461922800.9694784868847; Wed, 4 Mar 2026 02:17:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxjHe-0002Sr-Rd; Wed, 04 Mar 2026 05:16:50 -0500 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 1vxjHd-0002SK-31 for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxjHb-0008UR-LP for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:48 -0500 Received: from mx-prod-mc-01.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-623-HzjC2kp6NdukpCTS58e_zw-1; Wed, 04 Mar 2026 05:16:43 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7FECD1956050; Wed, 4 Mar 2026 10:16:42 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 83A85180035F; Wed, 4 Mar 2026 10:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772619406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lIGaNKkd3Um45QtvQTiKVKpv/SaTG5SFybo4hElOcHI=; b=GpPk9vglSaOTu767rRevPT2tDDbiPD8j7yAv97TZT9gVRzUNIhF0fxF9wndTHfXckhCR/e o+rZL10q9w/gLk+ZABTpTOFFA5BXXERIabZ+9RBziLfHU2BSQfDMxTq1kO5xPd4vNBWgFo K0uYa1K30Cq8wfCWncczHhqjDtotIZI= X-MC-Unique: HzjC2kp6NdukpCTS58e_zw-1 X-Mimecast-MFC-AGG-ID: HzjC2kp6NdukpCTS58e_zw_1772619402 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, cohuck@redhat.com, sebott@redhat.com, peterx@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 3/7] target/arm/kvm: Export kvm_print_register_name() Date: Wed, 4 Mar 2026 11:15:42 +0100 Message-ID: <20260304101625.1962633-4-eric.auger@redhat.com> In-Reply-To: <20260304101625.1962633-1-eric.auger@redhat.com> References: <20260304101625.1962633-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 27 X-Spam_score: 2.7 X-Spam_bar: ++ X-Spam_report: (2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.322, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-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: 1772619464869139100 Content-Type: text/plain; charset="utf-8" We want to use kvm_print_register_name() in machine.c so let's export the helper and implement a stub when kvm is not enabled. Signed-off-by: Eric Auger Reviewed-by: Peter Maydell --- v2 -> v3: - added "The caller must free the string with g_free()." v1 -> v2: - add doc comment - no code after g_assert_not_reached() - use char * instead of gchar --- target/arm/kvm_arm.h | 9 +++++++++ target/arm/kvm-stub.c | 5 +++++ target/arm/kvm.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 82ac2aae464..e7c40fb003e 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -231,4 +231,13 @@ void arm_cpu_kvm_set_irq(void *arm_cpu, int irq, int l= evel); =20 void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3); =20 +/* + * kvm_print_register_name: + * @regidx: register KVM index + * + * Returns a human-readable string representing this register + * The caller must free the string with g_free(). + */ +char *kvm_print_register_name(uint64_t regidx); + #endif diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c index 169ef5f2063..88cbe8d85c4 100644 --- a/target/arm/kvm-stub.c +++ b/target/arm/kvm-stub.c @@ -114,3 +114,8 @@ void arm_gic_cap_kvm_probe(GICCapability *v2, GICCapabi= lity *v3) { g_assert_not_reached(); } + +char *kvm_print_register_name(uint64_t regidx) +{ + g_assert_not_reached(); +} diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 555083e7aaf..11f6f2dff09 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -970,7 +970,7 @@ static gchar *kvm_print_sve_register_name(uint64_t regi= dx) } } =20 -static gchar *kvm_print_register_name(uint64_t regidx) +char *kvm_print_register_name(uint64_t regidx) { switch ((regidx & KVM_REG_ARM_COPROC_MASK)) { case KVM_REG_ARM_CORE: --=20 2.53.0 From nobody Sat Apr 11 23:03:22 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772619443; cv=none; d=zohomail.com; s=zohoarc; b=Gyaz1bWOlR7DqFf40WZzRKG4hiD170tcgfV8Kz2FE1BukCI2x81pyAsqMWnkykglLc8Bv7IuVCZCUCJgUvKrsaYZpdsIsYZyDWzPfweJz0ws1QZJp8jfrdrELPS4XCGpzCjeHFI7joV+4hoST2s3AR9iN/4SlmTVjohwueIp3dM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772619443; h=Content-Transfer-Encoding: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:Cc; bh=+1jj448pXOqYIPaK5U/ImjiNKkjPlBXYRvaM9ojXNS8=; b=Nq8j+u94WLwpZHBtVQQ4JRHerJFgg80XBjhgg9ha++tAoWQFk5+opUODcntXTApuZKjUrEKMfNrvU84PwLoD1+pV6Vi1GJAvKTMlngCUXpblmKsiDSTKTBWmq1eYN3ye71Xc7niuE72/XZ2UwI84SmLD36WOcQbOezdtQA0WQS4= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772619443179111.24656291775455; Wed, 4 Mar 2026 02:17:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxjHh-0002TW-Ul; Wed, 04 Mar 2026 05:16:53 -0500 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 1vxjHg-0002TF-Hm for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:52 -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 1vxjHf-0008Ur-AQ for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:52 -0500 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-468-BomRAHVOOn6ZAkHyzsm_rQ-1; Wed, 04 Mar 2026 05:16:47 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 49EC2180034F; Wed, 4 Mar 2026 10:16:46 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 002511800576; Wed, 4 Mar 2026 10:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772619410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+1jj448pXOqYIPaK5U/ImjiNKkjPlBXYRvaM9ojXNS8=; b=PwC9e6BF1ciGLWfThHMK289E24Ey7p+ZV79esp5ZR/DFcvd3P7QToNcTCubPYQehUPvZyN L1mX8xkMVzSyroxzNoRVJ+58T3qT5qO+VtYNM+4L8bXfqieDX11SDTo7cole3oDyWWeN6l miVp1TUv9FuTnkXcFwxLhOHb8VYTqpc= X-MC-Unique: BomRAHVOOn6ZAkHyzsm_rQ-1 X-Mimecast-MFC-AGG-ID: BomRAHVOOn6ZAkHyzsm_rQ_1772619406 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, cohuck@redhat.com, sebott@redhat.com, peterx@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 4/7] target/arm/kvm: Tweak print_register_name() for arm64 system register Date: Wed, 4 Mar 2026 11:15:43 +0100 Message-ID: <20260304101625.1962633-5-eric.auger@redhat.com> In-Reply-To: <20260304101625.1962633-1-eric.auger@redhat.com> References: <20260304101625.1962633-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.322, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-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: 1772619444669139100 Content-Type: text/plain; charset="utf-8" As opposed to other register types, arm64 system register decoding is not introduced by any 'register' mention which can lead to unfriendly user-facing traces. Let's add "system register" Signed-off-by: Eric Auger Reviewed-by: Peter Maydell --- target/arm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 11f6f2dff09..d4a68874b88 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -978,7 +978,7 @@ char *kvm_print_register_name(uint64_t regidx) case KVM_REG_ARM_DEMUX: return g_strdup_printf("demuxed reg %"PRIx64, regidx); case KVM_REG_ARM64_SYSREG: - return g_strdup_printf("op0:%d op1:%d crn:%d crm:%d op2:%d", + return g_strdup_printf("system register op0:%d op1:%d crn:%d c= rm:%d op2:%d", CP_REG_ARM64_SYSREG_OP(regidx, OP0), CP_REG_ARM64_SYSREG_OP(regidx, OP1), CP_REG_ARM64_SYSREG_OP(regidx, CRN), --=20 2.53.0 From nobody Sat Apr 11 23:03:22 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772619485; cv=none; d=zohomail.com; s=zohoarc; b=CUBUXIVXdDgwbZlVggmVVBnndKJJtG8aiAf1DM5l6k83W8qtHJC4hNbqiM3CbqOpw6c+FnUV91dQLWR6f9dPHVkE+ex/p/cQ0e+d8fb1K10IW9G0Z5LCZ+9l1PkiVsNG7yietVl6wNWYJ89nVP/H/J0BhFnrzNOYRKZh/SFGdmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772619485; h=Content-Transfer-Encoding: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:Cc; bh=p4KrjsRSHH9+UibAZE15yZ5nfpyHQm1erp+ksXEeRaE=; b=YtyzAuruODGwjxBJWmkxsMsUYCgPi44YkMuJIs7KpPqUurcUbsteM/hWxfFd0xFzHt7gt+nGqG8G9xFVHBXoV5N1FsVy+AZr37+GeFRBvu5lVzMWQNKQKQTVv4MXUpuIqMH02+Q2meI3rFPo9gVknb9W18oocG7wH4suws1Kfjw= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772619485250932.8462398894075; Wed, 4 Mar 2026 02:18:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxjHm-0002WI-9H; Wed, 04 Mar 2026 05:16:58 -0500 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 1vxjHk-0002US-QX for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxjHj-0008VU-BG for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:56 -0500 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-619-X2RSBgQYNJyjXmGjepI_JQ-1; Wed, 04 Mar 2026 05:16:51 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 6F9C018002D6; Wed, 4 Mar 2026 10:16:50 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C117F180035F; Wed, 4 Mar 2026 10:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772619414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p4KrjsRSHH9+UibAZE15yZ5nfpyHQm1erp+ksXEeRaE=; b=XUnM1+xb29ggRNmp+6QMcnJCRh48MgEJFM7M7/xfCcpilug3Ohu14rnZBRNnwSIKFhelhZ GzsNJjXgbRcJmnkLv1jFkGTDjMCTl1ctG2okulJ7tiSpe4BNsxcnXK79ixxpMY9C7t/EYV fWuPzffO5SqR07IuRg67SiDS3jkvU9s= X-MC-Unique: X2RSBgQYNJyjXmGjepI_JQ-1 X-Mimecast-MFC-AGG-ID: X2RSBgQYNJyjXmGjepI_JQ_1772619410 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, cohuck@redhat.com, sebott@redhat.com, peterx@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 5/7] target/arm/machine: Trace cpreg names which do not match on migration Date: Wed, 4 Mar 2026 11:15:44 +0100 Message-ID: <20260304101625.1962633-6-eric.auger@redhat.com> In-Reply-To: <20260304101625.1962633-1-eric.auger@redhat.com> References: <20260304101625.1962633-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.322, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-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: 1772619487069158500 Content-Type: text/plain; charset="utf-8" Whenever there is a mismatch between cpreg indexes in the incoming stream and cpregs exposed by the destination output the name of the register. We use a print_register_name() wrapper helper. At the moment we are only able to do a nice decoding of the index for KVM regs. Without this patch, the error would be: qemu-system-aarch64: load of migration failed: Operation not permitted: error while loading state for instance 0x0 of device 'cpu': post load hook failed for: cpu, version_id: 22, minimum_version: 22, ret: -1 which is not helpful for the end user to understand the actual issue. This patch adds the actual information about the probme: qemu-system-aarch64: cpu_post_load: system register op0:3 op1:0 crn:2 crm:0 op2:3 in the incoming stream but unknown on the destination, fail migration Signed-off-by: Eric Auger Reviewed-by: Peter Maydell --- v1 -> v2: - replaced ',' by ':' in the traces - added system register in print_register_name when kvm is not enabled --- target/arm/machine.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/target/arm/machine.c b/target/arm/machine.c index d3d4f2ddc15..d9b65b5eed6 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -1,5 +1,6 @@ #include "qemu/osdep.h" #include "cpu.h" +#include "cpregs.h" #include "trace.h" #include "qemu/error-report.h" #include "system/kvm.h" @@ -1047,6 +1048,15 @@ static int cpu_pre_load(void *opaque) return 0; } =20 +static gchar *print_register_name(uint64_t kvm_regidx) +{ + if (kvm_enabled()) { + return kvm_print_register_name(kvm_regidx); + } else { + return g_strdup_printf("system register 0x%x", kvm_to_cpreg_id(kvm= _regidx)); + } +} + static int cpu_post_load(void *opaque, int version_id) { ARMCPU *cpu =3D opaque; @@ -1085,11 +1095,18 @@ static int cpu_post_load(void *opaque, int version_= id) for (i =3D 0, v =3D 0; i < cpu->cpreg_array_len && v < cpu->cpreg_vmstate_array_len; i++) { if (cpu->cpreg_vmstate_indexes[v] > cpu->cpreg_indexes[i]) { - /* register in our list but not incoming : skip it */ + g_autofree gchar *name =3D print_register_name(cpu->cpreg_inde= xes[i]); + + warn_report("%s: %s " + "expected by the destination but not in the incomi= ng stream: " + "skip it", __func__, name); continue; } if (cpu->cpreg_vmstate_indexes[v] < cpu->cpreg_indexes[i]) { - /* register in their list but not ours: fail migration */ + g_autofree gchar *name =3D print_register_name(cpu->cpreg_vmst= ate_indexes[v]); + + error_report("%s: %s in the incoming stream but unknown on the= destination: " + "fail migration", __func__, name); return -1; } /* matching register, copy the value over */ --=20 2.53.0 From nobody Sat Apr 11 23:03:22 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772619442; cv=none; d=zohomail.com; s=zohoarc; b=nKOq63KNyMf7XLjJYNhB83LF3bCqRvCrGPyuGT8HhEXFc9JKKKkFzVcoKLYPcgN39ddKOai4kT2kURLvPy09HwabaBqVu2p4wS55nb2S5Z9xHnZFC3wEuiWAJxWleM/Vh3yUL1jTIgPeeHF2SjjFNT3iXlPTJvrr8bCzLOsjQlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772619442; h=Content-Transfer-Encoding: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:Cc; bh=rSu49GisDF8e6yLxCXsyxBwd446dzS82icSX82FN4ho=; b=fiu+DoNFRkPKQ78PLrvlLpXrFy22U6Qvk+P2Wxr4a2ZrD4F/5qA9wKzKZ/qDPZtj2O8eUq8ycspU7gpphOcqposFI0FMaeXLc3kVGUPC8T5o2pM3YCJxz8feUsDPvi0ljuQnDtfGQywNhVPkBLMFwutKA1RmhsjUfIwc2oy4Y6A= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772619442730281.3693474286142; Wed, 4 Mar 2026 02:17:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxjHo-0002YI-FY; Wed, 04 Mar 2026 05:17:00 -0500 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 1vxjHn-0002Xg-7z for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:59 -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 1vxjHl-0008Vx-MW for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:16:58 -0500 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-92-4GD2f3YaPsenX4DmkMm0FQ-1; Wed, 04 Mar 2026 05:16:55 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 D118B19560B7; Wed, 4 Mar 2026 10:16:53 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D03CD1800576; Wed, 4 Mar 2026 10:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772619417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rSu49GisDF8e6yLxCXsyxBwd446dzS82icSX82FN4ho=; b=LAu0DxnIRoRmbbSPDWHs/UZL/rDtwRs4xtknL1pY9conVdYdcC4Gm+HlU47kHDPR6Cqkbg DU3WlHecxz4oDExWTEu2GFnooAB3ChYvg02yfEZqhUGjTcC4hmzTGkUIN+/Pe3QtJkOIW7 43sS8dyM/ZPYiK+AeyeuzLJJHEHKaoE= X-MC-Unique: 4GD2f3YaPsenX4DmkMm0FQ-1 X-Mimecast-MFC-AGG-ID: 4GD2f3YaPsenX4DmkMm0FQ_1772619413 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, cohuck@redhat.com, sebott@redhat.com, peterx@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 6/7] target/arm/machine: Trace all register mismatches Date: Wed, 4 Mar 2026 11:15:45 +0100 Message-ID: <20260304101625.1962633-7-eric.auger@redhat.com> In-Reply-To: <20260304101625.1962633-1-eric.auger@redhat.com> References: <20260304101625.1962633-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: 27 X-Spam_score: 2.7 X-Spam_bar: ++ X-Spam_report: (2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.322, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-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: 1772619444685139101 Content-Type: text/plain; charset="utf-8" At the moment, cpu_post_load() exits with error on the first catch of unexpected register in the incoming stream. Let the code go further and trace all the issues before exiting. Signed-off-by: Eric Auger Reviewed-by: Peter Maydell --- target/arm/machine.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/target/arm/machine.c b/target/arm/machine.c index d9b65b5eed6..4d9158e6977 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -1061,6 +1061,7 @@ static int cpu_post_load(void *opaque, int version_id) { ARMCPU *cpu =3D opaque; CPUARMState *env =3D &cpu->env; + bool fail =3D false; int i, v; =20 trace_cpu_post_load(cpu->cpreg_vmstate_array_len, @@ -1093,13 +1094,14 @@ static int cpu_post_load(void *opaque, int version_= id) */ =20 for (i =3D 0, v =3D 0; i < cpu->cpreg_array_len - && v < cpu->cpreg_vmstate_array_len; i++) { + && v < cpu->cpreg_vmstate_array_len;) { if (cpu->cpreg_vmstate_indexes[v] > cpu->cpreg_indexes[i]) { g_autofree gchar *name =3D print_register_name(cpu->cpreg_inde= xes[i]); =20 warn_report("%s: %s " "expected by the destination but not in the incomi= ng stream: " "skip it", __func__, name); + i++; continue; } if (cpu->cpreg_vmstate_indexes[v] < cpu->cpreg_indexes[i]) { @@ -1107,12 +1109,18 @@ static int cpu_post_load(void *opaque, int version_= id) =20 error_report("%s: %s in the incoming stream but unknown on the= destination: " "fail migration", __func__, name); - return -1; + v++; + fail =3D true; + continue; } /* matching register, copy the value over */ cpu->cpreg_values[i] =3D cpu->cpreg_vmstate_values[v]; + i++; v++; } + if (fail) { + return -1; + } =20 if (kvm_enabled()) { if (!kvm_arm_cpu_post_load(cpu)) { --=20 2.53.0 From nobody Sat Apr 11 23:03:22 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772619467; cv=none; d=zohomail.com; s=zohoarc; b=eyUKFdK/p01/qEtkSYbJhQBDx9uejJ/oaVOdij1kctb10DXlMJhinrVIJqkxOywj4wt+tob70TGEMERpJD6xe3t8StKUdbnKq+p/MJF80qobmSATA7e8l1BGvfRcXHN1+ldaLVzfzvdh0wIULaG3YmjvqW6gTVqeZyNbTbkSa7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772619467; h=Content-Transfer-Encoding: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:Cc; bh=1RfRbHaxOdpI0Go4PT/3oi8et5sCJagp6lTvVhemN+g=; b=gYqaeJfdDQdpHqZezRCpwMpdGhsKnV9f4dTvzKhtJqN4y2I4TjlGsxkyyeIXrcNYf3tKTwe0njoLy7nH5HsgYGnXQp3zoSaGkD7HBy5tyZgG1pZ7p+ZVpCKP69JFnMtfm23TuAg+2r0q7kX+ZtbWi8YFfWTxGkeJAJcMgVjeg+k= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772619466798699.9058414407572; Wed, 4 Mar 2026 02:17:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxjHw-0002uQ-7U; Wed, 04 Mar 2026 05:17:08 -0500 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 1vxjHt-0002m3-2V for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:17:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vxjHq-00004s-LK for qemu-devel@nongnu.org; Wed, 04 Mar 2026 05:17:04 -0500 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-461-Ei45-ov8O9me6XXx_rB1Lw-1; Wed, 04 Mar 2026 05:16:58 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 51C1B19560B7; Wed, 4 Mar 2026 10:16:57 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 53094180035F; Wed, 4 Mar 2026 10:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772619421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1RfRbHaxOdpI0Go4PT/3oi8et5sCJagp6lTvVhemN+g=; b=W8nCxg88xYg1Gy9bVBRELEVTglIPWEaYDQD70bFxPDC1N5c09Uy/t/HAJdRTKAUFmagubH 2EttzBUxkCZ3/PDaDuoEGS57NttqQJDqlxIEM4jonTt8l2gAbj78BTvqnIgxuxKh8vxJ/e wdciv9ocA19HdRtmReYiLJXzAAF49JA= X-MC-Unique: Ei45-ov8O9me6XXx_rB1Lw-1 X-Mimecast-MFC-AGG-ID: Ei45-ov8O9me6XXx_rB1Lw_1772619417 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, cohuck@redhat.com, sebott@redhat.com, peterx@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 7/7] target/arm/machine: Fix detection of unknown incoming cpregs Date: Wed, 4 Mar 2026 11:15:46 +0100 Message-ID: <20260304101625.1962633-8-eric.auger@redhat.com> In-Reply-To: <20260304101625.1962633-1-eric.auger@redhat.com> References: <20260304101625.1962633-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 27 X-Spam_score: 2.7 X-Spam_bar: ++ X-Spam_report: (2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.322, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.141, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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-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: 1772619469269158500 Content-Type: text/plain; charset="utf-8" Currently the check of cpreg index matches fail to detect a situation where the length of both arrays is same but - destination has an extra register not found in the incoming stream (idx1) - source has an extra register not found in the destination (idx2) where idx1 < =3D idx2 Normally this should fail but it does not. Fix the logic to scan all indexes. Fixes: 721fae12536 ("target-arm: Convert TCG to using (index,value) list fo= r cp migration") Signed-off-by: Eric Auger Reviewed-by: Peter Maydell --- target/arm/machine.c | 61 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/target/arm/machine.c b/target/arm/machine.c index 4d9158e6977..476dad00ee7 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -1057,6 +1057,35 @@ static gchar *print_register_name(uint64_t kvm_regid= x) } } =20 +/* + * Handle the situation where @kvmidx is on destination but not + * in the incoming stream. This never fails the migration. + */ +static void handle_cpreg_missing_in_incoming_stream(ARMCPU *cpu, uint64_t = kvmidx) +{ + g_autofree gchar *name =3D print_register_name(kvmidx); + + warn_report("%s: %s " + "expected by the destination but not in the incoming strea= m: " + "skip it", __func__, name); +} + +/* + * Handle the situation where @kvmidx is in the incoming stream + * but not on destination. This currently fails the migration but + * we plan to accomodate some exceptions, hence the boolean returned value. + */ +static bool handle_cpreg_only_in_incoming_stream(ARMCPU *cpu, uint64_t kvm= idx) +{ + g_autofree gchar *name =3D print_register_name(kvmidx); + bool fail =3D true; + + error_report("%s: %s in the incoming stream but unknown on the " + "destination: fail migration", __func__, name); + + return fail; +} + static int cpu_post_load(void *opaque, int version_id) { ARMCPU *cpu =3D opaque; @@ -1096,21 +1125,12 @@ static int cpu_post_load(void *opaque, int version_= id) for (i =3D 0, v =3D 0; i < cpu->cpreg_array_len && v < cpu->cpreg_vmstate_array_len;) { if (cpu->cpreg_vmstate_indexes[v] > cpu->cpreg_indexes[i]) { - g_autofree gchar *name =3D print_register_name(cpu->cpreg_inde= xes[i]); - - warn_report("%s: %s " - "expected by the destination but not in the incomi= ng stream: " - "skip it", __func__, name); - i++; + handle_cpreg_missing_in_incoming_stream(cpu, cpu->cpreg_indexe= s[i++]); continue; } if (cpu->cpreg_vmstate_indexes[v] < cpu->cpreg_indexes[i]) { - g_autofree gchar *name =3D print_register_name(cpu->cpreg_vmst= ate_indexes[v]); - - error_report("%s: %s in the incoming stream but unknown on the= destination: " - "fail migration", __func__, name); - v++; - fail =3D true; + fail =3D handle_cpreg_only_in_incoming_stream(cpu, + cpu->cpreg_vmstate= _indexes[v++]); continue; } /* matching register, copy the value over */ @@ -1118,6 +1138,23 @@ static int cpu_post_load(void *opaque, int version_i= d) i++; v++; } + + /* + * if we have reached the end of the incoming array but there are + * still regs in cpreg, continue parsing the regs which are missing + * in the input stream + */ + for ( ; i < cpu->cpreg_array_len; i++) { + handle_cpreg_missing_in_incoming_stream(cpu, cpu->cpreg_indexes[i]= ); + } + /* + * if we have reached the end of the cpreg array but there are + * still regs in the input stream, continue parsing the vmstate array + */ + for ( ; v < cpu->cpreg_vmstate_array_len; v++) { + fail =3D handle_cpreg_only_in_incoming_stream(cpu, + cpu->cpreg_vmstate_ind= exes[v]); + } if (fail) { return -1; } --=20 2.53.0