From nobody Sat Apr 11 23:02:54 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=1772548994; cv=none; d=zohomail.com; s=zohoarc; b=Ccs9qyjUmAoHtMGoQ9MXgkgnO9D4fzNCc8VSSj1zfzji4NV8BGCJ/mTPw0sAy5xwUJOeRN331tgbe4FDflVBwoz1r50p3FIpySBSTKwgdK6gk/eli+0z6mAQQjptSUJMMpyeFwG5+HuwUGj0OKX0mlqR96tN4E3VX+pTixadCeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772548994; 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=jCcwaJWQYCPP0MMTvXw5UjlAHDFMso84J1iI6VFKt9n6saiCYe0yvOd9csRHbO0lbDoe9a25J5GbCQs45Ff2TFCSTXyY7d12oIMxx1k5P1e+cWziEWUMQJWigUu5lj6Yz5b92k2bczR/uWHfjSOnkPz+Uic0fbn51CZKX4+IieI= 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 1772548994401426.4570504112187; Tue, 3 Mar 2026 06:43:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxQuj-0001Y0-CM; Tue, 03 Mar 2026 09:39:57 -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 1vxQua-0001TW-3K for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39: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 1vxQuX-00028K-8Z for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:47 -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-407-ng_E7sGFO4uWdvvJI1M7cg-1; Tue, 03 Mar 2026 09:39:40 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 B165B180034D; Tue, 3 Mar 2026 14:39:37 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7D09430001B9; Tue, 3 Mar 2026 14:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772548784; 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=SwfdT24aU05r3lX2hrFpczM1S0tIEpMDol30jopvLRKmpKCFKO0aBoHJTqgvtDJBp/furJ bMbddbs8/06bQD//35Pp+lFfM7kq0iC1JSP1nhAPWj8JnlNwRKPXZlnd1b+EscQa2fK9Cu jbz3aOs8eSyIws8YPKdjOdlfvyHgH2A= X-MC-Unique: ng_E7sGFO4uWdvvJI1M7cg-1 X-Mimecast-MFC-AGG-ID: ng_E7sGFO4uWdvvJI1M7cg_1772548777 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 v2 1/7] vmstate: Introduce VMSTATE_VARRAY_INT32_ALLOC Date: Tue, 3 Mar 2026 15:36:33 +0100 Message-ID: <20260303143928.1747116-2-eric.auger@redhat.com> In-Reply-To: <20260303143928.1747116-1-eric.auger@redhat.com> References: <20260303143928.1747116-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.4 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: 1772548996284154100 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:02:54 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=1772548894; cv=none; d=zohomail.com; s=zohoarc; b=hHfBJP9Gfx9S3b4YlPBhKfvWLTyNSd5yaEmmDTMeBjrHsTSRarnvd4vmd/8MauPwtQ9kxeUb6K5qjuPGsz25RDzrica8+ES2/XPLVLKL7IkjD3zXci3Q7bxMqgQwm5boB751S8vLnv/jhEGxLxzqgys/k5+Ooz6UDKS1ZCXq6jY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772548894; 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=OYSwMDbbGzmGbaNGUtOTMIp5FF9JRV6nLKR1rTj01x0=; b=btWPBoliM9yWcSJ01EYUAL4jXgsqdatWUsxC6c/vj3QEs/kzE9W864RW0tf8TduyZk9CnshwezuXK7Z4cn7bkINkWFiQIVwF9b/+Z2FU22dxJPWCqD/owpJpvAmdrq5+P9esXDJ/ePcZ5l/pl/+L6lg2k8UYmr3rvvsQl9SO1eQ= 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 1772548894730154.17419274424537; Tue, 3 Mar 2026 06:41:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxQuk-0001Yv-69; Tue, 03 Mar 2026 09:39: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 1vxQud-0001UG-0Y for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:52 -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 1vxQuZ-00029l-RK for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:50 -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-659-vpUn1gqIM3CO-yeJK8j0dw-1; Tue, 03 Mar 2026 09:39:42 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 4E3691955F0B; Tue, 3 Mar 2026 14:39:41 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2FD6230001B9; Tue, 3 Mar 2026 14:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772548786; 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=OYSwMDbbGzmGbaNGUtOTMIp5FF9JRV6nLKR1rTj01x0=; b=JODYJZIjNihSvWy0aaJkaeW5vqZHELFpRaoq4zKZnzVxcRm1wUo7eZ0cWAkp9PpascQyI4 icKVmg4kVDvcN90OgVTWvCbnfrb0fZfO0kTuNwN3ab/vUwbCdqm275WE1IEVfLZjuw9mhH G7iagK+X7L9bUlxuSskVjVHQVveJ62E= X-MC-Unique: vpUn1gqIM3CO-yeJK8j0dw-1 X-Mimecast-MFC-AGG-ID: vpUn1gqIM3CO-yeJK8j0dw_1772548781 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 v2 2/7] target/arm/machine: Use VMSTATE_VARRAY_INT32_ALLOC for cpreg arrays Date: Tue, 3 Mar 2026 15:36:34 +0100 Message-ID: <20260303143928.1747116-3-eric.auger@redhat.com> In-Reply-To: <20260303143928.1747116-1-eric.auger@redhat.com> References: <20260303143928.1747116-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.4 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: 1772548897586154100 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 --- target/arm/helper.c | 5 ----- target/arm/kvm.c | 5 ----- target/arm/machine.c | 42 ++++++++++++++++++++++++++------------ target/arm/whpx/whpx-all.c | 7 ------- target/arm/trace-events | 3 +++ 5 files changed, 32 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 ded582e0da0..12a75f42e07 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -807,12 +807,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..aa617dd64db 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; } @@ -1034,6 +1038,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 +1050,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 +1104,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 +1182,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 40ada2d5b65..1429eab0c00 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -808,12 +808,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 @@ -832,7 +826,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:02:54 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=1772548902; cv=none; d=zohomail.com; s=zohoarc; b=PPSFx6vzKzQ/1sneCz5Xf5Jl1HF2EPyIIg7BiDoxFAY5UPDNrxE9h06Ld94yDrVYHwLv4sdzVe4Fcc1N/s5hMFZ4UJHXvHztJiHGqwwS8YFaUaCDIm0ifUjFlSJQ9SxMJolRG55TAGCL1cyb+j3e7PSw+bugT/vJS52XtqQTRUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772548902; 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=kvWtCfcf5xA5sKzkn7CU5so+nAY8+TITssoqVfCLesM=; b=mFPGj9nLGVgPZyHVnVkISsHu16gq5QTV7EkHe7anYJS82ih68GdyDKBUmbtmisZZ948WoKo3zlIj7hNysBKdX9YAq8l4aoeSjMTOp985ASguk6K8JOJ9Jhtv0vYDj8Ub1THk8r2bGE7HU6eoi8c9LgBPcCo+NmlqjiWxSou+l30= 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 1772548902724170.21553533402596; Tue, 3 Mar 2026 06:41:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxQuh-0001Xl-UL; Tue, 03 Mar 2026 09:39:56 -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 1vxQud-0001UJ-Bj for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:52 -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 1vxQub-0002Ay-RJ for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:51 -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-157-vMkF1KyxPfi3nJlDiqoAFw-1; Tue, 03 Mar 2026 09:39:46 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 E9920195605C; Tue, 3 Mar 2026 14:39:44 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B5062300022A; Tue, 3 Mar 2026 14:39:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772548789; 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=kvWtCfcf5xA5sKzkn7CU5so+nAY8+TITssoqVfCLesM=; b=StR5iNUZQ4trSDj4bwIHrPa7TlM8PC6+VqBIo8A/GA0JVs21dWtT5D0PP5vi3+63Poo2Fn Dazij9PuZ1m1i6rlt049SptiyTWnX5zp+CUwLgSmsKg6ObfRjoty9MdBQbrqrPG8L9WKLJ 9uc8fMA5QE0g/RA23yXsjVm8817uK2U= X-MC-Unique: vMkF1KyxPfi3nJlDiqoAFw-1 X-Mimecast-MFC-AGG-ID: vMkF1KyxPfi3nJlDiqoAFw_1772548785 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 v2 3/7] target/arm/kvm: Export kvm_print_register_name() Date: Tue, 3 Mar 2026 15:36:35 +0100 Message-ID: <20260303143928.1747116-4-eric.auger@redhat.com> In-Reply-To: <20260303143928.1747116-1-eric.auger@redhat.com> References: <20260303143928.1747116-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.4 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: 1772548905495154100 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 --- v1 -> v2: - add doc comment - no code after g_assert_not_reached() - use char * instead of gchar --- target/arm/kvm_arm.h | 8 ++++++++ target/arm/kvm-stub.c | 5 +++++ target/arm/kvm.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index cc0b374254e..ca2492c7412 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -266,4 +266,12 @@ 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 + */ +char *kvm_print_register_name(uint64_t regidx); + #endif diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c index ea67deea520..047e2291d98 100644 --- a/target/arm/kvm-stub.c +++ b/target/arm/kvm-stub.c @@ -129,3 +129,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 12a75f42e07..cfb46015d48 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -913,7 +913,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:02:54 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=1772548905; cv=none; d=zohomail.com; s=zohoarc; b=Q6SUsfHZ1hfTNga54cLN/FDA85WmfcRCornYg1r2j/+dIExBPLMpFDsRQQvAt9owyJJiVzgDXpftc3kJEQDSXFm0v4BIDj67uPjndovMrznTRF7mpIi6966m4BkForT4OgHh5bNaBFi8ZYBrGGVTlTpAchyMOwmHtvnf8CCWm88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772548905; 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=L2DtoZq5WsfdwG1vuykHjnRxWfUsfapLYRVd8mVgDBo=; b=QEhsLeaAm9csg5gBglKDBrpmPwGw+3I+JUDUMICoTI93ZjGVbClwUX/pgZ5L/o9niyatEhxYnWbZ3N7Fh/XI4VATgrS4FfPNNu/rzYIH0LRk0mdkE7X7ZA7zP04bC7M+mDwD6M+AWG9lbiDP+J5vhXC4DPoVfaSkhGhzyNL4xpA= 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 177254890568510.025556814007473; Tue, 3 Mar 2026 06:41:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxQuj-0001YD-Kl; Tue, 03 Mar 2026 09:39:57 -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 1vxQuh-0001XY-HY for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:55 -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 1vxQug-0002CY-32 for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:55 -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-491-yxDFXl-uOBiTgDH5gvuRvA-1; Tue, 03 Mar 2026 09:39:50 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 ADABD19560B7; Tue, 3 Mar 2026 14:39:48 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 67AD630001BF; Tue, 3 Mar 2026 14:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772548793; 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=L2DtoZq5WsfdwG1vuykHjnRxWfUsfapLYRVd8mVgDBo=; b=QN4sjWmgPW1eevU/AKlLZ4a/QD++JJ+7vHK0p894S9tISLYk7m1hnWHSozew5etazn/TpB v5fmA8CzgLu+9M54dZDVsDN5udtAKQIt+b0MHQbRjdbDIl1AkSKXrfnChBagZ7V6xGTzdA fnTk1dVq9SPnA2GwjBLKB824zuUgv+E= X-MC-Unique: yxDFXl-uOBiTgDH5gvuRvA-1 X-Mimecast-MFC-AGG-ID: yxDFXl-uOBiTgDH5gvuRvA_1772548788 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 v2 4/7] target/arm/kvm: Tweak print_register_name() for arm64 system register Date: Tue, 3 Mar 2026 15:36:36 +0100 Message-ID: <20260303143928.1747116-5-eric.auger@redhat.com> In-Reply-To: <20260303143928.1747116-1-eric.auger@redhat.com> References: <20260303143928.1747116-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.4 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: 1772548907505154100 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 cfb46015d48..43dab246097 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -921,7 +921,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:02:54 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=1772548892; cv=none; d=zohomail.com; s=zohoarc; b=dua1oqZTbITILEBcrKW3sKK+hQQOqSKYydGj5WzPgwufR4krV7VyHHYXDvTuPDnc5wZlryOiOe1guoiG73b4Gh29K8pYfZ4SW+nClb/lRUYfDNTceu8RgXTdJc9JqpMgJ/hpA7GH5682ec86OdmL0CRXSdEfBOsjos9ehgWBZfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772548892; 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=uqEFRcehEOqfJB6L6KH6l941FvMcz+lCVI77QQ4Ra1c=; b=lrCqzoZdGbTxFs/nXnck5IbuouDoICmJ2NIOjV0nsb78bAoovjtIGA6DnZ9rBi3mS5MyxOMqPfWgUIyL4zIcLtoMVflWhwhwD18maKl+JWRIyKlhZ6MHf+6mBacqb71hXuRtQVJ3NH89594iykANi9nUHXcxDPmBoZXkvhCkFdI= 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 1772548892149680.004317252089; Tue, 3 Mar 2026 06:41:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxQun-0001cj-7A; Tue, 03 Mar 2026 09:40:01 -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 1vxQul-0001b0-Iw for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:59 -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 1vxQuj-0002Cw-UZ for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:39:59 -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-575-hQa4N-Z0PDyxOlacah-3qw-1; Tue, 03 Mar 2026 09:39:54 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 C71661800266; Tue, 3 Mar 2026 14:39:52 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2C3CB30001B9; Tue, 3 Mar 2026 14:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772548797; 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=uqEFRcehEOqfJB6L6KH6l941FvMcz+lCVI77QQ4Ra1c=; b=f2nqUblZT10kTX1g9ErSJ3eP6yepe1BojcqfgDUpotz6/uxytdYIjtXwpwAguYCqJDfQar aBo3JcrThe5DZ1D0DYHd/5Fb1sxbvcX2tSQdWy9Yl6q8C0bQsoxh23hXicoU2OU0bWzW2U EW3Qrlj9YxH4iXW6mOySRe+a7KB3Y9U= X-MC-Unique: hQa4N-Z0PDyxOlacah-3qw-1 X-Mimecast-MFC-AGG-ID: hQa4N-Z0PDyxOlacah-3qw_1772548792 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 v2 5/7] target/arm/machine: Trace cpreg names which do not match on migration Date: Tue, 3 Mar 2026 15:36:37 +0100 Message-ID: <20260303143928.1747116-6-eric.auger@redhat.com> In-Reply-To: <20260303143928.1747116-1-eric.auger@redhat.com> References: <20260303143928.1747116-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.4 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: 1772548895787154100 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 aa617dd64db..7dd649e8f64 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" @@ -1044,6 +1045,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; @@ -1082,11 +1092,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:02:54 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=1772548837; cv=none; d=zohomail.com; s=zohoarc; b=MK4hK0CTFLPdx1VLtR4KnNJc3dGTSIb+P8nMcdMVbjbd8OR5iZOxtVjc6PuxXsZiHTa3b73BLkpX6MQI7OHgMjISty0CVPmiPXMMfFt/nPLWobT7WcRh+ZNrBYlKCpTHZtyZmftry/+fK+oeT8Dq+fLRT/N46sHylBSjNXUVej4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772548837; 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=oJHnFlbisgEtfr+pa9NG0vrx4X448WVIRora0FKjQFI=; b=an0YuHio87v7a00r4bvTfPtjIXfWYIBPKnS5zPGVWRs7VAkbv0XLNGThohnyTW45o71iBX2Ss09Bvub6cbyEuz6YTXRpulM2rjnwBUh4CS2W8Ptm0vPzhVw7UNiK5M0ZGJtTwD33j/MlAkbkOULo6akfLBgXB4QlzFNekR7zlX8= 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 1772548837804710.7214434810204; Tue, 3 Mar 2026 06:40:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxQus-0001fH-Bn; Tue, 03 Mar 2026 09:40:06 -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 1vxQuq-0001eo-F8 for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:40:04 -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 1vxQuo-0002Dk-5q for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:40:04 -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-34-GA67AYOvPyCz0FgmPNKzlg-1; Tue, 03 Mar 2026 09:39:57 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 49BFC1956055; Tue, 3 Mar 2026 14:39:56 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4543930001B9; Tue, 3 Mar 2026 14:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772548800; 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=oJHnFlbisgEtfr+pa9NG0vrx4X448WVIRora0FKjQFI=; b=SCVuJgxTW5mpQ6uchnC/fVR9ZXdz/7rOfU1pZYNgq9jW04LAtWEuzunMZvmj3zcsS2bMB5 jAFl3/OE6NGCg5BlFRpI0V1G1/ax27q9Mli+kHQdoOD4cQRT3CEaopZbYNX3L5A7+5/apu CWR0xmzOjhElCPpQ5gHpdryvlesznw8= X-MC-Unique: GA67AYOvPyCz0FgmPNKzlg-1 X-Mimecast-MFC-AGG-ID: GA67AYOvPyCz0FgmPNKzlg_1772548796 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 v2 6/7] target/arm/machine: Trace all register mismatches Date: Tue, 3 Mar 2026 15:36:38 +0100 Message-ID: <20260303143928.1747116-7-eric.auger@redhat.com> In-Reply-To: <20260303143928.1747116-1-eric.auger@redhat.com> References: <20260303143928.1747116-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.4 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: 1772548840045158500 Content-Type: text/plain; charset="utf-8" At the moment, cpu_post_load() exists 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 7dd649e8f64..13f3955be67 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -1058,6 +1058,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, @@ -1090,13 +1091,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]) { @@ -1104,12 +1106,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:02:54 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=1772548818; cv=none; d=zohomail.com; s=zohoarc; b=hciZcKhv7+Mb3yB3mzLvtjgoc8q/Y+tflikWaZvmM1DWqyK0BnqbaxfWDdQ9D/iGdMDY1qzOVEExImNpm8M9Kpiwt42d3oF0q2AhkF2BnQ2jkmpLERUgd3JiwtuIA/XDByZcCh0WeFqon0Oc43jqGPag4/hyToC42VNZJkgaV5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772548818; 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=TNWsxK6/NvYySeLU0trFMBVUsLLcD9gWIFbk5GtfTio=; b=fKhTBHoTtaLLvzRzGPm0upxsVRPkPFWWXXQ5VtGsSmuvF+6Bsbhl17TJaHcB4iIF2TyANBDVpbZII5NxDzxeikH9J0WyIDWMAFg0DR4vWwAK8fK5jZL5VpsY7r7eEFj02UBjWP/Frsrj10oPolUI4NvTPANAkRb0MJWBBWeWKRU= 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 177254881893222.776040097070904; Tue, 3 Mar 2026 06:40:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxQuv-0001jp-Vj; Tue, 03 Mar 2026 09:40:10 -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 1vxQuu-0001gA-70 for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:40:08 -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 1vxQus-0002Qm-9z for qemu-devel@nongnu.org; Tue, 03 Mar 2026 09:40:07 -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-372-YwX0zgVMNr2ntvB1o-rAqw-1; Tue, 03 Mar 2026 09:40:01 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 E90E71800259; Tue, 3 Mar 2026 14:39:59 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.45.224.89]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BC2AA30001BF; Tue, 3 Mar 2026 14:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772548805; 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=TNWsxK6/NvYySeLU0trFMBVUsLLcD9gWIFbk5GtfTio=; b=hHoLabAe/LyouQ23yq6OtieqywE49lUKbf7/BzmWc/HGeXDFo8mJQcsL9FAhWYuwYyagNR lomn5TA+sF6XY0xKgdh7c4PQqBAw5i1OuRi27Gk2OEYpRALReQbAU9YQa4X324ZGFrer1A hZWTfSnnWDCU6D+qxVJPHqwvxLPrWNU= X-MC-Unique: YwX0zgVMNr2ntvB1o-rAqw-1 X-Mimecast-MFC-AGG-ID: YwX0zgVMNr2ntvB1o-rAqw_1772548800 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 v2 7/7] target/arm/machine: Fix detection of unknown incoming cpregs Date: Tue, 3 Mar 2026 15:36:39 +0100 Message-ID: <20260303143928.1747116-8-eric.auger@redhat.com> In-Reply-To: <20260303143928.1747116-1-eric.auger@redhat.com> References: <20260303143928.1747116-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.4 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: 1772548822291139100 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. Signed-off-by: Eric Auger Fixes: 721fae12536 ("target-arm: Convert TCG to using (index,value) list fo= r cp migration") --- 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 13f3955be67..2108e7916bb 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -1054,6 +1054,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; @@ -1093,21 +1122,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 */ @@ -1115,6 +1135,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