]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/sd/sdhci: Fix DMA Transfer Block Size field
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Tue, 1 Sep 2020 13:22:06 +0000 (15:22 +0200)
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>
Wed, 21 Oct 2020 11:19:01 +0000 (13:19 +0200)
The 'Transfer Block Size' field is 12-bit wide.

See section '2.2.2. Block Size Register (Offset 004h)' in datasheet.

Two different bug reproducer available:
- https://bugs.launchpad.net/qemu/+bug/1892960
- https://ruhr-uni-bochum.sciebo.de/s/NNWP2GfwzYKeKwE?path=%2Fsdhci_oob_write1

Cc: qemu-stable@nongnu.org
Buglink: https://bugs.launchpad.net/qemu/+bug/1892960
Fixes: d7dfca0807a ("hw/sdhci: introduce standard SD host controller")
Reported-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org>
Tested-by: Alexander Bulekov <alxndr@bu.edu>
Message-Id: <20200901140411.112150-3-f4bug@amsat.org>

hw/sd/sdhci.c

index ed717ab549bac060dfc55020101fd86df2727c6a..c849c3d99b82d6582a0a0a2d29f7dd4be731805f 100644 (file)
@@ -1107,7 +1107,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
         break;
     case SDHC_BLKSIZE:
         if (!TRANSFERRING_DATA(s->prnsts)) {
-            MASKED_WRITE(s->blksize, mask, value);
+            MASKED_WRITE(s->blksize, mask, extract32(value, 0, 12));
             MASKED_WRITE(s->blkcnt, mask >> 16, value >> 16);
         }