@samitouri / QOSamiQemu / commits / 234b3eaddd

target/arm/helper: Define cpreg migration tolerance for DGBDTR_EL0

We want to remove AArch32 DBGDTRTX which was erroneously exposed. This was attempted by 655659a74a36b ("target/arm: Correct encoding of Debug Communications Channel registers") but it was discovered that the removal of this debug register broke forward migration on TCG. Now we have the cpreg migration tolerance infrastructure, we can declare one for the DBGDTRTX. This allow to revert the reinstate patch. Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Sebastian Ott <sebott@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20260420140552.104369-7-eric.auger@redhat.com [PMM: revised comment, included note about when we can drop the workaround] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Eric Auger committed Apr 20, 2026 at 16:03 UTC 234b3eaddd4ff08b8b62d563742e37f7bb6486bd
1 file changed +23
target/arm/helper.c
+23
@@ -6349,9 +6349,32 @@ void register_cp_regs_for_features(ARMCPU *cpu)
6349 .fgt = FGT_CLIDR_EL1,
6350 .resetvalue = GET_IDREG(isar, CLIDR)
6351 };
6352 + uint64_t dbgtr_el0_kvmidx =
6353 + cpreg_to_kvm_id(ENCODE_CP_REG(14, 0, 1, 0, 5, 3, 0));
6354 +
6355 define_one_arm_cp_reg(cpu, &clidr);
6356 define_arm_cp_regs(cpu, v7_cp_reginfo);
6357 define_debug_regs(cpu);
6358 + /*
6359 + * We used to incorrectly expose a non-existent AArch32 "DBGDTRTX"
6360 + * register with this encoding. This has been fixed by commit
6361 + * 655659a74a36 ("target/arm: Correct encoding of Debug
6362 + * Communications Channel registers") by the introduction of correct
6363 + * separate cpreg definitions for AA64 and AA32 versions. However,
6364 + * the old cpreg definition couldn't be removed without breaking
6365 + * migration, so commit 4f2b82f604 reinstated the bogus encoding
6366 + * for migration data only.
6367 + *
6368 + * Now that we have migration tolerance infrastructure, we can use
6369 + * this to allow forward migration from the buggy QEMU versions,
6370 + * accepting and ignoring the bogus register if it is in the
6371 + * source data. QEMU 11.0 was the last version that sent the
6372 + * bogus encoding, so this workaround can be removed at the point
6373 + * where we no longer care about migration from that version
6374 + * (i.e. when we remove the "virt-11.0" machine type).
6375 + */
6376 + arm_register_cpreg_mig_tolerance(cpu, dbgtr_el0_kvmidx,
6377 + 0, 0, ToleranceNotOnBothEnds);
6378 } else {
6379 define_arm_cp_regs(cpu, not_v7_cp_reginfo);
6380 }