From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LS9Z1-000429-Kr for qemu-devel@nongnu.org; Wed, 28 Jan 2009 07:30:39 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LS9Z0-00041r-6d for qemu-devel@nongnu.org; Wed, 28 Jan 2009 07:30:39 -0500 Received: from [199.232.76.173] (port=48939 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LS9Z0-00041o-4Z for qemu-devel@nongnu.org; Wed, 28 Jan 2009 07:30:38 -0500 Received: from mx20.gnu.org ([199.232.41.8]:5289) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LS9Yz-0004w4-Tt for qemu-devel@nongnu.org; Wed, 28 Jan 2009 07:30:38 -0500 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LS9Yu-0006m5-WB for qemu-devel@nongnu.org; Wed, 28 Jan 2009 07:30:33 -0500 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH] support >2TB SCSI disks Date: Wed, 28 Jan 2009 12:30:28 +0000 References: <20090127224619.3ae16173@bree.surriel.com> In-Reply-To: <20090127224619.3ae16173@bree.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200901281230.29455.paul@codesourcery.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org > =A0 =A0 =A0case 0: > - =A0 =A0 =A0 =A0lba =3D buf[3] | (buf[2] << 8) | ((buf[1] & 0x1f) << 16); > + =A0 =A0 =A0 =A0lba =3D (uint64_t) buf[3] | ((uint64_t) buf[2] << 8) | > + =A0 =A0 =A0 =A0 =A0 =A0 =A0(((uint64_t) buf[1] & 0x1f) << 16); This is not required, though I guess it's harmless. > =A0 =A0 =A0case 4: >... > =A0 =A0 =A0 =A0 =A0len =3D buf[13] | (buf[12] << 8) | (buf[11] << 16) | (= buf[10] << 24); >... > + =A0 =A0case 0x88: > =A0 =A0 =A0 =A0 =A0r->sector_count =3D len * s->cluster_size; Implementing these commands introduces several overflows. There are several= =20 places (including SCSIRequest->sector_count and the return value from=20 scsi_send_comand) that assume the transfer length fits in a signed (32-bit)= =20 int. We should to implement the Block Limits VPD page, and enforce these limits. > + =A0 =A0 =A0 =A0 =A0 =A0/* Returned value is the address of the last sec= tor. =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0if (nb_sectors) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nb_sectors--; By my reading both this and the current Read Capacity(10) are incorrect. They need to divide by s->cluster_size. Paul