[PATCH] hw/sd: give the RPMB vmstate subsection a name of its own

Denis V. Lunev posted 1 patch 1 week, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260814183859.4034017-1-den@openvz.org
Maintainers: "Philippe Mathieu-Daudé" <philmd@mailo.com>, Bin Meng <bmeng.cn@gmail.com>
hw/sd/sd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hw/sd: give the RPMB vmstate subsection a name of its own
Posted by Denis V. Lunev 1 week, 5 days ago
From: Denis V. Lunev <den@openvz.org>

emmc_rpmb_vmstate and emmc_extcsd_vmstate are both called
"sd-card/ext_csd_modes-state" and both sit in sd_vmstate.subsections, so
a card with an RPMB partition sends two subsections under one name:
192 bytes of ext_csd_rw and 353 bytes of RPMB state.

vmstate_get_subsection() returns the first entry whose name matches, so
the destination parses both of them as emmc_extcsd_vmstate. The RPMB
section is 161 bytes longer than the fields being loaded from it, the
stream is left mid-section, and the load fails:

  (qemu) migrate file:vm.mig
  ... on the destination:
  load of migration failed: Invalid argument:
  Section footer error, section_id: 38

Reproduced with

  qemu-system-x86_64 -M q35 -device sdhci-pci,id=mmc \
    -drive if=none,id=d0,file=emmc.raw,format=raw \
    -device emmc,bus=sd-bus,drive=d0,rpmb-partition-size=131072

Name it "sd-card/rpmb-state". A stream written by an affected version
cannot be loaded by any version, this one included, so there is no
working format to stay compatible with.

Cc: qemu-stable@nongnu.org
Fixes: 8ef4260a3f ("hw/sd/sdcard: Add basic support for RPMB partition")
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 hw/sd/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index a30c541df0..674ca09b49 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1022,7 +1022,7 @@ static bool vmstate_needed_for_rpmb(void *opaque)
 }
 
 static const VMStateDescription emmc_rpmb_vmstate = {
-    .name = "sd-card/ext_csd_modes-state",
+    .name = "sd-card/rpmb-state",
     .version_id = 1,
     .minimum_version_id = 1,
     .needed = vmstate_needed_for_rpmb,
-- 
2.53.0
Re: [PATCH] hw/sd: give the RPMB vmstate subsection a name of its own
Posted by Philippe Mathieu-Daudé 1 week, 4 days ago
On 14/8/26 20:38, Denis V. Lunev wrote:
> From: Denis V. Lunev <den@openvz.org>
> 
> emmc_rpmb_vmstate and emmc_extcsd_vmstate are both called
> "sd-card/ext_csd_modes-state" and both sit in sd_vmstate.subsections, so
> a card with an RPMB partition sends two subsections under one name:
> 192 bytes of ext_csd_rw and 353 bytes of RPMB state.
> 
> vmstate_get_subsection() returns the first entry whose name matches, so
> the destination parses both of them as emmc_extcsd_vmstate. The RPMB
> section is 161 bytes longer than the fields being loaded from it, the
> stream is left mid-section, and the load fails:
> 
>    (qemu) migrate file:vm.mig
>    ... on the destination:
>    load of migration failed: Invalid argument:
>    Section footer error, section_id: 38
> 
> Reproduced with
> 
>    qemu-system-x86_64 -M q35 -device sdhci-pci,id=mmc \
>      -drive if=none,id=d0,file=emmc.raw,format=raw \
>      -device emmc,bus=sd-bus,drive=d0,rpmb-partition-size=131072
> 
> Name it "sd-card/rpmb-state". A stream written by an affected version
> cannot be loaded by any version, this one included, so there is no
> working format to stay compatible with.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: 8ef4260a3f ("hw/sd/sdcard: Add basic support for RPMB partition")
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> ---
>   hw/sd/sd.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>

and queued, thanks.