* Re: [PATCH for-11.2] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled
2026-11-16 11:46 [PATCH for-11.2] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled Peter Maydell
@ 2026-11-17 5:50 ` Karl Mehltretter
2026-11-23 11:31 ` Peter Maydell
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Karl Mehltretter @ 2026-11-17 5:50 UTC (permalink / raw)
To: Peter Maydell
Cc: Karl Mehltretter, qemu-arm, qemu-devel, Jean-Christophe Dubois
On Mon, 16 Nov 2026 at 11:46, Peter Maydell <peter.maydell@linaro.org> wrote:
> The wdt_imx2 device has optional support for pretimeouts, which are
> present on most i.MX SoCs but not on i.MX31. If the QOM property
> 'pretimeout-support' is not set to true then we don't create the
> ptimer associated with that feature. However, the migration vmstate
> unconditionally lists that ptimer, with the result that trying to
> save the vmstate of an i.MX31-based machine like "kzm" will hit an
> assertion.
>
> Move the migration of 'itimer' into its own subsection which we only
> send when pretimeout support is enabled.
>
> Fixes: daca13d495a11 ("hw/watchdog: Implement full i.MX watchdog support")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4876
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
With this patch on master (97c88c61d45d), saving and loading a paused kzm
machine exits 0 instead of aborting in vmstate_save_vmsd_v().
Tested on Debian 13 x86_64.
Tested-by: Karl Mehltretter <kmehltretter@gmail.com>
Thanks,
Karl
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH for-11.2] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled
2026-11-16 11:46 [PATCH for-11.2] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled Peter Maydell
2026-11-17 5:50 ` Karl Mehltretter
@ 2026-11-23 11:31 ` Peter Maydell
2026-11-24 11:06 ` Alex Bennée
2026-12-01 11:27 ` Bernhard Beschow
3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2026-11-23 11:31 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: Jean-Christophe Dubois
Could I get a review on this, please? I'd quite like to be
able to put it in the pullreq I intend to send for the next rc.
thanks
-- PMM
On Mon, 16 Nov 2026 at 11:46, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> The wdt_imx2 device has optional support for pretimeouts, which are
> present on most i.MX SoCs but not on i.MX31. If the QOM property
> 'pretimeout-support' is not set to true then we don't create the
> ptimer associated with that feature. However, the migration vmstate
> unconditionally lists that ptimer, with the result that trying to
> save the vmstate of an i.MX31-based machine like "kzm" will hit an
> assertion.
>
> Move the migration of 'itimer' into its own subsection which we only
> send when pretimeout support is enabled.
>
> This bug has existed in the code for a long time, but it was hidden
> until commit d9abd0253be ("hw/watchdog/wdt_imx2: Remove redundant
> attributes)" because a bug in the VMSTATE_PTIMER() macro together
> with the fact that the vmstate_imx2_wdt version_id was 0 meant that
> we weren't trying to migrate the device's ptimers at all, and so
> we avoided the assertion (but didn't migrate correctly).
>
> This is a migration compatibility break for this device, but it isn't
> used in any versioned machine types, and we've already decided to
> break compat on it this release cycle.
>
> Fixes: daca13d495a11 ("hw/watchdog: Implement full i.MX watchdog support")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4876
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Based-on: 20261106163657.3825938-1-peter.maydell@linaro.org
> ("Fix 'version' arg of VMSTATE_PTIMER")
> -- the patch in that which sets minimum_version_id to 1 in
> the wdt_imx2 vmstate would otherwise be a conflict
> ---
> hw/watchdog/wdt_imx2.c | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/hw/watchdog/wdt_imx2.c b/hw/watchdog/wdt_imx2.c
> index abb8edfae25..b4196de7021 100644
> --- a/hw/watchdog/wdt_imx2.c
> +++ b/hw/watchdog/wdt_imx2.c
> @@ -221,13 +221,31 @@ static const MemoryRegionOps imx2_wdt_ops = {
> },
> };
>
> -static const VMStateDescription vmstate_imx2_wdt = {
> - .name = "imx2.wdt",
> +static bool pretimeout_state_needed(void *opaque)
> +{
> + /* The itimer is only present if pretimeout-support is enabled */
> + IMX2WdtState *s = opaque;
> +
> + return s->pretimeout_support;
> +}
> +
> +static const VMStateDescription vmstate_imx2_wdt_pretimeout = {
> + .name = "imx2.wdt/pretimeout",
> .version_id = 1,
> .minimum_version_id = 1,
> + .needed = pretimeout_state_needed,
> + .fields = (const VMStateField[]) {
> + VMSTATE_PTIMER(itimer, IMX2WdtState),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static const VMStateDescription vmstate_imx2_wdt = {
> + .name = "imx2.wdt",
> + .version_id = 2,
> + .minimum_version_id = 2,
> .fields = (const VMStateField[]) {
> VMSTATE_PTIMER(timer, IMX2WdtState),
> - VMSTATE_PTIMER(itimer, IMX2WdtState),
> VMSTATE_BOOL(wicr_locked, IMX2WdtState),
> VMSTATE_BOOL(wcr_locked, IMX2WdtState),
> VMSTATE_UINT16(wcr, IMX2WdtState),
> @@ -236,6 +254,10 @@ static const VMStateDescription vmstate_imx2_wdt = {
> VMSTATE_UINT16(wmcr, IMX2WdtState),
> VMSTATE_UINT16(wicr, IMX2WdtState),
> VMSTATE_END_OF_LIST()
> + },
> + .subsections = (const VMStateDescription * const []) {
> + &vmstate_imx2_wdt_pretimeout,
> + NULL
> }
> };
>
> --
> 2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH for-11.2] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled
2026-11-16 11:46 [PATCH for-11.2] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled Peter Maydell
2026-11-17 5:50 ` Karl Mehltretter
2026-11-23 11:31 ` Peter Maydell
@ 2026-11-24 11:06 ` Alex Bennée
2026-12-01 11:27 ` Bernhard Beschow
3 siblings, 0 replies; 5+ messages in thread
From: Alex Bennée @ 2026-11-24 11:06 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Jean-Christophe Dubois
Peter Maydell <peter.maydell@linaro.org> writes:
> The wdt_imx2 device has optional support for pretimeouts, which are
> present on most i.MX SoCs but not on i.MX31. If the QOM property
> 'pretimeout-support' is not set to true then we don't create the
> ptimer associated with that feature. However, the migration vmstate
> unconditionally lists that ptimer, with the result that trying to
> save the vmstate of an i.MX31-based machine like "kzm" will hit an
> assertion.
>
> Move the migration of 'itimer' into its own subsection which we only
> send when pretimeout support is enabled.
>
> This bug has existed in the code for a long time, but it was hidden
> until commit d9abd0253be ("hw/watchdog/wdt_imx2: Remove redundant
> attributes)" because a bug in the VMSTATE_PTIMER() macro together
> with the fact that the vmstate_imx2_wdt version_id was 0 meant that
> we weren't trying to migrate the device's ptimers at all, and so
> we avoided the assertion (but didn't migrate correctly).
>
> This is a migration compatibility break for this device, but it isn't
> used in any versioned machine types, and we've already decided to
> break compat on it this release cycle.
>
> Fixes: daca13d495a11 ("hw/watchdog: Implement full i.MX watchdog support")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4876
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Based-on: 20261106163657.3825938-1-peter.maydell@linaro.org
> ("Fix 'version' arg of VMSTATE_PTIMER")
> -- the patch in that which sets minimum_version_id to 1 in
> the wdt_imx2 vmstate would otherwise be a conflict
LGTM
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH for-11.2] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled
2026-11-16 11:46 [PATCH for-11.2] hw/watchdog/wdt_imx2: Fix migration when pretimeout-support not enabled Peter Maydell
` (2 preceding siblings ...)
2026-11-24 11:06 ` Alex Bennée
@ 2026-12-01 11:27 ` Bernhard Beschow
3 siblings, 0 replies; 5+ messages in thread
From: Bernhard Beschow @ 2026-12-01 11:27 UTC (permalink / raw)
To: qemu-devel, Peter Maydell, qemu-arm; +Cc: Jean-Christophe Dubois
Am 16. November 2026 11:46:41 UTC schrieb Peter Maydell <peter.maydell@linaro.org>:
>The wdt_imx2 device has optional support for pretimeouts, which are
>present on most i.MX SoCs but not on i.MX31. If the QOM property
>'pretimeout-support' is not set to true then we don't create the
>ptimer associated with that feature. However, the migration vmstate
>unconditionally lists that ptimer, with the result that trying to
>save the vmstate of an i.MX31-based machine like "kzm" will hit an
>assertion.
>
>Move the migration of 'itimer' into its own subsection which we only
>send when pretimeout support is enabled.
>
>This bug has existed in the code for a long time, but it was hidden
>until commit d9abd0253be ("hw/watchdog/wdt_imx2: Remove redundant
>attributes)" because a bug in the VMSTATE_PTIMER() macro together
>with the fact that the vmstate_imx2_wdt version_id was 0 meant that
>we weren't trying to migrate the device's ptimers at all, and so
>we avoided the assertion (but didn't migrate correctly).
>
>This is a migration compatibility break for this device, but it isn't
>used in any versioned machine types, and we've already decided to
>break compat on it this release cycle.
>
>Fixes: daca13d495a11 ("hw/watchdog: Implement full i.MX watchdog support")
>Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4876
>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Sorry for missing this patxh so far. The approach LGTM.
Acked-by: Bernhard Beschow <shentey@gmail.com>
>---
>Based-on: 20261106163657.3825938-1-peter.maydell@linaro.org
>("Fix 'version' arg of VMSTATE_PTIMER")
> -- the patch in that which sets minimum_version_id to 1 in
> the wdt_imx2 vmstate would otherwise be a conflict
>---
> hw/watchdog/wdt_imx2.c | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
>diff --git a/hw/watchdog/wdt_imx2.c b/hw/watchdog/wdt_imx2.c
>index abb8edfae25..b4196de7021 100644
>--- a/hw/watchdog/wdt_imx2.c
>+++ b/hw/watchdog/wdt_imx2.c
>@@ -221,13 +221,31 @@ static const MemoryRegionOps imx2_wdt_ops = {
> },
> };
>
>-static const VMStateDescription vmstate_imx2_wdt = {
>- .name = "imx2.wdt",
>+static bool pretimeout_state_needed(void *opaque)
>+{
>+ /* The itimer is only present if pretimeout-support is enabled */
>+ IMX2WdtState *s = opaque;
>+
>+ return s->pretimeout_support;
>+}
>+
>+static const VMStateDescription vmstate_imx2_wdt_pretimeout = {
>+ .name = "imx2.wdt/pretimeout",
> .version_id = 1,
> .minimum_version_id = 1,
>+ .needed = pretimeout_state_needed,
>+ .fields = (const VMStateField[]) {
>+ VMSTATE_PTIMER(itimer, IMX2WdtState),
>+ VMSTATE_END_OF_LIST()
>+ }
>+};
>+
>+static const VMStateDescription vmstate_imx2_wdt = {
>+ .name = "imx2.wdt",
>+ .version_id = 2,
>+ .minimum_version_id = 2,
> .fields = (const VMStateField[]) {
> VMSTATE_PTIMER(timer, IMX2WdtState),
>- VMSTATE_PTIMER(itimer, IMX2WdtState),
> VMSTATE_BOOL(wicr_locked, IMX2WdtState),
> VMSTATE_BOOL(wcr_locked, IMX2WdtState),
> VMSTATE_UINT16(wcr, IMX2WdtState),
>@@ -236,6 +254,10 @@ static const VMStateDescription vmstate_imx2_wdt = {
> VMSTATE_UINT16(wmcr, IMX2WdtState),
> VMSTATE_UINT16(wicr, IMX2WdtState),
> VMSTATE_END_OF_LIST()
>+ },
>+ .subsections = (const VMStateDescription * const []) {
>+ &vmstate_imx2_wdt_pretimeout,
>+ NULL
> }
> };
>
^ permalink raw reply [flat|nested] 5+ messages in thread