[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 06/15] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v6 06/15] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards |
Date: |
Tue, 30 Jun 2020 12:03:33 +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.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/sd/sd.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 7e0d684aca..871c30a67f 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -922,6 +922,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 */
--
2.21.3
- [PATCH v6 00/15] hw/sd/sdcard: Fix CVE-2020-13253 & cleanups, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 01/15] MAINTAINERS: Cc qemu-block mailing list, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 02/15] hw/sd/sdcard: Update coding style to make checkpatch.pl happy, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 03/15] hw/sd/sdcard: Move some definitions to use them earlier, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 04/15] hw/sd/sdcard: Use the HWBLOCK_SIZE definition, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 05/15] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 06/15] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards,
Philippe Mathieu-Daudé <=
- [PATCH v6 07/15] hw/sd/sdcard: Initialize constant values first, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 08/15] hw/sd/sdcard: Check address is in range, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 09/15] hw/sd/sdcard: Update the SDState documentation, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 10/15] hw/sd/sdcard: Simplify cmd_valid_while_locked(), Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 11/15] hw/sd/sdcard: Constify sd_crc*()'s message argument, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 12/15] hw/sd/sdcard: Make iolen unsigned, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 13/15] hw/sd/sdcard: Correctly display the command name in trace events, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 14/15] hw/sd/sdcard: Display offset in read/write_data() trace events, Philippe Mathieu-Daudé, 2020/06/30
- [PATCH v6 15/15] hw/sd/sdcard: Simplify realize() a bit, Philippe Mathieu-Daudé, 2020/06/30
- Re: [PATCH v6 00/15] hw/sd/sdcard: Fix CVE-2020-13253 & cleanups, no-reply, 2020/06/30