Skip to contentSkip to conversation

imx_serial: add missing migration state

PATCH In review Tao Ding 3 participants 5 messages Jul 15 – Jul 22 Arm i.MX and Layerscape

lore
Share & tools
lore

Tao Ding

author
#0 lore raw

cover imx_serial: add missing migration state

Hi all.
The imx_serial is missing a migration status, resulting in no display on the terminal after migration. This patch fixes this issue.

Thanks.

Tao Ding (1):
hw/char: imx_serial: add missing migration state

 hw/char/imx_serial.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

base-commit: eca2c16212ef9dcb0871de39bb9d1c2efebe76be

Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 1/1 hw/char: imx_serial: add missing migration state

Add ucr2 from imx_serial to vmstate, and increment the version_id.

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
---
 hw/char/imx_serial.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/char/imx_serial.c +3 -2
index 080b7f6331..fb41ee2ac5 100644
@@ -43,14 +43,15 @@
 
 static const VMStateDescription vmstate_imx_serial = {
     .name = TYPE_IMX_SERIAL,
-    .version_id = 3,
-    .minimum_version_id = 3,
+    .version_id = 4,
+    .minimum_version_id = 4,
     .fields = (const VMStateField[]) {
         VMSTATE_FIFO32(rx_fifo, IMXSerialState),
         VMSTATE_TIMER(ageing_timer, IMXSerialState),
         VMSTATE_UINT32(usr1, IMXSerialState),
         VMSTATE_UINT32(usr2, IMXSerialState),
         VMSTATE_UINT32(ucr1, IMXSerialState),
+        VMSTATE_UINT32(ucr2, IMXSerialState),
         VMSTATE_UINT32(uts1, IMXSerialState),
         VMSTATE_UINT32(onems, IMXSerialState),
         VMSTATE_UINT32(ufcr, IMXSerialState),
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/1] hw/char: imx_serial: add missing migration state

Quoted 41 lines · Tao Ding

Add ucr2 from imx_serial to vmstate, and increment the version_id.

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
Quoted 1 line

Somehow, this grow Cc: qemu-stable@ in the final version which was applied as v11.1.0-rc0-68-g8833ff95eaf. I don't think this is a good candidate for the stable series, since this fix changes the migration stream format, which is very difficult to do in the stable series.

FWIW.

Thanks,

/mjt

Quoted 25 lines
  hw/char/imx_serial.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
hw/char/imx_serial.c +3 -2
index 080b7f6331..fb41ee2ac5 100644
@@ -43,14 +43,15 @@
 
  static const VMStateDescription vmstate_imx_serial = {
      .name = TYPE_IMX_SERIAL,
-    .version_id = 3,
-    .minimum_version_id = 3,
+    .version_id = 4,
+    .minimum_version_id = 4,
      .fields = (const VMStateField[]) {
          VMSTATE_FIFO32(rx_fifo, IMXSerialState),
          VMSTATE_TIMER(ageing_timer, IMXSerialState),
          VMSTATE_UINT32(usr1, IMXSerialState),
          VMSTATE_UINT32(usr2, IMXSerialState),
          VMSTATE_UINT32(ucr1, IMXSerialState),
+        VMSTATE_UINT32(ucr2, IMXSerialState),
          VMSTATE_UINT32(uts1, IMXSerialState),
          VMSTATE_UINT32(onems, IMXSerialState),
          VMSTATE_UINT32(ufcr, IMXSerialState),
#3 lore raw

Re: [PATCH 1/1] hw/char: imx_serial: add missing migration state

Quoted 43 lines · Michael Tokarev
Quoted 41 lines · Tao Ding

Add ucr2 from imx_serial to vmstate, and increment the version_id.

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
Quoted 8 lines
Quoted 1 line

Somehow, this grow Cc: qemu-stable@ in the final version which was applied as v11.1.0-rc0-68-g8833ff95eaf. I don't think this is a good candidate for the stable series, since this fix changes the migration stream format, which is very difficult to do in the stable series.

On the other hand it goes from "migration doesn't work" to "migration works" for a typical guest :-) But I agree it's probably better to avoid migration breaks in stable branches unless they're fixing something really critical.

-- PMM

#4 lore raw
In reply to Tao Ding
Quoted 5 lines · Tao Ding

Hi all.
The imx_serial is missing a migration status, resulting in no display on the terminal after migration. This patch fixes this issue.

Whoops. Yes, ucr2 has the rx enable and tx enable bits, so not migrating it will leave the UART in a completely broken state.

I've applied this patch to target-arm.next for 11.1. I tweaked the commit message a bit to lead off with a clearer description of the problem and to note that it's a migration compat break:

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.

[etc]

thanks
-- PMM