Skip to contentSkip to conversation

scsi-disk: passthrough VERIFY command

PATCH In review Junlian Bell 2 participants 3 messages Dec 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi-disk: passthrough VERIFY command

When a scsi-disk object receives VERIFY command with BYTCHK bit being zero, scsi_block_is_passthrough returns false and finally makes req being proceeded by scsi_block_dma_command. Because scsi_block_dma_command has removed process of VERIFY, QEMU will abort in this function.

This patch makes all VERIFY passthrough to solve this problom.

---
 hw/scsi/scsi-disk.c | 7 -------
 1 file changed, 7 deletions(-)
hw/scsi/scsi-disk.c +0 -7
index a96319138a..f30f97f976 100644
@@ -2690,13 +2690,6 @@ static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf)
     case VERIFY_10:
     case VERIFY_12:
     case VERIFY_16:
-        /* Check if BYTCHK == 0x01 (data-out buffer contains data
-         * for the number of logical blocks specified in the length
-         * field).  For other modes, do not use scatter/gather operation.
-         */
-        if ((buf[1] & 6) != 2) {
-            return false;
-        }
         break;
 
     case READ_6:
Signature · 1 line
2.11.0.28.gde2efeb
#1 lore raw
Quoted 21 lines · Junlian Bell

When a scsi-disk object receives VERIFY command with BYTCHK bit being zero, scsi_block_is_passthrough returns false and finally makes req being proceeded by scsi_block_dma_command. Because scsi_block_dma_command has removed process of VERIFY, QEMU will abort in this function.

This patch makes all VERIFY passthrough to solve this problom.

---
 hw/scsi/scsi-disk.c | 7 -------
 1 file changed, 7 deletions(-)
hw/scsi/scsi-disk.c +0 -0
index a96319138a..f30f97f976 100644
@@ -2690,13 +2690,6 @@ static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf)
     case VERIFY_10:
     case VERIFY_12:
     case VERIFY_16:

hw/scsi/scsi-disk.c static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf) · line 2695

Quoted 10 lines
hw/scsi/scsi-disk.c +0 -7
-        /* Check if BYTCHK == 0x01 (data-out buffer contains data
-         * for the number of logical blocks specified in the length
-         * field).  For other modes, do not use scatter/gather operation.
-         */
-        if ((buf[1] & 6) != 2) {
-            return false;
-        }
         break;
 
     case READ_6:

Does this work too?

hw/scsi/scsi-disk.c +0 -0
index a963191..676164d 100644
@@ -2157,6 +2157,13 @@ static int32_t scsi_disk_dma_command(SCSIRequest

*req, uint8_t *buf)

         DPRINTF("Write %s(sector %" PRId64 ", count %u)\n",
                 (command & 0xe) == 0xe ? "And Verify " : "",
                 r->req.cmd.lba, len);
+    case VERIFY_10:
+    case VERIFY_12:
+    case VERIFY_16:
+        /* We get here only for BYTCHK=00 and only for scsi-block.  As
+         * far as DMA is concerned, we can treat it as a write, and
+         * scsi_block_do_sgio will send VERIFY commands.
+         */
         if (r->req.cmd.buf[1] & 0xe0) {
             goto illegal_request;
         }

Thanks,

Paolo

#2 lore raw

Yes, it's also work.
So you prefer the latter?

[email protected]

From: Paolo Bonzini
Date: 2016-12-16 18:10
To: Junlian Bell
CC: qemu-devel
Subject: Re: [PATCH 1/1] scsi-disk: passthrough VERIFY command

Quoted 21 lines · Junlian Bell

When a scsi-disk object receives VERIFY command with BYTCHK bit being zero, scsi_block_is_passthrough returns false and finally makes req being proceeded by scsi_block_dma_command. Because scsi_block_dma_command has removed process of VERIFY, QEMU will abort in this function.

This patch makes all VERIFY passthrough to solve this problom.

---
 hw/scsi/scsi-disk.c | 7 -------
 1 file changed, 7 deletions(-)
hw/scsi/scsi-disk.c +0 -0
index a96319138a..f30f97f976 100644
@@ -2690,13 +2690,6 @@ static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf)
     case VERIFY_10:
     case VERIFY_12:
     case VERIFY_16:

hw/scsi/scsi-disk.c static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf) · line 2695

Quoted 10 lines
hw/scsi/scsi-disk.c +0 -7
-        /* Check if BYTCHK == 0x01 (data-out buffer contains data
-         * for the number of logical blocks specified in the length
-         * field).  For other modes, do not use scatter/gather operation.
-         */
-        if ((buf[1] & 6) != 2) {
-            return false;
-        }
         break;
 
     case READ_6:

Does this work too?

hw/scsi/scsi-disk.c +0 -0
index a963191..676164d 100644
@@ -2157,6 +2157,13 @@ static int32_t scsi_disk_dma_command(SCSIRequest

*req, uint8_t *buf)

         DPRINTF("Write %s(sector %" PRId64 ", count %u)\n",
                 (command & 0xe) == 0xe ? "And Verify " : "",
                 r->req.cmd.lba, len);
+    case VERIFY_10:
+    case VERIFY_12:
+    case VERIFY_16:
+        /* We get here only for BYTCHK=00 and only for scsi-block.  As
+         * far as DMA is concerned, we can treat it as a write, and
+         * scsi_block_do_sgio will send VERIFY commands.
+         */
         if (r->req.cmd.buf[1] & 0xe0) {
             goto illegal_request;
         }

Thanks,

Paolo