Commit b04f29e78c for qemu.org

commit b04f29e78cc2581266fa4d1c78d57525e8f7791c
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date:   Wed Oct 28 09:58:54 2026 +0100

    hw/sd/sdcard: Fix incoming migration of SPI mode cards

    sd_vmstate_pre_load() powers up the card when the OCR state is not
    part of the migration stream. Since commit b66f73a0cb31, SPI mode
    cards are already powered up at reset, so the incoming migration
    of a machine with an SPI mode card aborts in sd_ocr_powerup():

      Assertion failed: (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)),
      function sd_ocr_powerup, file sd.c, line 409.

    Only power up the card if it is not already powered up.

    Cc: qemu-stable@nongnu.org
    Fixes: b66f73a0cb31 ("hw/sd: Add SDHC support for SD card SPI-mode")
    Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Message-ID: <20261123225349.54981-5-philmd@oss.qualcomm.com>

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 81dd54beb9..442a749109 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1067,8 +1067,11 @@ static int sd_vmstate_pre_load(void *opaque)
     /* If the OCR state is not included (prior versions, or not
      * needed), then the OCR must be set as powered up. If the OCR state
      * is included, this will be replaced by the state restore.
+     * In SPI mode the card is already powered up after reset.
      */
-    sd_ocr_powerup(sd);
+    if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) {
+        sd_ocr_powerup(sd);
+    }

     return 0;
 }