Received: from eggs.gnu.org ([208.118.235.92]:51635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sum5O-0007kh-3K for qemu-devel@nongnu.org; Fri, 27 Jul 2012 11:04:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sum5E-0007RO-Jk for qemu-devel@nongnu.org; Fri, 27 Jul 2012 11:04:14 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:59010) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sum5E-0007FU-Dt for qemu-devel@nongnu.org; Fri, 27 Jul 2012 11:04:04 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so4974590pbb.4 for ; Fri, 27 Jul 2012 08:04:04 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 27 Jul 2012 17:02:45 +0200 Message-Id: <1343401379-19495-19-git-send-email-pbonzini@redhat.com> In-Reply-To: <1343401379-19495-1-git-send-email-pbonzini@redhat.com> References: <1343401379-19495-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 18/32] scsi-disk: rd/wr/vr-protect !=0 is an error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Ronnie Sahlberg From: 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 [ Rebase after scsi_dma_reqops introduction - Paolo ] Signed-off-by: Paolo Bonzini --- hw/scsi-disk.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index fd5cd70..526da4b 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1774,6 +1774,9 @@ static int32_t scsi_disk_dma_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 illegal_request; + } if (r->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } @@ -1794,6 +1797,9 @@ static int32_t scsi_disk_dma_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 illegal_request; + } if (r->req.cmd.lba > s->qdev.max_lba) { goto illegal_lba; } @@ -1802,6 +1808,9 @@ static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf) break; default: abort(); + illegal_request: + scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); + return 0; illegal_lba: scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); return 0; -- 1.7.10.4