Skip to contentSkip to conversation

SCSI rd/wr/vr protect != 0 is an error

PATCH New Ronnie Sahlberg 2 participants 3 messages Jul 12, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SCSI rd/wr/vr protect != 0 is an error

List, Paolo,

Please find a small patch for the scsi emulation in qemu.
Since QEMU scsi emulation does not implement/support protection information
any READ/WRITE/VERIFY command that specifies a non-zero value for the rd/vr/wr-protect field in the CDB should fail with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB

regards
ronnie sahlberg

#1 lore raw

PATCH 1/1 SCSI: rd/wr/vr-protect !=0 is an error

The QEMU SCSI emulation does not support protection information, so any READ/WRITE/VERIFY commands that has the protect bits set to non-zero should fail with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB

Quoted 1 line

From SCSI SBC :

If the logical unit does not support protection information, then the device server should terminate the command with CHECK CONDITION status with the sense key set to ILLEGAL REQUEST and the additional sense code set to INVALID FIELD IN CDB.

---
 hw/scsi-disk.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/scsi-disk.c +6 -0
index 34336b1..b2f3c0c 100644
@@ -1555,6 +1555,9 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
     case READ_16:
         len = r->req.cmd.xfer / s->qdev.blocksize;
         DPRINTF("Read (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len);
+        if (r->req.cmd.buf[1] & 0xe0) {
+            goto fail;
+        }
         if (r->req.cmd.lba > s->qdev.max_lba) {
             goto illegal_lba;
         }
@@ -1575,6 +1578,9 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
         DPRINTF("Write %s(sector %" PRId64 ", count %d)\n",
                 (command & 0xe) == 0xe ? "And Verify " : "",
                 r->req.cmd.lba, len);
+        if (r->req.cmd.buf[1] & 0xe0) {
+            goto fail;
+        }
         if (r->req.cmd.lba > s->qdev.max_lba) {
             goto illegal_lba;
         }
Signature · 1 line
1.7.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH] SCSI: rd/wr/vr-protect !=0 is an error

Il 12/07/2012 02:19, Ronnie Sahlberg ha scritto:

Quoted 31 lines

The QEMU SCSI emulation does not support protection information, so any READ/WRITE/VERIFY commands that has the protect bits set to non-zero should fail with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB

From SCSI SBC :
If the logical unit does not support protection information, then the device server should terminate the command with CHECK CONDITION status with the sense key set to ILLEGAL REQUEST and the additional sense code set to INVALID FIELD IN CDB.

---
 hw/scsi-disk.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/scsi-disk.c +3 -0
index 34336b1..b2f3c0c 100644
@@ -1555,6 +1555,9 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
     case READ_16:
         len = r->req.cmd.xfer / s->qdev.blocksize;
         DPRINTF("Read (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len);
+        if (r->req.cmd.buf[1] & 0xe0) {
+            goto fail;
+        }
         if (r->req.cmd.lba > s->qdev.max_lba) {
             goto illegal_lba;
         }

hw/scsi-disk.c static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf) · line 1586

Quoted 9 lines
hw/scsi-disk.c +3 -0
@@ -1575,6 +1578,9 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
         DPRINTF("Write %s(sector %" PRId64 ", count %d)\n",
                 (command & 0xe) == 0xe ? "And Verify " : "",
                 r->req.cmd.lba, len);
+        if (r->req.cmd.buf[1] & 0xe0) {
+            goto fail;
+        }
         if (r->req.cmd.lba > s->qdev.max_lba) {
             goto illegal_lba;
         }

Applied, thanks!

Paolo