[PATCH for-11.2] hw/ssi/aspeed_smc: Correct minimum_version_id in vmstate

Peter Maydell posted 1 patch 3 days, 11 hours ago
hw/ssi/aspeed_smc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
[PATCH for-11.2] hw/ssi/aspeed_smc: Correct minimum_version_id in vmstate
Posted by Peter Maydell 3 days, 11 hours ago
In commit 29139270d8ad70f2 we made an incompatible change to the
migration state for the aspeed_smc device, and bumped the version_id
and minimum_version_id: this is because we increased ASPEED_SMC_R_MAX
and so the regs array is bigger.

However, the old vmstate was handling migration from a range of
vmstate versions, with version_id = 3 and minimum_version_id = 1.
The change to ASPEED_SMC_R_MAX is (intentionally) not compatible with
any of those older versions, and so it should have moved
minimum_version_id up to 4 (matching the new version_id), not merely
increment it.

The effect of this is that trying a migration save on v11.1.3 and
then a load on the current head of git fails in a confusing way
("Missing section footer for aspeed.smc") rather than clearly ("error
while loading state for instance 0x0 of device 'aspeed.smc':
aspeed.smc: incoming version_id 3 is too old for local minimum
version_id 5").

Since we now don't need to try to handle migration from versions 2
and 3 at all, we can drop the complications in the vmstate struct (an
unused field, and field only present in version 3 and up). Clean
these up and set the version_id and minimum_version_id to 5
accordingly.

Fixes: 29139270d8ad70f2 ("hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4880
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/ssi/aspeed_smc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index ec9ad0f747e..f82947e752e 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -1218,12 +1218,11 @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp)
 
 static const VMStateDescription vmstate_aspeed_smc = {
     .name = "aspeed.smc",
-    .version_id = 4,
-    .minimum_version_id = 2,
+    .version_id = 5,
+    .minimum_version_id = 5,
     .fields = (const VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, AspeedSMCState, ASPEED_SMC_R_MAX),
-        VMSTATE_UNUSED_V(2, 2), /* was snoop_index/snoop_dummies */
-        VMSTATE_BOOL_V(unselect, AspeedSMCState, 3),
+        VMSTATE_BOOL(unselect, AspeedSMCState),
         VMSTATE_END_OF_LIST()
     }
 };
-- 
2.43.0
Re: [PATCH for-11.2] hw/ssi/aspeed_smc: Correct minimum_version_id in vmstate
Posted by Cédric Le Goater 2 days, 21 hours ago
On 11/19/26 18:14, Peter Maydell wrote:
> In commit 29139270d8ad70f2 we made an incompatible change to the
> migration state for the aspeed_smc device, and bumped the version_id
> and minimum_version_id: this is because we increased ASPEED_SMC_R_MAX
> and so the regs array is bigger.
> 
> However, the old vmstate was handling migration from a range of
> vmstate versions, with version_id = 3 and minimum_version_id = 1.
> The change to ASPEED_SMC_R_MAX is (intentionally) not compatible with
> any of those older versions, and so it should have moved
> minimum_version_id up to 4 (matching the new version_id), not merely
> increment it.
> 
> The effect of this is that trying a migration save on v11.1.3 and
> then a load on the current head of git fails in a confusing way
> ("Missing section footer for aspeed.smc") rather than clearly ("error
> while loading state for instance 0x0 of device 'aspeed.smc':
> aspeed.smc: incoming version_id 3 is too old for local minimum
> version_id 5").
> 
> Since we now don't need to try to handle migration from versions 2
> and 3 at all, we can drop the complications in the vmstate struct (an
> unused field, and field only present in version 3 and up). Clean
> these up and set the version_id and minimum_version_id to 5
> accordingly.
> 
> Fixes: 29139270d8ad70f2 ("hw/ssi/aspeed_smc: Add Data FIFO-based flash access support for AST2700")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4880
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/ssi/aspeed_smc.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index ec9ad0f747e..f82947e752e 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -1218,12 +1218,11 @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp)
>   
>   static const VMStateDescription vmstate_aspeed_smc = {
>       .name = "aspeed.smc",
> -    .version_id = 4,
> -    .minimum_version_id = 2,
> +    .version_id = 5,
> +    .minimum_version_id = 5,
>       .fields = (const VMStateField[]) {
>           VMSTATE_UINT32_ARRAY(regs, AspeedSMCState, ASPEED_SMC_R_MAX),
> -        VMSTATE_UNUSED_V(2, 2), /* was snoop_index/snoop_dummies */
> -        VMSTATE_BOOL_V(unselect, AspeedSMCState, 3),
> +        VMSTATE_BOOL(unselect, AspeedSMCState),
>           VMSTATE_END_OF_LIST()
>       }
>   };


Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.