@samitouri / QOSamiQemu / commits / 8833ff95ea

hw/char: imx_serial: add missing migration state

The imx_serial vmstate is missing the ucr2 field. This register includes important state like the transmit enable and receive enable bits, so it's likely that after a migration the UART will be in a completely broken state. This bug has been present ever since the UART code was first added to QEMU. Add ucr2 from imx_serial to vmstate, and increment the version_id. This is a migration compatibility break, but this UART is only used in the various imx-based boards, where we are OK with compat breaks. Migrating on sabrelite can reproduce this issue: 1. Prepare the U-Boot required for sabrelite. (according to sabrelite.rst) 2. Compile qemu $ mkdir build && cd build && ../configure --target-list="arm-softmmu" && make -j4 3. Start sabrelite and prepare for migration $ ./build/qemu-system-arm -M sabrelite \ -smp 1 -m 1G -display none -serial null -serial mon:stdio \ -kernel ~/u-boot 4. Enter qemu monitor after uboot. (ctrl + a + c) (qemu) stop (qemu) xp /4wx 0x021e8084 021e8084: 0x00004027 0x00000784 0x00008000 0x00000a01 (qemu) migrate -d file:vmstate (qemu) q Load the migrated vmstate, before repairing: $ ./build/qemu-system-arm -M sabrelite \ -smp 1 -m 1G -display none -serial null -serial mon:stdio \ -kernel ~/u-boot -incoming file:vmstate (ctrl + a + c) QEMU 11.0.50 monitor - type 'help' for more information (qemu) xp /4wx 0x021e8084 021e8084: 0x00000004 0x00000784 0x00008000 0x00000a01 (qemu) q It can be found that the data for address 0x021e8084 (register of usr2 in imx_serial of sabrelite) is not the data before the migration. After being repaired: $ ./build/qemu-system-arm -M sabrelite \ -smp 1 -m 1G -display none -serial null -serial mon:stdio \ -kernel ~/u-boot -incoming file:vmstate (ctrl + a + c) QEMU 11.0.50 monitor - type 'help' for more information (qemu) xp /4wx 0x021e8084 021e8084: 0x00004027 0x00000784 0x00008000 0x00000a01 Cc: qemu-stable@nongnu.org Fixes: 40b6f91151 ("i.MX: UART support") Signed-off-by: Tao Ding <dingtao0430@163.com> Message-id: 20260715131819.14827-2-dingtao0430@163.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Tao Ding committed Jul 20, 2026 at 19:05 UTC 8833ff95eaf347f79b61d857cc5eed32ec6d2a0b
1 file changed +3 -2
hw/char/imx_serial.c
+3 -2
@@ -43,14 +43,15 @@
43
44 static const VMStateDescription vmstate_imx_serial = {
45 .name = TYPE_IMX_SERIAL,
46 - .version_id = 3,
47 - .minimum_version_id = 3,
46 + .version_id = 4,
47 + .minimum_version_id = 4,
48 .fields = (const VMStateField[]) {
49 VMSTATE_FIFO32(rx_fifo, IMXSerialState),
50 VMSTATE_TIMER(ageing_timer, IMXSerialState),
51 VMSTATE_UINT32(usr1, IMXSerialState),
52 VMSTATE_UINT32(usr2, IMXSerialState),
53 VMSTATE_UINT32(ucr1, IMXSerialState),
54 + VMSTATE_UINT32(ucr2, IMXSerialState),
55 VMSTATE_UINT32(uts1, IMXSerialState),
56 VMSTATE_UINT32(onems, IMXSerialState),
57 VMSTATE_UINT32(ufcr, IMXSerialState),