All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] SCSI rd/wr/vr protect != 0 is an error
@ 2012-07-12  0:19 Ronnie Sahlberg
  2012-07-12  0:19 ` [Qemu-devel] [PATCH] SCSI: rd/wr/vr-protect !=0 " Ronnie Sahlberg
  0 siblings, 1 reply; 3+ messages in thread
From: Ronnie Sahlberg @ 2012-07-12  0:19 UTC (permalink / raw)
  To: pbonzini, qemu-devel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH] SCSI: rd/wr/vr-protect !=0 is an error
  2012-07-12  0:19 [Qemu-devel] [PATCH] SCSI rd/wr/vr protect != 0 is an error Ronnie Sahlberg
@ 2012-07-12  0:19 ` Ronnie Sahlberg
  2012-07-12  6:25   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Ronnie Sahlberg @ 2012-07-12  0:19 UTC (permalink / raw)
  To: pbonzini, qemu-devel; +Cc: Ronnie Sahlberg

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.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
---
 hw/scsi-disk.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 34336b1..b2f3c0c 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -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;
         }
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] SCSI: rd/wr/vr-protect !=0 is an error
  2012-07-12  0:19 ` [Qemu-devel] [PATCH] SCSI: rd/wr/vr-protect !=0 " Ronnie Sahlberg
@ 2012-07-12  6:25   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2012-07-12  6:25 UTC (permalink / raw)
  To: Ronnie Sahlberg; +Cc: qemu-devel

Il 12/07/2012 02:19, Ronnie Sahlberg ha scritto:
> 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.
> 
> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> ---
>  hw/scsi-disk.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index 34336b1..b2f3c0c 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -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;
>          }
> 

Applied, thanks!

Paolo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-12  6:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-12  0:19 [Qemu-devel] [PATCH] SCSI rd/wr/vr protect != 0 is an error Ronnie Sahlberg
2012-07-12  0:19 ` [Qemu-devel] [PATCH] SCSI: rd/wr/vr-protect !=0 " Ronnie Sahlberg
2012-07-12  6:25   ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.