summaryrefslogtreecommitdiffstats
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorPaolo Bonzini2011-10-03 13:57:06 +0200
committerKevin Wolf2011-10-28 19:25:51 +0200
commit7cec78b6f0e9a3b33732afd14a811849d219ffbc (patch)
treee1e43d3e1c13e777785d97ae74e32b46f73f8dd1 /hw/scsi-disk.c
parentscsi: add channel to addressing (diff)
downloadqemu-7cec78b6f0e9a3b33732afd14a811849d219ffbc.tar.gz
qemu-7cec78b6f0e9a3b33732afd14a811849d219ffbc.tar.xz
qemu-7cec78b6f0e9a3b33732afd14a811849d219ffbc.zip
scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0
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 <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 50fc3d6eaa..6b139acda1 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1180,6 +1180,9 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
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--;
@@ -1232,6 +1235,9 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
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--;