diff mbox series

[PATCH-for-9.1,2/5] hw/sd/sdcard: Do not abort when reading DAT lines on invalid cmd state

Message ID 20240730092138.32443-3-philmd@linaro.org
State Superseded
Headers show
Series hw/sd: SDcard & SDHCI fixes | expand

Commit Message

Philippe Mathieu-Daudé July 30, 2024, 9:21 a.m. UTC
Guest should not try to read the DAT lines from invalid
command state. If it still insists to do so, return a
dummy value.

Cc: qemu-stable@nongnu.org
Fixes: e2dec2eab0 ("hw/sd/sdcard: Remove default case in read/write on DAT lines")
Reported-by: Zheyu Ma <zheyuma97@gmail.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2454
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/sd/sd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Richard Henderson July 31, 2024, 4:30 a.m. UTC | #1
On 7/30/24 19:21, Philippe Mathieu-Daudé wrote:
> Guest should not try to read the DAT lines from invalid
> command state. If it still insists to do so, return a
> dummy value.
> 
> Cc:qemu-stable@nongnu.org
> Fixes: e2dec2eab0 ("hw/sd/sdcard: Remove default case in read/write on DAT lines")
> Reported-by: Zheyu Ma<zheyuma97@gmail.com>
> Resolves:https://gitlab.com/qemu-project/qemu/-/issues/2454
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   hw/sd/sd.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index c02f04f1ea..b1e6e36b44 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -2540,7 +2540,9 @@  uint8_t sd_read_byte(SDState *sd)
         break;
 
     default:
-        g_assert_not_reached();
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: DAT read illegal for command %s\n",
+                                       __func__, sd->last_cmd_name);
+        return dummy_byte;
     }
 
     return ret;