[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/35] scsi-disk: fail READ CAPACITY if LBA != 0 but
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 19/35] scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0 |
Date: |
Thu, 13 Oct 2011 13:03:49 +0200 |
Tested by the Windows Logo Kit SCSI Compliance test. From SBC-3, paragraph
5.25: "The LOGICAL BLOCK ADDRESS field shall be set to zero if the PMI
bit is set to zero. If the PMI bit is set to zero and the LOGICAL BLOCK
ADDRESS field is not set to zero, then the device server shall 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: Paolo Bonzini <address@hidden>
---
hw/scsi-disk.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 97a7335..b041fd5 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1161,8 +1161,12 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
/* The normal LEN field for this command is zero. */
memset(outbuf, 0, 8);
bdrv_get_geometry(s->bs, &nb_sectors);
- if (!nb_sectors)
+ if (!nb_sectors) {
goto not_ready;
+ }
+ if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) {
+ goto illegal_request;
+ }
nb_sectors /= s->cluster_size;
/* Returned value is the address of the last sector. */
nb_sectors--;
@@ -1207,8 +1211,12 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
DPRINTF("SAI READ CAPACITY(16)\n");
memset(outbuf, 0, req->cmd.xfer);
bdrv_get_geometry(s->bs, &nb_sectors);
- if (!nb_sectors)
+ if (!nb_sectors) {
goto not_ready;
+ }
+ if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) {
+ goto illegal_request;
+ }
nb_sectors /= s->cluster_size;
/* Returned value is the address of the last sector. */
nb_sectors--;
--
1.7.6
- [Qemu-devel] [PATCH 22/35] scsi-disk: fix retrying a flush, (continued)
- [Qemu-devel] [PATCH 22/35] scsi-disk: fix retrying a flush, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 01/35] scsi: pass correct sense code for ENOMEDIUM, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 25/35] scsi-generic: check ioctl statuses when SG_IO succeeds, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 24/35] scsi-generic: remove scsi_req_fixup, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 23/35] scsi-generic: drop SCSIGenericState, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 26/35] scsi-generic: look at host status, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 33/35] scsi: export scsi_generic_reqops, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 32/35] scsi: make reqops static const, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 20/35] scsi-disk: do not complete requests twice, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 19/35] scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 35/35] scsi-disk: add scsi-block for device passthrough, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 12/35] scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 34/35] scsi: pass cdb to alloc_req, Paolo Bonzini, 2011/10/13
- [Qemu-devel] [PATCH 15/35] scsi: remove devs array from SCSIBus, Paolo Bonzini, 2011/10/13