From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGr5r-0005xh-48 for qemu-devel@nongnu.org; Sat, 16 Mar 2013 09:24:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGr5p-0004fj-Rz for qemu-devel@nongnu.org; Sat, 16 Mar 2013 09:24:15 -0400 Message-ID: <51446F27.8060909@redhat.com> Date: Sat, 16 Mar 2013 14:09:59 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1363418170-3391-1-git-send-email-aik@ozlabs.ru> <514429B2.4010207@redhat.com> <5144616B.8040808@ozlabs.ru> <1363438887.1244.27.camel@pasglop> In-Reply-To: <1363438887.1244.27.camel@pasglop> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] scsi-bus: fix endianness bug in store_lun() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Benjamin Herrenschmidt Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Il 16/03/2013 14:01, Benjamin Herrenschmidt ha scritto: > On Sat, 2013-03-16 at 23:11 +1100, Alexey Kardashevskiy wrote: >>> No, LUNs are composed of four 2-byte big-endian values. >> >> I cannot find it in "SCSI Commands References Manual" >> (for example here -=20 >> http://www.seagate.com/staticfiles/support/disc/manuals/Interface% >> 20manuals/100293068c.pdf=20 >> ). It just says that it is 8 bytes per >> LUN and SCSI itself is big endian. Could you please point me to >> the correct spec? Look at section 4.7 of SAM-5. Most of it is useless, because the last six bytes are almost never used. Still, what matters for QEMU is 4.7.5 Single level LUN structure, 4.7.7 Peripheral device addressing method, 4.7.8 Flat space addressing method. In particular, you can see the reference to four two-byte fields in Table 11 =E2=80=94 "Single level LUN structure using peripheral device addressing method" and Table 12 =E2=80=94 "Single level LUN structure usi= ng flat space addressing method". > The confusion comes from the old SCSI protocol LUN as a 2 bytes number > identifying a unit for a given bus/device and the "new style" LUN as a > more generic concept such as used in SRP (ie vscsi is SRP) which > encompass the bus, ID and LUN in one big number. >=20 > The actual type of LUN returned by REPORT_LUN depends on the > SELECT_REPORT field (I don't remember the details, but the doco you > point to say to see what's in SAM-4) and the result is *variable* in > size, so it should be kosher for qemu to just return 2 bytes as long as > the LUN_LIST_LENGTH field of the reply is correct. No, that's wrong. Each LUN returned by REPORT LUNS is always 8 bytes. The field tells you if you are reporting all LUNs, only well-known LUNs, etc. Paolo