]> xenbits.xensource.com Git - people/dariof/qemu-xen.git/commitdiff
hw/sd/sdcard: Restrict Class 6 commands to SCSD cards
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Wed, 3 Jun 2020 17:59:16 +0000 (19:59 +0200)
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>
Tue, 14 Jul 2020 13:45:58 +0000 (15:45 +0200)
Only SCSD cards support Class 6 (Block Oriented Write Protection)
commands.

  "SD Specifications Part 1 Physical Layer Simplified Spec. v3.01"

  4.3.14 Command Functional Difference in Card Capacity Types

  * Write Protected Group

  SDHC and SDXC do not support write-protected groups. Issuing
  CMD28, CMD29 and CMD30 generates the ILLEGAL_COMMAND error.

Cc: qemu-stable@nongnu.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20200630133912.9428-7-f4bug@amsat.org>

hw/sd/sd.c

index 5137168d6611f71eb4ec1c3eb59e55ccffff6eb1..1cc16bfd31259005ed4848464a1bd08df44a0575 100644 (file)
@@ -920,6 +920,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
         sd->multi_blk_cnt = 0;
     }
 
+    if (sd_cmd_class[req.cmd] == 6 && FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) {
+        /* Only Standard Capacity cards support class 6 commands */
+        return sd_illegal;
+    }
+
     switch (req.cmd) {
     /* Basic commands (Class 0 and Class 1) */
     case 0:    /* CMD0:   GO_IDLE_STATE */