From nobody Sat Feb 7 08:53:21 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=1768981785; cv=none; d=zohomail.com; s=zohoarc; b=cGsC2xTJj6IURdg+fENdNhRo25zd7lolHRJrBsdzlYkUgEXodf8vTLmHhrEMZPH2UAI4hvUCgbPxeFFSR/12okfVi1JoTmhN36bpP9co8Z4NVRxIig0P7gXaTk28vOBNAC+u8xY5M8Pi/6jne45MEckNcPkqG4fYSYHfHhSX/D8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981785; 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=qXAAJgi5Pp5IxQlHOgCbVUi5+LNR/ufJNvpmy8ZUovs=; b=YzInogXRJyWPDOWwYmotpgMriO/70Nvs14sGa3zW6WI/mVWpwNRIU6EmGR+bLLmhhMiN/iDs1RIRuPhRvHtkjE5l5aFB97D+8fshl2V+nlRogD6zrg9skJMJC4HLxL0+AevpXr056bduUxZRgUPh7M+W9dEwEBtt6bzmPL7ZK6w= 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 1768981785742840.7724358048189; Tue, 20 Jan 2026 23:49:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSxb-0004UM-Lh; Wed, 21 Jan 2026 02:49:05 -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 1viSxT-0004Qb-JJ for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:48:57 -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 1viSxR-0003Os-Ap for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:48:54 -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-54-9sW2z0CgO5SVF9EHabJbAg-1; Wed, 21 Jan 2026 02:48:48 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 664FE1956046; Wed, 21 Jan 2026 07:48:47 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F2C5B19560A2; Wed, 21 Jan 2026 07:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981732; 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=qXAAJgi5Pp5IxQlHOgCbVUi5+LNR/ufJNvpmy8ZUovs=; b=TC+TR1XiB83yWaLuBgv5o6J9PCFBdCOFBB75xHOcx25Y+vOpPRh1yCV7gfNEJJxLEB9zao FACZaKSRcbMYeTtHCx4OaeWkaGRlv2NlInXzS9aXBNDzO7W+TwUrvs5KoYPJJQgHmYq48k X62LWTc2HMC2mFp4OnnL+PgzruGasAk= X-MC-Unique: 9sW2z0CgO5SVF9EHabJbAg-1 X-Mimecast-MFC-AGG-ID: 9sW2z0CgO5SVF9EHabJbAg_1768981727 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 01/11] hw/arm/virt: Rename arm_virt_compat into arm_virt_compat_defaults Date: Wed, 21 Jan 2026 08:46:38 +0100 Message-ID: <20260121074834.1900677-2-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 1768981788135158500 Content-Type: text/plain; charset="utf-8" Renaming arm_virt_compat into arm_virt_compat_defaults makes more obvious that those compats apply to all machine types by default, if not overriden for specific ones. This also matches the terminology used for pc-q35. Suggested-by: Igor Mammedov Signed-off-by: Eric Auger Reviewed-by: Sebastian Ott Reviewed-by: Cornelia Huck --- hw/arm/virt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4badc1a7348..baa4e31aac1 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -94,20 +94,21 @@ #include "hw/cxl/cxl_host.h" #include "qemu/guest-random.h" =20 -static GlobalProperty arm_virt_compat[] =3D { +static GlobalProperty arm_virt_compat_defaults[] =3D { { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "48" }, }; -static const size_t arm_virt_compat_len =3D G_N_ELEMENTS(arm_virt_compat); +static const size_t arm_virt_compat_defaults_len =3D + G_N_ELEMENTS(arm_virt_compat_defaults); =20 /* * This cannot be called from the virt_machine_class_init() because * TYPE_VIRT_MACHINE is abstract and mc->compat_props g_ptr_array_new() * only is called on virt non abstract class init. */ -static void arm_virt_compat_set(MachineClass *mc) +static void arm_virt_compat_default_set(MachineClass *mc) { - compat_props_add(mc->compat_props, arm_virt_compat, - arm_virt_compat_len); + compat_props_add(mc->compat_props, arm_virt_compat_defaults, + arm_virt_compat_defaults_len); } =20 #define DEFINE_VIRT_MACHINE_IMPL(latest, ...) \ @@ -116,7 +117,7 @@ static void arm_virt_compat_set(MachineClass *mc) const void *data) \ { \ MachineClass *mc =3D MACHINE_CLASS(oc); \ - arm_virt_compat_set(mc); \ + arm_virt_compat_default_set(mc); \ MACHINE_VER_SYM(options, virt, __VA_ARGS__)(mc); \ mc->desc =3D "QEMU " MACHINE_VER_STR(__VA_ARGS__) " ARM Virtual Ma= chine"; \ MACHINE_VER_DEPRECATION(__VA_ARGS__); \ --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981813; cv=none; d=zohomail.com; s=zohoarc; b=awXlUKk/FU8tOSm2LBa95GFwhZL0M7gihFrCi7YZH5X9OmgRfVAWCAZwq6lZy3eQy5EETSENGyq6YY36AeB0CbpbEH+OoPlSAhc6eUfDyllQBlD2PgtS0a8duJAqwA/pGUhvxVbSVbC1qjUHeR0DBVsaSK1dR8Jd4kXUCNgQyR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981813; 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=5U9o39mXlG/0YzN+zMwCmUjQr1Ld8ySAYZypVBAbYUE=; b=cmdfLxTpdfr/sPr3APtRUG2XobXqTS8mrhwLKP7GVk9b+qimY3BvCoepF3pDfGpnNV6PN2OMp8WIIL7d5UCBRwZwefn2EtfTMrTLB0xdFxvFi/J4y7NU7oW0TkSpFrkgGBSEeBqGSKn+kSnoE/lCFpmNgIb6uP2l5vGhH+Szlwg= 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 1768981813950222.61211626119575; Tue, 20 Jan 2026 23:50:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSxf-0004WX-Hz; Wed, 21 Jan 2026 02:49:09 -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 1viSxa-0004Uh-1L for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:03 -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 1viSxX-0003PZ-Kj for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:01 -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-107-hevTO_HGMECKLNaWB1XQpQ-1; Wed, 21 Jan 2026 02:48:54 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E9321954B1B; Wed, 21 Jan 2026 07:48:52 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DF8BB19560A7; Wed, 21 Jan 2026 07:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981738; 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=5U9o39mXlG/0YzN+zMwCmUjQr1Ld8ySAYZypVBAbYUE=; b=Qk4cL56qjpwsTBQVe0FvyQa+m0dyRJtytCHtN6g/qwaUJLh4bh8tBwKDTG28/mu1DG77xn 7y6CxzuEwXKLt43yK9trtZbwODRNDfp2/aakhUw1op6eXdhLGOJv+j+BGnm3yP4Xw+qLQ1 zDJgwRbmgbsKmSDhqSE7TRSLwBx0zp0= X-MC-Unique: hevTO_HGMECKLNaWB1XQpQ-1 X-Mimecast-MFC-AGG-ID: hevTO_HGMECKLNaWB1XQpQ_1768981733 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 02/11] target/arm/machine: Improve traces on register mismatch during migration Date: Wed, 21 Jan 2026 08:46:39 +0100 Message-ID: <20260121074834.1900677-3-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, 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_H2=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 1768981814356158500 Content-Type: text/plain; charset="utf-8" Currently when the number of KVM registers exposed by the source is larger than the one exposed on the destination, the migration fails with: "failed to load cpu:cpreg_vmstate_array_len" This gives no information about which registers are causing the trouble. This patch reworks the target/arm/machine code so that it becomes able to handle an input stream with a larger set of registers than the destination and print useful information about which registers are causing the trouble. The migration outcome is unchanged: - unexpected registers still will fail the migration - missing ones are printed but will not fail the migration, as done today. The input stream can contain MAX_CPREG_VMSTATE_ANOMALIES(10) extra registers compared to what exists on the target. If there are more registers we will still hit the previous "load cpu:cpreg_vmstate_array_len" error. At most, MAX_CPREG_VMSTATE_ANOMALIES missing registers and MAX_CPREG_VMSTATE_ANOMALIES unexpected registers are printed. Example: qemu-system-aarch64: kvm_arm_cpu_post_load Missing register in input stream= : 0 0x6030000000160003 fw feat reg 3 qemu-system-aarch64: kvm_arm_cpu_post_load Unexpected register in input str= eam: 0 0x603000000013c103 op0:3 op1:0 crn:2 crm:0 op2:3 qemu-system-aarch64: kvm_arm_cpu_post_load Unexpected register in input str= eam: 1 0x603000000013c512 op0:3 op1:0 crn:10 crm:2 op2:2 qemu-system-aarch64: kvm_arm_cpu_post_load Unexpected register in input str= eam: 2 0x603000000013c513 op0:3 op1:0 crn:10 crm:2 op2:3 qemu-system-aarch64: error while loading state for instance 0x0 of device '= cpu' qemu-system-aarch64: load of migration failed: Operation not permitted With TCG there is no user friendly formatting of the faulting register indexes as with KVM. However the 2 added trace points help to identify the culprit indexes. Signed-off-by: Eric Auger Reviewed-by: Cornelia Huck --- v2 -> v3: - some extra typos (Connie) - collected Connie's R-b v1 -> v2: - fixed some type in the commit msg --- target/arm/cpu.h | 6 +++++ target/arm/kvm.c | 23 ++++++++++++++++ target/arm/machine.c | 58 ++++++++++++++++++++++++++++++++++++----- target/arm/trace-events | 7 +++++ 4 files changed, 88 insertions(+), 6 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 2f124d1b157..7f67c42cfd7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -939,6 +939,12 @@ struct ArchCPU { uint64_t *cpreg_vmstate_values; int32_t cpreg_vmstate_array_len; =20 + #define MAX_CPREG_VMSTATE_ANOMALIES 10 + uint64_t cpreg_vmstate_missing_indexes[MAX_CPREG_VMSTATE_ANOMALIES]; + int32_t cpreg_vmstate_missing_indexes_array_len; + uint64_t cpreg_vmstate_unexpected_indexes[MAX_CPREG_VMSTATE_ANOMALIES]; + int32_t cpreg_vmstate_unexpected_indexes_array_len; + DynamicGDBFeatureInfo dyn_sysreg_feature; DynamicGDBFeatureInfo dyn_svereg_feature; DynamicGDBFeatureInfo dyn_smereg_feature; diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 48f853fff80..c6f0d0fc4e1 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1024,6 +1024,29 @@ void kvm_arm_cpu_pre_save(ARMCPU *cpu) =20 bool kvm_arm_cpu_post_load(ARMCPU *cpu) { + int i; + + for (i =3D 0; i < cpu->cpreg_vmstate_missing_indexes_array_len; i++) { + gchar *name; + + name =3D kvm_print_register_name(cpu->cpreg_vmstate_missing_indexe= s[i]); + trace_kvm_arm_cpu_post_load_missing_reg(name); + g_free(name); + } + + for (i =3D 0; i < cpu->cpreg_vmstate_unexpected_indexes_array_len; i++= ) { + gchar *name; + + name =3D kvm_print_register_name(cpu->cpreg_vmstate_unexpected_ind= exes[i]); + error_report("%s Unexpected register in input stream: %i 0x%"PRIx6= 4" %s", + __func__, i, cpu->cpreg_vmstate_unexpected_indexes[i]= , name); + g_free(name); + } + /* Fail the migration if we detect unexpected registers */ + if (cpu->cpreg_vmstate_unexpected_indexes_array_len) { + return false; + } + if (!write_list_to_kvmstate(cpu, KVM_PUT_FULL_STATE)) { return false; } diff --git a/target/arm/machine.c b/target/arm/machine.c index 0befdb0b28a..f06a920aba1 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -10,6 +10,7 @@ #include "migration/vmstate.h" #include "target/arm/gtimer.h" #include "hw/arm/machines-qom.h" +#include "trace.h" =20 static bool vfp_needed(void *opaque) { @@ -990,7 +991,13 @@ static int cpu_pre_load(void *opaque) { ARMCPU *cpu =3D opaque; CPUARMState *env =3D &cpu->env; + int arraylen =3D cpu->cpreg_vmstate_array_len + MAX_CPREG_VMSTATE_ANOM= ALIES; =20 + 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_vmstate_array_len =3D arraylen; /* * In an inbound migration where on the source FPSCR/FPSR/FPCR are 0, * there will be no fpcr_fpsr subsection so we won't call vfp_set_fpcr= () @@ -1023,7 +1030,7 @@ static int cpu_post_load(void *opaque, int version_id) { ARMCPU *cpu =3D opaque; CPUARMState *env =3D &cpu->env; - int i, v; + int i =3D 0, j =3D 0, k =3D 0, v =3D 0; =20 /* * Handle migration compatibility from old QEMU which didn't @@ -1051,27 +1058,66 @@ static int cpu_post_load(void *opaque, int version_= id) * entries with the right slots in our own values array. */ =20 - for (i =3D 0, v =3D 0; i < cpu->cpreg_array_len - && v < cpu->cpreg_vmstate_array_len; i++) { + trace_cpu_post_load_len(cpu->cpreg_array_len, cpu->cpreg_vmstate_array= _len); + for (; i < cpu->cpreg_array_len && v < cpu->cpreg_vmstate_array_len;) { + trace_cpu_post_load(i, v , cpu->cpreg_indexes[i]); if (cpu->cpreg_vmstate_indexes[v] > cpu->cpreg_indexes[i]) { /* register in our list but not incoming : skip it */ + trace_cpu_post_load_missing(i, cpu->cpreg_indexes[i], v); + if (j < MAX_CPREG_VMSTATE_ANOMALIES) { + cpu->cpreg_vmstate_missing_indexes[j++] =3D cpu->cpreg_ind= exes[i]; + } + i++; continue; } if (cpu->cpreg_vmstate_indexes[v] < cpu->cpreg_indexes[i]) { - /* register in their list but not ours: fail migration */ - return -1; + /* register in their list but not ours: those will fail migrat= ion */ + trace_cpu_post_load_unexpected(v, cpu->cpreg_vmstate_indexes[v= ], i); + if (k < MAX_CPREG_VMSTATE_ANOMALIES) { + cpu->cpreg_vmstate_unexpected_indexes[k++] =3D + cpu->cpreg_vmstate_indexes[v]; + } + v++; + continue; } /* matching register, copy the value over */ cpu->cpreg_values[i] =3D cpu->cpreg_vmstate_values[v]; v++; + i++; } + /* + * 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++) { + if (j < MAX_CPREG_VMSTATE_ANOMALIES) { + trace_cpu_post_load_missing(i, cpu->cpreg_indexes[i], v); + cpu->cpreg_vmstate_missing_indexes[j++] =3D 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++) { + if (k < MAX_CPREG_VMSTATE_ANOMALIES) { + trace_cpu_post_load_unexpected(v, cpu->cpreg_vmstate_indexes[v= ], i); + cpu->cpreg_vmstate_unexpected_indexes[k++] =3D + cpu->cpreg_vmstate_indexes[v]; + } + } + + cpu->cpreg_vmstate_missing_indexes_array_len =3D j; + cpu->cpreg_vmstate_unexpected_indexes_array_len =3D k; =20 if (kvm_enabled()) { if (!kvm_arm_cpu_post_load(cpu)) { return -1; } } else { - if (!write_list_to_cpustate(cpu)) { + if (cpu->cpreg_vmstate_unexpected_indexes_array_len || + !write_list_to_cpustate(cpu)) { return -1; } } diff --git a/target/arm/trace-events b/target/arm/trace-events index 676d29fe516..0a5ed3e69d5 100644 --- a/target/arm/trace-events +++ b/target/arm/trace-events @@ -13,6 +13,7 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq= : timer %d irqstate %d" =20 # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova =3D 0x%"PRI= x64" is translated into 0x%"PRIx64 +kvm_arm_cpu_post_load_missing_reg(char *name) "Missing register in input s= tream: %s" =20 # cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64 @@ -26,3 +27,9 @@ 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_len(int cpreg_array_len, int cpreg_vmstate_array_len) "cpreg= _array_len=3D%d cpreg_vmstate_array_len=3D%d" +cpu_post_load(int i, int v, uint64_t regidx) "i=3D%d v=3D%d regidx=3D0x%"P= RIx64 +cpu_post_load_missing(int i, uint64_t regidx, int v) "missing register in = input stream: i=3D%d index=3D0x%"PRIx64" (v=3D%d)" +cpu_post_load_unexpected(int v, uint64_t regidx, int i) "unexpected regist= er in input stream: v=3D%d index=3D0x%"PRIx64" (i=3D%d)" --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981849; cv=none; d=zohomail.com; s=zohoarc; b=mijDPYPafYrhJbRAv1xDMt/RX5ZEEXSlBJ7ntFfJBPNExYpJtvZcZs3LgXCdtApt1RRB+Jkfmq005gP7X2H5zVmNuygPZIiMbXIxPS+13sZ3gOBn4LY6muNsfuhPKR5PwycbKrTib7KPLJG9XMwLC8TwuhTSG1vWrom825OjcQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981849; h=Content-Type: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=vocxVT7YCKzPjeXzWh1+L4bHuMZRKOWWYk7R3HWIrCY=; b=iaDCRS0lz0F41vR9TLtivDqFufE/NY9oeVZugS3hCm5FWYdtZMr/HiqN8GR8iLMFJ6y+ExK1npGXmIWTOnquSP3evpq+60hWhkYmWzr80mel19aGHqLGixethGN8mXDQlNrZFXa5+G6lvUs5Eq67iF0Jd8wPw68c//kedLAY68o= 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 1768981849584932.4600139623155; Tue, 20 Jan 2026 23:50:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSxl-0004Y5-BZ; Wed, 21 Jan 2026 02:49:13 -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 1viSxd-0004Vs-Nd for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:07 -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 1viSxb-0003Rn-NN for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:05 -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-425-SllJ6i5VMCudEK7qtis1qA-1; Wed, 21 Jan 2026 02:48:58 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 978B9195608E; Wed, 21 Jan 2026 07:48:57 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CBFA419560A2; Wed, 21 Jan 2026 07:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vocxVT7YCKzPjeXzWh1+L4bHuMZRKOWWYk7R3HWIrCY=; b=BnvITgn7IJIVjFEsN4ipYOIL6i0OsKH0cP5Ubo/kzpAnSyW9fmM9b5i74yGU0Rg+nxaZrE KcZ4cx60F4V2FG/pzQu+TUK2C/SIaA33lkTejrMn3GAeL5/3eFWajaQN9kJsZ3f73VAmyC UfzB2rAbvP9vOQPk0m4uPguF2N/wH9Y= X-MC-Unique: SllJ6i5VMCudEK7qtis1qA-1 X-Mimecast-MFC-AGG-ID: SllJ6i5VMCudEK7qtis1qA_1768981737 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 03/11] target/arm/cpu: Allow registers to be hidden Date: Wed, 21 Jan 2026 08:46:40 +0100 Message-ID: <20260121074834.1900677-4-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, 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_H2=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 1768981850401158500 More recent kernels sometimes expose new registers in an unconditionnal manner. This situation breaks backward migration as qemu notices there are more registers in the input stream than supported on the destination host. This leads to a "failed to load cpu:cpreg_vmstate_array_len" error. A good example is the introduction of KVM_REG_ARM_VENDOR_HYP_BMAP_2 pseudo FW register in v6.16 by commit C0000e58c74e (=E2=80=9CKVM: arm64: Introduce KVM_REG_ARM_VENDOR_HYP_BMAP_2=E2=80=9D). Trying to do backward migration from a host kernel that features the commit to a destination host that doesn't, fail with above error. Currently QEMU is not using that feature so ignoring this latter is not a problem. An easy way to fix the migration issue is to teach qemu we don't care about that register and we can simply ignore it when syncing its state during migration. This patch introduces an array of such hidden registers. Soon it will be settable through an array property. If hidden, the register is moved out of the array of cpreg which is built in kvm_arm_init_cpreg_list(). That way their state won't be synced. To extend that functionality to TCG, do the same in add_cpreg_to_list() and count_cpreg(). Signed-off-by: Eric Auger Reviewed-by: Sebastian Ott Reviewed-by: Cornelia Huck --- v2 -> v3: - use kvm_regidx v1 -> v2: - Move the property in a separate patch - improve the commit msg - change the trace point to just print info in kvm_arm_init_cpreg_list() - improve comment in cpu.h (Connie) target/arm/helper: Skip hidden registers In case a cpreg is hidden, skip it when initialing the cpreg list. Signed-off-by: Eric Auger Reviewed-by: Cornelia Huck --- target/arm/cpu.h | 20 ++++++++++++++++++++ target/arm/helper.c | 12 +++++++++++- target/arm/kvm.c | 12 +++++++++++- target/arm/trace-events | 2 ++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 7f67c42cfd7..b80f77d3743 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1045,6 +1045,15 @@ struct ArchCPU { /* KVM steal time */ OnOffAuto kvm_steal_time; =20 + /* + * Array of register indexes that need to be hidden to allow migration + * in certain cases, i.e. when a register is exposed in KVM or defined + * in TCG but not actually used in QEMU. Indexes are described in Linux + * Documentation/virt/kvm/api.rst for both KVM and TCG. + */ + uint64_t *hidden_regs; + uint32_t nr_hidden_regs; + /* Uniprocessor system with MP extensions */ bool mp_is_up; =20 @@ -1185,6 +1194,17 @@ struct ARMCPUClass { ResettablePhases parent_phases; }; =20 +static inline bool +arm_cpu_hidden_reg(ARMCPU *cpu, uint64_t regidx) +{ + for (int i =3D 0; i < cpu->nr_hidden_regs; i++) { + if (cpu->hidden_regs[i] =3D=3D regidx) { + return true; + } + } + return false; +} + /* Callback functions for the generic timer's timers. */ void arm_gt_ptimer_cb(void *opaque); void arm_gt_vtimer_cb(void *opaque); diff --git a/target/arm/helper.c b/target/arm/helper.c index dce648b4824..8217517150b 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -235,9 +235,13 @@ static void add_cpreg_to_list(gpointer key, gpointer v= alue, gpointer opaque) ARMCPU *cpu =3D opaque; uint32_t regidx =3D (uintptr_t)key; const ARMCPRegInfo *ri =3D value; + uint64_t kvm_regidx =3D cpreg_to_kvm_id(regidx); =20 + if (arm_cpu_hidden_reg(cpu, kvm_regidx)) { + return; + } if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) { - cpu->cpreg_indexes[cpu->cpreg_array_len] =3D cpreg_to_kvm_id(regid= x); + cpu->cpreg_indexes[cpu->cpreg_array_len] =3D kvm_regidx; /* The value array need not be initialized at this point */ cpu->cpreg_array_len++; } @@ -247,6 +251,12 @@ static void count_cpreg(gpointer key, gpointer value, = gpointer opaque) { ARMCPU *cpu =3D opaque; const ARMCPRegInfo *ri =3D value; + uint32_t regidx =3D (uintptr_t)key; + uint64_t kvm_regidx =3D cpreg_to_kvm_id(regidx); + + if (arm_cpu_hidden_reg(cpu, kvm_regidx)) { + return; + } =20 if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) { cpu->cpreg_array_len++; diff --git a/target/arm/kvm.c b/target/arm/kvm.c index c6f0d0fc4e1..7e0a3680748 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -789,7 +789,10 @@ static int kvm_arm_init_cpreg_list(ARMCPU *cpu) qsort(&rlp->reg, rlp->n, sizeof(rlp->reg[0]), compare_u64); =20 for (i =3D 0, arraylen =3D 0; i < rlp->n; i++) { - if (!kvm_arm_reg_syncs_via_cpreg_list(rlp->reg[i])) { + uint64_t regidx =3D rlp->reg[i]; + + if (!kvm_arm_reg_syncs_via_cpreg_list(regidx) || + arm_cpu_hidden_reg(cpu, regidx)) { continue; } switch (rlp->reg[i] & KVM_REG_SIZE_MASK) { @@ -805,6 +808,8 @@ static int kvm_arm_init_cpreg_list(ARMCPU *cpu) arraylen++; } =20 + trace_kvm_arm_init_cpreg_list_arraylen(arraylen); + 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, @@ -816,9 +821,14 @@ static int kvm_arm_init_cpreg_list(ARMCPU *cpu) =20 for (i =3D 0, arraylen =3D 0; i < rlp->n; i++) { uint64_t regidx =3D rlp->reg[i]; + if (!kvm_arm_reg_syncs_via_cpreg_list(regidx)) { continue; } + if (arm_cpu_hidden_reg(cpu, regidx)) { + trace_kvm_arm_init_cpreg_list_skip_hidden_reg(rlp->reg[i]); + continue; + } cpu->cpreg_indexes[arraylen] =3D regidx; arraylen++; } diff --git a/target/arm/trace-events b/target/arm/trace-events index 0a5ed3e69d5..20f4b4f2cd0 100644 --- a/target/arm/trace-events +++ b/target/arm/trace-events @@ -14,6 +14,8 @@ arm_gt_update_irq(int timer, int irqstate) "gt_update_irq= : timer %d irqstate %d" # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova =3D 0x%"PRI= x64" is translated into 0x%"PRIx64 kvm_arm_cpu_post_load_missing_reg(char *name) "Missing register in input s= tream: %s" +kvm_arm_init_cpreg_list_arraylen(uint32_t arraylen) "arraylen=3D%d" +kvm_arm_init_cpreg_list_skip_hidden_reg(uint64_t regidx) "hidden 0x%"PRIx6= 4" is skipped" =20 # cpu.c arm_cpu_reset(uint64_t mp_aff) "cpu %" PRIu64 --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981825; cv=none; d=zohomail.com; s=zohoarc; b=IDkTsIpcY7EJqtv/bcZto4TQYMsNG2mrWgvWRR/VR9Q53sc7wppdmhXNEXNX7H2O1SfuxdgChpevEgaPPSoReWCaj1ifr+UQfJJR6sLuuqjmvMAsPLVy+JKrIrTcY5JK9fZqA1wUtvmrbaZZ+9eb+OhxRkCqvGKSoh78s03lcdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981825; h=Content-Type: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=3McznrCgaoKWsPWweLxrxM06lAEHxg297odhSafpSxQ=; b=iv+da/r5Yc0j0cEkadJve6ge55GFX5XcLsUqCQTRYXhdRcnf6SLAECW4mBVX/Z5yr1s4solCwoGAWYzoMafbjDjjhTwfungdeqtUzGmCuriYx0vBCrvUKFDbgL0sVVCyKcRMy6bjvhZmhee+7hpHn4z9Yo1vyxe9Ld5znHjKH80= 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 1768981825897749.5682685473829; Tue, 20 Jan 2026 23:50:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSxm-0004YE-7P; Wed, 21 Jan 2026 02:49:14 -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 1viSxg-0004Wn-7H for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:09 -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 1viSxe-0003TN-9M for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:07 -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-3-IdlBgsniO1S_auHnle48LQ-1; Wed, 21 Jan 2026 02:49:04 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B93B11954B0C; Wed, 21 Jan 2026 07:49:02 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1D14D19560A7; Wed, 21 Jan 2026 07:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3McznrCgaoKWsPWweLxrxM06lAEHxg297odhSafpSxQ=; b=Taxdj5oWQ2UofbbPUcoiweognSHutIWy1gesUm1RiOycm5sHQdcrFZio/aL/g1B7PNtJ3F RKz5jScfjR2iXx1D6tr6UehWsBxOR3Rhoo8RE+dLEuQ4adqsf9uOeOQ03I/htQgyBv/pbb ngZ2gU3EWKSoEis6dB6XQNsvLr7fRG8= X-MC-Unique: IdlBgsniO1S_auHnle48LQ-1 X-Mimecast-MFC-AGG-ID: IdlBgsniO1S_auHnle48LQ_1768981742 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 04/11] target/arm/machine: Allow extra regs in the incoming stream Date: Wed, 21 Jan 2026 08:46:41 +0100 Message-ID: <20260121074834.1900677-5-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, 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_H2=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 1768981827801154100 Newer kernels may revoke exposure of KVM regs to userspace. This can happen when one notices that some registers were unconditionnally exposed whether they shall be conditionnally exposed for example. An example of such situation is: TCR2_EL1, PIRE0_EL1, PIR_EL1. Associated kernel commits were: 0fcb4eea5345=C2=A0 KVM: arm64: Hide TCR2_EL1 from userspace when disabled f= or guests a68cddbe47ef=C2=A0 KVM: arm64: Hide S1PIE registers from userspace when dis= abled for guests Those commits were actual fixes but the cons is that is breaks forward migration on some HW. Indeed when migrating from an old kernel that does not feature those commits to a more recent one, destination qemu detects there are more KVM regs in the input migration stream than exposed by the destination host and the migration fails with: "failed to load cpu:cpreg_vmstate_array_len" This patchs adds the capability to define an array of register indexes that may exist in the migration incoming stream but may be not exposed by KVM on the destination. We provision for extra space in cpreg_vmstate_* arrays during the preload phase to allow the state to be saved without overflow, in case the registers only are in the inbound data. On postload we make sure to ignore them when analyzing potential mismatch between registers. The actual cpreg array is never altered meaning those registers are never accessed nor saved. The array will be populated with a dedicated array property. Signed-off-by: Eric Auger Reviewed-by: Cornelia Huck --- v2 -> v3: - add a missing_as_expected trace point v1 -> v2: - get rid of the enforced/fake terminology - remove the useless array of fake regs. Only the number of missing regs is needed RFC -> v1: - improve comment in target/arm/cpu.h (Connie) --- target/arm/cpu.h | 22 ++++++++++++++++++++++ target/arm/machine.c | 30 +++++++++++++++++++++--------- target/arm/trace-events | 1 + 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index b80f77d3743..985d74b2ff6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1054,6 +1054,15 @@ struct ArchCPU { uint64_t *hidden_regs; uint32_t nr_hidden_regs; =20 + /* + * Registers that are likely to be part of the migration + * incoming stream but not exposed on destination. If + * their indexes are stored in this array, it is OK to + * ignore those registers in the inbound data. + */ + uint64_t *mig_safe_missing_regs; + uint32_t nr_mig_safe_missing_regs; + /* Uniprocessor system with MP extensions */ bool mp_is_up; =20 @@ -1205,6 +1214,19 @@ arm_cpu_hidden_reg(ARMCPU *cpu, uint64_t regidx) return false; } =20 + +static inline bool +arm_cpu_safe_missing_reg(ARMCPU *cpu, uint64_t regidx) +{ + for (int i =3D 0; i < cpu->nr_mig_safe_missing_regs; i++) { + if (regidx =3D=3D cpu->mig_safe_missing_regs[i]) { + return true; + } + } + return false; +} + + /* Callback functions for the generic timer's timers. */ void arm_gt_ptimer_cb(void *opaque); void arm_gt_vtimer_cb(void *opaque); diff --git a/target/arm/machine.c b/target/arm/machine.c index f06a920aba1..98851afc615 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -991,7 +991,8 @@ static int cpu_pre_load(void *opaque) { ARMCPU *cpu =3D opaque; CPUARMState *env =3D &cpu->env; - int arraylen =3D cpu->cpreg_vmstate_array_len + MAX_CPREG_VMSTATE_ANOM= ALIES; + int arraylen =3D cpu->cpreg_vmstate_array_len + + cpu->nr_mig_safe_missing_regs + MAX_CPREG_VMSTATE_ANOMA= LIES; =20 cpu->cpreg_vmstate_indexes =3D g_renew(uint64_t, cpu->cpreg_vmstate_in= dexes, arraylen); @@ -1058,6 +1059,10 @@ static int cpu_post_load(void *opaque, int version_i= d) * entries with the right slots in our own values array. */ =20 + /* + * at this point cpu->cpreg_vmstate_array_len was migrated with the + * actual length saved on source + */ trace_cpu_post_load_len(cpu->cpreg_array_len, cpu->cpreg_vmstate_array= _len); for (; i < cpu->cpreg_array_len && v < cpu->cpreg_vmstate_array_len;) { trace_cpu_post_load(i, v , cpu->cpreg_indexes[i]); @@ -1072,10 +1077,15 @@ static int cpu_post_load(void *opaque, int version_= id) } if (cpu->cpreg_vmstate_indexes[v] < cpu->cpreg_indexes[i]) { /* register in their list but not ours: those will fail migrat= ion */ - trace_cpu_post_load_unexpected(v, cpu->cpreg_vmstate_indexes[v= ], i); - if (k < MAX_CPREG_VMSTATE_ANOMALIES) { - cpu->cpreg_vmstate_unexpected_indexes[k++] =3D - cpu->cpreg_vmstate_indexes[v]; + if (!arm_cpu_safe_missing_reg(cpu, cpu->cpreg_vmstate_indexes[= v])) { + trace_cpu_post_load_unexpected(v, cpu->cpreg_vmstate_index= es[v], i); + if (k < MAX_CPREG_VMSTATE_ANOMALIES) { + cpu->cpreg_vmstate_unexpected_indexes[k++] =3D + cpu->cpreg_vmstate_indexes[v]; + } + } else { + trace_cpu_post_load_missing_as_expected(v, cpu->cpreg_vmst= ate_indexes[v], + i); } v++; continue; @@ -1101,10 +1111,12 @@ static int cpu_post_load(void *opaque, int version_= id) * still regs in the input stream, continue parsing the vmstate array */ for ( ; v < cpu->cpreg_vmstate_array_len; v++) { - if (k < MAX_CPREG_VMSTATE_ANOMALIES) { - trace_cpu_post_load_unexpected(v, cpu->cpreg_vmstate_indexes[v= ], i); - cpu->cpreg_vmstate_unexpected_indexes[k++] =3D - cpu->cpreg_vmstate_indexes[v]; + if (!arm_cpu_safe_missing_reg(cpu, cpu->cpreg_vmstate_indexes[v]))= { + if (k < MAX_CPREG_VMSTATE_ANOMALIES) { + trace_cpu_post_load_unexpected(v, cpu->cpreg_vmstate_index= es[v], i); + cpu->cpreg_vmstate_unexpected_indexes[k++] =3D + cpu->cpreg_vmstate_indexes[v]; + } } } =20 diff --git a/target/arm/trace-events b/target/arm/trace-events index 20f4b4f2cd0..2e22012c692 100644 --- a/target/arm/trace-events +++ b/target/arm/trace-events @@ -35,3 +35,4 @@ cpu_post_load_len(int cpreg_array_len, int cpreg_vmstate_= array_len) "cpreg_array cpu_post_load(int i, int v, uint64_t regidx) "i=3D%d v=3D%d regidx=3D0x%"P= RIx64 cpu_post_load_missing(int i, uint64_t regidx, int v) "missing register in = input stream: i=3D%d index=3D0x%"PRIx64" (v=3D%d)" cpu_post_load_unexpected(int v, uint64_t regidx, int i) "unexpected regist= er in input stream: v=3D%d index=3D0x%"PRIx64" (i=3D%d)" +cpu_post_load_missing_as_expected(int v, uint64_t regidx, int i) "register= missing as expected in input stream: v=3D%d index=3D0x%"PRIx64" (i=3D%d)" --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981790; cv=none; d=zohomail.com; s=zohoarc; b=I5p/F1Y0X2Ka4gZt1qJzDHIDKYp9eXAxEKixb7GIIBNVVA2CLrz7dP0QcK/z6CWjgEZK8QdUDeZdUEzi6wf2Zdklxu4e7zm3C/aweV+8DfTbYVwI0WiBpe4uswcRKEjmSjtdi+1NwDPr1hBwhzeSoVBewQRQuYhE6o8pJbYfFaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981790; 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=vSTY9AYqm8TFkjdqYG3z7M0nSb+Cdbm/Nbr6mi6s0+w=; b=Bpz0Z6RY7qMgaoNe7pDg6mCoDnBFs8M4QG03RaY/WQPbjMl5CVClv1qNSMAytsP0EEAEcrSakOuQzrNIGbS6+p0YIAHWkkcy7NzlZ5ANzq1ssIB91YqsHVVpmevXxb1kxaM1cH+fVxhl3Bugvqb2KLHb+HWjqYpTc9MDwNIAld4= 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 1768981790779195.90337003842717; Tue, 20 Jan 2026 23:49:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSy5-0004ri-OK; Wed, 21 Jan 2026 02:49:33 -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 1viSxp-0004d2-53 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:23 -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 1viSxl-0003UL-Tc for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:15 -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-567-tcVLkrVYOESXOLxsKjqGGA-1; Wed, 21 Jan 2026 02:49:09 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C486618005B2; Wed, 21 Jan 2026 07:49:07 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3F46F19560A7; Wed, 21 Jan 2026 07:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981752; 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=vSTY9AYqm8TFkjdqYG3z7M0nSb+Cdbm/Nbr6mi6s0+w=; b=g9tptkiGRk0Yp+c3ettOhoQNWskJAeuxC8ICWKRCsCmubx8Oy6+jWTJIOMW9XBz6S1/FNM FqMuFWXZiF5c502JwFCowvLfCvUqWbw1hNJrmoI2RY1m6I7EbeiAjhbTT99c31lZNBGOYA C2Vj6uK7k+Z9ivTRBr/WhjgrZTEMN6U= X-MC-Unique: tcVLkrVYOESXOLxsKjqGGA-1 X-Mimecast-MFC-AGG-ID: tcVLkrVYOESXOLxsKjqGGA_1768981747 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 05/11] kvm-all: Enforce hidden regs are never accessed Date: Wed, 21 Jan 2026 08:46:42 +0100 Message-ID: <20260121074834.1900677-6-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, 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_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1768981793073154100 Content-Type: text/plain; charset="utf-8" On ARM we want to be able to hide some registers which are exposed by KVM. To mitigate some migration failures that occur when a new register is exposed and does not exist on the destination, some registers are tagged "hidden" and their state won't be saved. As the state is not saved and they are expected not to be used, we want to enforce they aren't. So let's check this. The new CPUClass hide_reg() callback is optional and will be implemented on ARM in a subsequent patch. Signed-off-by: Eric Auger Reviewed-by: Cornelia Huck Reviewed-by: Sebastian Ott --- v3 -> v4: - don't use blacklist terminology (Connie & Sebastian) and reword the commit title to something clearer --- include/hw/core/cpu.h | 2 ++ accel/kvm/kvm-all.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index f6f17df9e64..3e30e1cbddf 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -142,6 +142,7 @@ struct SysemuCPUOps; * the caller will not g_free() it. * @disas_set_info: Setup architecture specific components of disassembly = info * @adjust_watchpoint_address: Perform a target-specific adjustment to an + * @hide_reg: Check if a register must be hidden (optional) * address before attempting to match it against watchpoints. * @deprecation_note: If this CPUClass is deprecated, this field provides * related information. @@ -167,6 +168,7 @@ struct CPUClass { int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr); + bool (*hide_reg)(CPUState *cpu, uint64_t regidex); =20 const char *gdb_core_xml_file; const char * (*gdb_arch_name)(CPUState *cpu); diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f85eb42d78b..bcbf45cee8d 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3784,9 +3784,15 @@ bool kvm_device_supported(int vmfd, uint64_t type) =20 int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source) { + CPUClass *cc =3D CPU_GET_CLASS(cs); struct kvm_one_reg reg; int r; =20 + if (cc->hide_reg && cc->hide_reg(cs, id)) { + error_report("%s reg 0x%"PRIx64" is hidden and shall never been ac= cessed", + __func__, id); + g_assert_not_reached(); + } reg.id =3D id; reg.addr =3D (uintptr_t) source; r =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); @@ -3798,9 +3804,15 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void = *source) =20 int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target) { + CPUClass *cc =3D CPU_GET_CLASS(cs); struct kvm_one_reg reg; int r; =20 + if (cc->hide_reg && cc->hide_reg(cs, id)) { + error_report("%s reg 0x%"PRIx64" is hidden and shall never been ac= cessed", + __func__, id); + g_assert_not_reached(); + } reg.id =3D id; reg.addr =3D (uintptr_t) target; r =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981848; cv=none; d=zohomail.com; s=zohoarc; b=Z8OllKtkkF8KsJfXFLckh0rld67Al8jT3X/Hp6yDCL8LKhNHYHBg22LJPNUKuemvqhpIGOWN8CLHpeKiJ+tdCkgEJBprKJlxAhf3hjJiD0ljcTeMQXqIgqOS5Vm3c/iJ7xNhf20T8hsJIfjqAJ7xYXN0bR9pAdLc4Mnq7abti5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981848; 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=EAWMwNW8rH4kExpUCAWgFUYWjRVqEtltBNmkIe4rFLs=; b=K+Qszl+zWeBUux4Gy5KF+wZknJezNBnBbYubFmWWxl3A/zzHVbtA/l+LPHbdB9TDgwRPB4zzvodTFbllJE4WKTQHPdfvdIANXV94/+WluY0mXUuLYimUQVBPgpFqOh58ZLjpmE8di6uH8RVpNggN+ng4qnqWc7C5W0gAOFUJOx8= 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 1768981848187143.7595024472048; Tue, 20 Jan 2026 23:50:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSy6-0004zM-LE; Wed, 21 Jan 2026 02:49:34 -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 1viSxs-0004ge-Tc for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:23 -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 1viSxr-0003Uo-Bt for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:20 -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-660-h1dBU5qHMoSVtVXNxOCE_A-1; Wed, 21 Jan 2026 02:49:13 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 975F819560A3; Wed, 21 Jan 2026 07:49:12 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4BBAE1955F67; Wed, 21 Jan 2026 07:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981758; 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=EAWMwNW8rH4kExpUCAWgFUYWjRVqEtltBNmkIe4rFLs=; b=VPVv6O8Sj2QIibTFaftvcPUMAsv8Xj5qvhDgopaUjZDGSxBjWvGpF4nXsWzVhBCXv0LRZ2 74fDfMsDhve0R6db644GOrNrNIO5LCoJqy7XoLOB+YJToNwcQm0GsWMC1sFRYkzu0CyMpg r8U8SSg/B+htGRHnN3OcPpRn4n/+AHs= X-MC-Unique: h1dBU5qHMoSVtVXNxOCE_A-1 X-Mimecast-MFC-AGG-ID: h1dBU5qHMoSVtVXNxOCE_A_1768981752 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 06/11] target/arm/cpu: Implement hide_reg callback() Date: Wed, 21 Jan 2026 08:46:43 +0100 Message-ID: <20260121074834.1900677-7-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 1768981850321158500 Content-Type: text/plain; charset="utf-8" Check if the register is hidden. Signed-off-by: Eric Auger Reviewed-by: Sebastian Ott Reviewed-by: Cornelia Huck --- target/arm/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 05fa3339b1a..04a73254420 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2370,6 +2370,11 @@ static const TCGCPUOps arm_tcg_ops =3D { }; #endif /* CONFIG_TCG */ =20 +static inline bool arm_cpu_hide_reg(CPUState *s, uint64_t regidx) +{ + return arm_cpu_hidden_reg(ARM_CPU(s), regidx); +} + static void arm_cpu_class_init(ObjectClass *oc, const void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); @@ -2398,6 +2403,7 @@ static void arm_cpu_class_init(ObjectClass *oc, const= void *data) cc->gdb_get_core_xml_file =3D arm_gdb_get_core_xml_file; cc->gdb_stop_before_watchpoint =3D true; cc->disas_set_info =3D arm_disas_set_info; + cc->hide_reg =3D arm_cpu_hide_reg; =20 #ifdef CONFIG_TCG cc->tcg_ops =3D &arm_tcg_ops; --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981838; cv=none; d=zohomail.com; s=zohoarc; b=cL5jtV6yIlXR66AyhCEFyKHFHUwmPx7BcGCYJehuVJpUn82JUwMDrZZyHG4xkz80xZJU7+JZ/YzR9zT8cFY01edsGgWd7MoFHnWctktjer6y8auv7EOEAXbVzetBJV4BmCIUOauyRhYSNZtAMmSgOei6z15pTUexj8JrsLNq7QE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981838; 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=AQaL8UtBtvuIOFM3Tqxqj0ZQlm2ruMixoH3w6eLaJ6g=; b=mAHbnLwCTiKDPfFDaCR/xEXA6E/cmrMyAWE+Yc0+CeUOyOZ6n1Zfc8dn2nQ5ya7FkXTjITmBfIWLDtOskAKWMbQbUBlYVXdauutw05PL3d0hswmkHU2vBhcRUlEP7XbkO3QXq5qPFhKzIVWSlvZ59GRbVqr65UrZzq1npd78vFU= 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 1768981838375843.718918762714; Tue, 20 Jan 2026 23:50:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSy8-00054M-Mu; Wed, 21 Jan 2026 02:49:36 -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 1viSxx-0004l4-N5 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:26 -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 1viSxv-0003WC-S6 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:25 -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-318-oSgqSVMKMcub4dIeCFDXAw-1; Wed, 21 Jan 2026 02:49:18 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7616D1800350; Wed, 21 Jan 2026 07:49:17 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1BC0D19560A2; Wed, 21 Jan 2026 07:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981763; 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=AQaL8UtBtvuIOFM3Tqxqj0ZQlm2ruMixoH3w6eLaJ6g=; b=ASmbM2hebwR9Nb/zk4+leyl+MnM/rmsz/4+ck9lopBi1dXGorsOEEV20/qewws0R4b9+SA j/is2wuY5UMROvMYWywISzm2oK5r8p9Rf+NY+xQd/+/m1mRFmmpUcqvYDxR2dlIT7IGd/m 6mnG1vv7tT6q2ZCxAGY58yFkB0K+5oo= X-MC-Unique: oSgqSVMKMcub4dIeCFDXAw-1 X-Mimecast-MFC-AGG-ID: oSgqSVMKMcub4dIeCFDXAw_1768981757 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 07/11] target/arm/cpu: Expose x-mig-hidden-regs and x-mig-safe-missing-regs properties Date: Wed, 21 Jan 2026 08:46:44 +0100 Message-ID: <20260121074834.1900677-8-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-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: 1768981840293158500 Content-Type: text/plain; charset="utf-8" Allows to set both array properties along with arm cpus. Their "x-" prefix reminds that those shall be used carefully for distro specific use cases to enable cross kernel migration. This will allow to define such compat machine props like: static GlobalProperty arm_virt_kernel_compat_10_1[] =3D { /* KVM_REG_ARM_VENDOR_HYP_BMAP_2 */ { TYPE_ARM_CPU, "x-mig-hidden-regs", "0x6030000000160003" }, { TYPE_ARM_CPU, "x-mig-safe-missing-regs", /* TCR_EL1, PIRE0_EL1, PIR_EL1 */ "0x603000000013c103, 0x603000000013c512, 0x603000000013c513" }, } The first one means KVM_REG_ARM_VENDOR_HYP_BMAP_2 shall always be hidden for machine types older than 10.1. The second one means that along with 10.1 machine type we may receive in the incoming migration stream, 3 registers that are unknown on destination. Obviously, using the reg index as defined in linux/Documentation/virt/kvm/api.rst is not user friendly. However These options are supposed to be used to enable specific, rare cases, and in general, by people trying to configure distribution defaults familiar with those specific cases. Signed-off-by: Eric Auger Reviewed-by: Cornelia Huck --- v3 -> v4: - typo and rewording in the commit description (Connie) --- target/arm/cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 04a73254420..88a22453795 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2249,6 +2249,11 @@ static const Property arm_cpu_properties[] =3D { DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, backcompat_cntfrq, false= ), DEFINE_PROP_BOOL("backcompat-pauth-default-use-qarma5", ARMCPU, backcompat_pauth_default_use_qarma5, false), + DEFINE_PROP_ARRAY("x-mig-hidden-regs", ARMCPU, + nr_hidden_regs, hidden_regs, qdev_prop_uint64, uint6= 4_t), + DEFINE_PROP_ARRAY("x-mig-safe-missing-regs", ARMCPU, + nr_mig_safe_missing_regs, mig_safe_missing_regs, + qdev_prop_uint64, uint64_t), }; =20 static const gchar *arm_gdb_arch_name(CPUState *cs) --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981834; cv=none; d=zohomail.com; s=zohoarc; b=bTKRkz/xBAKInnyq+5RjEfb2y/CG4XOgz4xAoaMgVsFIs2hyeMd7yoDCozMT4ROVLcgzyFdftB6jrEXbGPKB0WI5gd0RvQBU69mw2qfoNoVNeWl7aCQrZJHbQ05rd9fNbvGtl0/K+j6gXTSYqxxxoho/0kag/DLB1ombavIlYzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981834; 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=ZepwHYUKbovmWr9l3d1myrw/xdtLr/RrktyUMd39Ito=; b=fMsXtyjVXMOTnjtfbIVQWzX4ye1/w6SKPew3TEXQLZbFkpAEAOMdW4n+sof5S8P78BifiTrvrqj1r2L6AgwJRwZRUToINHu6O4TATq24/KaoCuvU8pGEIIIKxyhFRwnvBeWyPtjv+nhjSvdtnBRMvX5uSMQIWcJPtopvegEaWdE= 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 1768981834364160.51044987491855; Tue, 20 Jan 2026 23:50:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSy9-00058K-Ef; Wed, 21 Jan 2026 02:49:37 -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 1viSy3-0004tF-RO for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:33 -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 1viSy0-0003YH-GP for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:29 -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-53-g5v2UKRlPeyY16rAkPwH-A-1; Wed, 21 Jan 2026 02:49:23 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A343E1956063; Wed, 21 Jan 2026 07:49:22 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EECD819560A2; Wed, 21 Jan 2026 07:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981767; 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=ZepwHYUKbovmWr9l3d1myrw/xdtLr/RrktyUMd39Ito=; b=XVPMHXWSn1yeZgpgmc9WnkJIXj01UZL47v87JxiUhm0LJtHKoe/pZui9OXdYdLAAJXO00a y4E26JvG6jTn/IJ6ta/3qWH6Yo/ug9kI+uxBb+iRCsj1lERZhNzo6XlnCpkEjQooDnKrtF TB5Q60jF5MuFsxHqOdIFt8tSssu1SfA= X-MC-Unique: g5v2UKRlPeyY16rAkPwH-A-1 X-Mimecast-MFC-AGG-ID: g5v2UKRlPeyY16rAkPwH-A_1768981762 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 08/11] hw/arm/virt: Declare AArch32 DBGDTRTX as safe to ignore in incoming stream Date: Wed, 21 Jan 2026 08:46:45 +0100 Message-ID: <20260121074834.1900677-9-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, 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_H2=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 1768981836274158500 Content-Type: text/plain; charset="utf-8" With the new infrastructure in place it is now feasible to teach qemu that it is safe to ignore a sysreg in the incoming migration stream. So with the plan to revert commit 4f2b82f60431 ("target/arm: Reinstate bogus AArch32 DBGDTRTX register for migration compat") from qemu 11.0 onwards, let's add a compat in 10.2 machine options stating that this reg is safe to ignore. from 11.0 onwards we will not need that register anymore. Signed-off-by: Eric Auger --- v4 -> v5: - rebased on top of latest machine types (Connie) v3 -> v4: - add a comment related to DBGDTRTX (Connie) --- hw/arm/virt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index baa4e31aac1..03d5af18f26 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -100,6 +100,15 @@ static GlobalProperty arm_virt_compat_defaults[] =3D { static const size_t arm_virt_compat_defaults_len =3D G_N_ELEMENTS(arm_virt_compat_defaults); =20 +/* Register erronously exposed on 10.2 and earlier */ +#define DBGDTRTX 0x40200000200e0298 + +static GlobalProperty arm_virt_compat_10_2[] =3D { + { TYPE_ARM_CPU, "x-mig-safe-missing-regs", stringify(DBGDTRTX)}, +}; +static const size_t arm_virt_compat_10_2_len =3D + G_N_ELEMENTS(arm_virt_compat_10_2); + /* * This cannot be called from the virt_machine_class_init() because * TYPE_VIRT_MACHINE is abstract and mc->compat_props g_ptr_array_new() @@ -3552,6 +3561,7 @@ static void virt_machine_10_2_options(MachineClass *m= c) { virt_machine_11_0_options(mc); compat_props_add(mc->compat_props, hw_compat_10_2, hw_compat_10_2_len); + compat_props_add(mc->compat_props, arm_virt_compat_10_2, arm_virt_comp= at_10_2_len); } DEFINE_VIRT_MACHINE(10, 2) =20 --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981863; cv=none; d=zohomail.com; s=zohoarc; b=QkhZNPQyZh+llet3IBesl58M/BacUstS+QI++LLpzhROVcVtUjWWZZTD2n8vSubrRAlEabUmjRTBTJJpwy+lqMCoVyPTXm/uBw3o7kJEg8uG6Ix7Qf77FfH0T5pS2GNCCh9ycEO9M9lb+7Dr3oqjkcNh+0+Et/ni2JES2V5YTSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981863; 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=7/G678DDbXCgNGkigZdO6LX+E2evVF+SLkVbTYB/0S4=; b=KNAOeDvtsTsgg5NJds4HcrVnLndLCMp52Rtz7YjseJ/cObXk18kksJMR5KNsWXjl8LJ7M6yXB75wcD/hDL9oWVWBEW7iucEbjLX3R1sJwjysWHIA2UGx/KYJFn0JHRocm/IyH8sztYIHldCWoCeDEG7gQcWgS13mgP0Ej8RUilg= 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 1768981862994585.458075824624; Tue, 20 Jan 2026 23:51:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSyA-0005Ap-3S; Wed, 21 Jan 2026 02:49:38 -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 1viSy7-00051e-04 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:35 -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 1viSy5-0003aW-D4 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:34 -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-679-oCVgkLnTPZ6KFfHrCAGBiA-1; Wed, 21 Jan 2026 02:49:28 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 48D4718005B2; Wed, 21 Jan 2026 07:49:27 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 116FB19560A2; Wed, 21 Jan 2026 07:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981772; 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=7/G678DDbXCgNGkigZdO6LX+E2evVF+SLkVbTYB/0S4=; b=PhcX0ncUAdeO8Naw0V+zyZNnCGBJYFP3EAYqoLuEQqwPU2t51/LcicxK65LgvXKtDr5tF7 ti5jBtppc4Q2JH822DHZfZsK6dOIxug6Boxu9KAdI7iSHJe8p5ORO1CRcUBByN6Lm4SgiH 58q74YgsOS2GJZ56R4yzfOEiIptoVQA= X-MC-Unique: oCVgkLnTPZ6KFfHrCAGBiA-1 X-Mimecast-MFC-AGG-ID: oCVgkLnTPZ6KFfHrCAGBiA_1768981767 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 09/11] Revert "target/arm: Reinstate bogus AArch32 DBGDTRTX register for migration compat" Date: Wed, 21 Jan 2026 08:46:46 +0100 Message-ID: <20260121074834.1900677-10-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, 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_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1768981866042154100 Content-Type: text/plain; charset="utf-8" This reverts commit 4f2b82f60431e4792ecfd86a4d6b824248ee4c21. We don't need that commit anymore as the AArch32 DBGDTRTX register is declared to be safe to ignore in the incoming migration stream using a compat in arm virt machine. Signed-off-by: Eric Auger --- target/arm/debug_helper.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c index 579516e1541..aee06d4d426 100644 --- a/target/arm/debug_helper.c +++ b/target/arm/debug_helper.c @@ -940,13 +940,6 @@ static void dbgclaimclr_write(CPUARMState *env, const = ARMCPRegInfo *ri, env->cp15.dbgclaim &=3D ~(value & 0xFF); } =20 -static CPAccessResult access_bogus(CPUARMState *env, const ARMCPRegInfo *r= i, - bool isread) -{ - /* Always UNDEF, as if this cpreg didn't exist */ - return CP_ACCESS_UNDEFINED; -} - static const ARMCPRegInfo debug_cp_reginfo[] =3D { /* * DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped @@ -1009,28 +1002,6 @@ static const ARMCPRegInfo debug_cp_reginfo[] =3D { .opc0 =3D 2, .opc1 =3D 3, .crn =3D 0, .crm =3D 4, .opc2 =3D 0, .access =3D PL0_RW, .accessfn =3D access_tdcc, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, - /* - * This is not a real AArch32 register. We used to incorrectly expose - * this due to a QEMU bug; to avoid breaking migration compatibility we - * need to continue to provide it so that we don't fail the inbound - * migration when it tells us about a sysreg that we don't have. - * We set an always-fails .accessfn, which means that the guest doesn't - * actually see this register (it will always UNDEF, identically to if - * there were no cpreg definition for it other than that we won't print - * a LOG_UNIMP message about it), and we set the ARM_CP_NO_GDB flag so= the - * gdbstub won't see it either. - * (We can't just set .access =3D 0, because add_cpreg_to_hashtable() - * helpfully ignores cpregs which aren't accessible to the highest - * implemented EL.) - * - * TODO: implement a system for being able to describe "this register - * can be ignored if it appears in the inbound stream"; then we can - * remove this temporary hack. - */ - { .name =3D "BOGUS_DBGDTR_EL0", .state =3D ARM_CP_STATE_AA32, - .cp =3D 14, .opc1 =3D 3, .crn =3D 0, .crm =3D 5, .opc2 =3D 0, - .access =3D PL0_RW, .accessfn =3D access_bogus, - .type =3D ARM_CP_CONST | ARM_CP_NO_GDB, .resetvalue =3D 0 }, /* * OSECCR_EL1 provides a mechanism for an operating system * to access the contents of EDECCR. EDECCR is not implemented though, --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981803; cv=none; d=zohomail.com; s=zohoarc; b=cI7l6w+Z4iNTvOCGtlIB7Zb4eShZ2LlGIS6DXNcZrS3Ux6bUvozPhJubYfRsESZMGkCvNBZw54f+YbF3AAd9HXJWg6APTpt3qgnV+wfqob4+f+RvgVpnsE7uvPVcMP4h/R+KgZuIkqzHQz7h0SE2P1mU/ZET7Bk7jnVJNGfpuOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981803; 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=s3kRSDRJvH+FhJiR2WPNf+o62ZhtVFuYnAQtQruqenE=; b=TeWt0LpqEQQNMv3EAT5AiuFaK8v5VmkpfuxyScXxELKAHNagDTF6+Vh2kT//68MGqXGOZ1g/MwblEkssRA9ZoFN32sT9ucPSJnsIfClGI/a7CCMmbjBgjc/TrRb6RL0VSg6SJicwFHbuTdwFyMldMysikRYQ97w/08toGoXr7aI= 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 176898180375942.85672721877222; Tue, 20 Jan 2026 23:50:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSyC-0005IN-U0; Wed, 21 Jan 2026 02:49:40 -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 1viSyB-0005Fm-A5 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:39 -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 1viSy9-0003bs-H5 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:39 -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-614-21uvYPTpOdaybUdRsOPo8g-1; Wed, 21 Jan 2026 02:49:33 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA58B1800378; Wed, 21 Jan 2026 07:49:31 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C4B5819560A7; Wed, 21 Jan 2026 07:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981776; 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=s3kRSDRJvH+FhJiR2WPNf+o62ZhtVFuYnAQtQruqenE=; b=ZTIatHRbiCdCWfa5vS7jssNkDSICIizIQGzlzjXMcw5LYj83WggcES61iX/MVC2/sFSjq0 vy6+sjQmbbVOd885LEIa5Rz+ecaXxqrgUMn3bK5nACb6eOuwr1UANvbqFSl0vHf6nvvTRJ 4ASMmJhUf21SN8WP/DJeEtydo+egqZ8= X-MC-Unique: 21uvYPTpOdaybUdRsOPo8g-1 X-Mimecast-MFC-AGG-ID: 21uvYPTpOdaybUdRsOPo8g_1768981772 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 10/11] hw/arm/virt: Introduce framework to aggregate hidden-regs and safe-missing-regs Date: Wed, 21 Jan 2026 08:46:47 +0100 Message-ID: <20260121074834.1900677-11-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-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: 1768981806529158500 Content-Type: text/plain; charset="utf-8" Currently if a virt_machine__options() sets a TYPE_ARM_CPU x-mig-hidden-regs or x-mig-safe-missing-regs array property, another one cannot overwrite it or extend it. We end up with a core dump: qemu-system-aarch64: can't apply global arm-cpu.x-mig-safe-missing-regs=3D0= x603000000013c103, 0x603000000013c512, 0x603000000013c513: array size prope= rty x-mig-safe-missing-regs may not be set more than once Aborted (core dumped) In practice we would like an easy way to register regs that belong to either of those categories and allow aggregation of those. We introduce arm_virt_compat_register_safe_missing_reg() and arm_virt_compat_register_hidden_reg() which populate GLists of int64_t. After all virt_machine__options have been called and have registered their regs, the GList are converted into the associated array property value and the GlobalProperties are set. Signed-off-by: Eric Auger Reviewed-by: Sebastian Ott --- include/hw/arm/virt.h | 23 ++++++++++++++ hw/arm/virt.c | 70 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 5907d41dbb2..d83e6f00068 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -41,6 +41,7 @@ #include "system/kvm.h" #include "hw/intc/arm_gicv3_common.h" #include "qom/object.h" +#include "qobject/qlist.h" =20 #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -131,6 +132,8 @@ struct VirtMachineClass { bool no_tcg_lpa2; bool no_ns_el2_virt_timer_irq; bool no_nested_smmu; + QList *safe_missing_regs; + QList *hidden_regs; }; =20 struct VirtMachineState { @@ -216,4 +219,24 @@ static inline int virt_gicv3_redist_region_count(VirtM= achineState *vms) vms->highmem_redists) ? 2 : 1; } =20 +static inline void arm_virt_class_init(MachineClass *mc) +{ + VirtMachineClass *vmc =3D VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + + vmc->safe_missing_regs =3D qlist_new(); + vmc->hidden_regs =3D qlist_new(); +} + +static inline void +arm_virt_compat_register_safe_missing_reg(VirtMachineClass *vmc, int64_t r= egidx) +{ + qlist_append_int(vmc->safe_missing_regs, regidx); +} + +static inline void +arm_virt_compat_register_hidden_reg(VirtMachineClass *vmc, int64_t regidx) +{ + qlist_append_int(vmc->hidden_regs, regidx); +} + #endif /* QEMU_ARM_VIRT_H */ diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 03d5af18f26..6c57e436053 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -93,6 +93,7 @@ #include "hw/cxl/cxl.h" #include "hw/cxl/cxl_host.h" #include "qemu/guest-random.h" +#include "qobject/qnum.h" =20 static GlobalProperty arm_virt_compat_defaults[] =3D { { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "48" }, @@ -100,15 +101,18 @@ static GlobalProperty arm_virt_compat_defaults[] =3D { static const size_t arm_virt_compat_defaults_len =3D G_N_ELEMENTS(arm_virt_compat_defaults); =20 +/* + * Array made of x-mig-safe-missing-regs and x-mig-hidden-regs global + * properties. It is populated by arm_virt_aggregate_x_mig_props() that + * aggregates registrations respectively made with: + * - arm_virt_compat_register_safe_missing_reg() and + * - arm_virt_compat_register_hidden_reg() + */ +static GlobalProperty aggregated_x_mig_array_props[2]; + /* Register erronously exposed on 10.2 and earlier */ #define DBGDTRTX 0x40200000200e0298 =20 -static GlobalProperty arm_virt_compat_10_2[] =3D { - { TYPE_ARM_CPU, "x-mig-safe-missing-regs", stringify(DBGDTRTX)}, -}; -static const size_t arm_virt_compat_10_2_len =3D - G_N_ELEMENTS(arm_virt_compat_10_2); - /* * This cannot be called from the virt_machine_class_init() because * TYPE_VIRT_MACHINE is abstract and mc->compat_props g_ptr_array_new() @@ -120,14 +124,64 @@ static void arm_virt_compat_default_set(MachineClass = *mc) arm_virt_compat_defaults_len); } =20 +static char *get_prop_value_from_reg_qlist(QList *l) +{ + size_t size =3D qlist_size(l); + GString *s =3D g_string_new(""); + QListEntry *item; + int i =3D 0; + QNum *qi; + + if (!size) { + return NULL; + } + QLIST_FOREACH_ENTRY(l, item) { + qi =3D qobject_to(QNum, qlist_entry_obj(item)); + int64_t regidx; + + qnum_get_try_int(qi, ®idx); + if (i++ > 0) { + g_string_append(s, ", "); + } + g_string_append_printf(s, "%" G_GINT64_FORMAT, regidx); + } + return g_string_free(s, false); +} + +static void arm_virt_aggregate_x_mig_props(MachineClass *mc) +{ + VirtMachineClass *vmc =3D VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + const char *safe_missing_regs_prop_value =3D + get_prop_value_from_reg_qlist(vmc->safe_missing_regs); + const char *hidden_regs_prop_value =3D + get_prop_value_from_reg_qlist(vmc->hidden_regs); + int i =3D 0; + + if (safe_missing_regs_prop_value) { + aggregated_x_mig_array_props[i].driver =3D TYPE_ARM_CPU; + aggregated_x_mig_array_props[i].property =3D "x-mig-safe-missing-r= egs"; + aggregated_x_mig_array_props[i++].value =3D safe_missing_regs_prop= _value; + } + + if (hidden_regs_prop_value) { + aggregated_x_mig_array_props[i].driver =3D TYPE_ARM_CPU; + aggregated_x_mig_array_props[i].property =3D "x-mig-hidden-regs"; + aggregated_x_mig_array_props[i++].value =3D hidden_regs_prop_value; + } + + compat_props_add(mc->compat_props, aggregated_x_mig_array_props, i); +} + #define DEFINE_VIRT_MACHINE_IMPL(latest, ...) \ static void MACHINE_VER_SYM(class_init, virt, __VA_ARGS__)( \ ObjectClass *oc, \ const void *data) \ { \ MachineClass *mc =3D MACHINE_CLASS(oc); \ + arm_virt_class_init(mc); \ arm_virt_compat_default_set(mc); \ MACHINE_VER_SYM(options, virt, __VA_ARGS__)(mc); \ + arm_virt_aggregate_x_mig_props(mc); \ mc->desc =3D "QEMU " MACHINE_VER_STR(__VA_ARGS__) " ARM Virtual Ma= chine"; \ MACHINE_VER_DEPRECATION(__VA_ARGS__); \ if (latest) { \ @@ -3559,9 +3613,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(11, 0) =20 static void virt_machine_10_2_options(MachineClass *mc) { + VirtMachineClass *vmc =3D VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_11_0_options(mc); compat_props_add(mc->compat_props, hw_compat_10_2, hw_compat_10_2_len); - compat_props_add(mc->compat_props, arm_virt_compat_10_2, arm_virt_comp= at_10_2_len); + arm_virt_compat_register_safe_missing_reg(vmc, DBGDTRTX); } DEFINE_VIRT_MACHINE(10, 2) =20 --=20 2.52.0 From nobody Sat Feb 7 08:53:21 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=1768981813; cv=none; d=zohomail.com; s=zohoarc; b=l1aDKoD46La1bPEY4jzdx36025rmLCt1L5kXwNSghGe+1wj2kg1uvOofvgyFRCLQeqp6j0LDL94EXLeZ1+GdlertnX6l3DayE1Yw1uvFALs0cwScsZa+UrNmCee3fUSXPqSwSa4Cng2jV9dIixs90pcImQW8OXz+FPaWZWbcCaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768981813; 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=bTRGkgzqKCLgNP35OC3/rHfsgQ/PrP40JekVQ+Kj3I8=; b=nyrZQuiPZ4fCFaW1FwLdM/ptHGiA1RHfIizyyqh2PARdcnv5sF9JwtEAxeKL5UDMYGdS+LMVwpaJlG4635QWPGX32/seJ4rD45TuHMYU2slTGttsAhhn2iKdO1PBqOqJicyaRa/edgfdblaSBZJvSngxR8aka0hw+l1H2JBCMms= 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 1768981813155755.9046688387235; Tue, 20 Jan 2026 23:50:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viSyG-0005P6-FT; Wed, 21 Jan 2026 02:49:44 -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 1viSyF-0005Oe-K0 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:43 -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 1viSyE-0003dZ-6h for qemu-devel@nongnu.org; Wed, 21 Jan 2026 02:49:43 -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-266-GipxofKyN4uKwuSrESSTfA-1; Wed, 21 Jan 2026 02:49:38 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E16D31956058; Wed, 21 Jan 2026 07:49:36 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.44.32.15]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7109E19560A2; Wed, 21 Jan 2026 07:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768981781; 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=bTRGkgzqKCLgNP35OC3/rHfsgQ/PrP40JekVQ+Kj3I8=; b=Bvqlhqx0w3RFr4KHm+iGKxY16N/3TS75ywnHaRblFpiO+NqRnSANaerx8jjVhwvnHGPXCu WC81mtX9/z6Qq6Ioz1vaz36eXFz+QjPskUgv+hVJG9u0FtodUSMMc4RTkxL76SLm/9Kjp9 GM/1jwcQpRxaRA9++y0UZZ0kLoF8eoA= X-MC-Unique: GipxofKyN4uKwuSrESSTfA-1 X-Mimecast-MFC-AGG-ID: GipxofKyN4uKwuSrESSTfA_1768981777 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, maz@kernel.org, oliver.upton@linux.dev, sebott@redhat.com, gshan@redhat.com, ddutile@redhat.com, peterx@redhat.com, philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v5 11/11] hw/arm/virt: [DO NOT UPSTREAM] Enforce compatibility with older kernels Date: Wed, 21 Jan 2026 08:46:48 +0100 Message-ID: <20260121074834.1900677-12-eric.auger@redhat.com> In-Reply-To: <20260121074834.1900677-1-eric.auger@redhat.com> References: <20260121074834.1900677-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 (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: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.087, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 1768981815424154100 Content-Type: text/plain; charset="utf-8" This is an example on how to use the new CPU options. This catters to distributions who want machines to be migratable (forward and backward) accross different host kernel versions in case KVM registers exposed to qemu vary accross kernels. This patch is not meant to be upstreamed as it is really kernel dependent. The goal is to illustrate how this would be used. In this example, For 10_1 machines types and older we apply the following host kernel related compats: 1) Make sure the KVM_REG_ARM_VENDOR_HYP_BMAP_2 exposed from v6.15 onwards is ignored/hidden. 2) Make sure TCR_EL1, PIRE0_EL1, PIR_EL1 are always seen by qemu although not exposed by KVM. They were unconditionnally exposed before v6.13 while from v6.13 they are only exposed if supported by the guest. This will allow 10_1 machines types and older machines to migrate forward and backward from old downstream kernels that do not feature those changes to newer kernels (>=3D v6.15). Signed-off-by: Eric Auger --- hw/arm/virt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6c57e436053..860bc8a787a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3623,9 +3623,16 @@ DEFINE_VIRT_MACHINE(10, 2) =20 static void virt_machine_10_1_options(MachineClass *mc) { + VirtMachineClass *vmc =3D VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_10_2_options(mc); mc->smbios_memory_device_size =3D 2047 * TiB; compat_props_add(mc->compat_props, hw_compat_10_1, hw_compat_10_1_len); + /* KVM_REG_ARM_VENDOR_HYP_BMAP_2 */ + arm_virt_compat_register_hidden_reg(vmc, 0x6030000000160003); + arm_virt_compat_register_safe_missing_reg(vmc, 0x603000000013c103 /* T= CR_EL1 */); + arm_virt_compat_register_safe_missing_reg(vmc, 0x603000000013c512 /* P= IRE0_EL1 */); + arm_virt_compat_register_safe_missing_reg(vmc, 0x603000000013c513 /* P= IR_EL1 */); } DEFINE_VIRT_MACHINE(10, 1) =20 --=20 2.52.0