From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGpwL-0002nB-4b for qemu-devel@nongnu.org; Sat, 16 Mar 2013 08:10:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGpwI-0006rf-PD for qemu-devel@nongnu.org; Sat, 16 Mar 2013 08:10:21 -0400 Received: from mail-pb0-f54.google.com ([209.85.160.54]:59805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGpwI-0006rF-Iw for qemu-devel@nongnu.org; Sat, 16 Mar 2013 08:10:18 -0400 Received: by mail-pb0-f54.google.com with SMTP id rr4so4944203pbb.27 for ; Sat, 16 Mar 2013 05:10:17 -0700 (PDT) Message-ID: <5144616B.8040808@ozlabs.ru> Date: Sat, 16 Mar 2013 23:11:23 +1100 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <1363418170-3391-1-git-send-email-aik@ozlabs.ru> <514429B2.4010207@redhat.com> In-Reply-To: <514429B2.4010207@redhat.com> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit 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: Paolo Bonzini Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson On 16/03/13 19:13, Paolo Bonzini wrote: > Il 16/03/2013 08:16, Alexey Kardashevskiy ha scritto: >> SCSI protocol is defined as big endian. The SCSI command REPORT_LUNS >> returns the list of LUNs, 8 bytes each. >> >> The store_lun() function is called from scsi_target_emulate_report_luns() >> to fill the LUNs list which is sent later to a guest a response. However >> it puts the 2 bytes long big-endian value while it is 8 bytes long. > > No, LUNs are composed of four 2-byte big-endian values. I cannot find it in "SCSI Commands References Manual" (for example here - http://www.seagate.com/staticfiles/support/disc/manuals/Interface%20manuals/100293068c.pdf ). 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? > What bug are you trying to fix? It is a ppc64 system firmware/bios (aka SLOF) which expects 8 bytes big endian value and therefore cannot boot from SCSI devices with LUN!=0. I can fix QEMU or SLOF but not sure which one. > > Paolo > >> The patch fixes it. Tested on PPC64 platform. >> >> Signed-off-by: Alexey Kardashevskiy >> --- >> hw/scsi-bus.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c >> index a97f1cd..7059dc2 100644 >> --- a/hw/scsi-bus.c >> +++ b/hw/scsi-bus.c >> @@ -310,11 +310,11 @@ struct SCSITargetReq { >> static void store_lun(uint8_t *outbuf, int lun) >> { >> if (lun < 256) { >> - outbuf[1] = lun; >> + outbuf[7] = lun; >> return; >> } >> - outbuf[1] = (lun & 255); >> - outbuf[0] = (lun >> 8) | 0x40; >> + outbuf[7] = (lun & 255); >> + outbuf[6] = (lun >> 8) | 0x40; >> } >> >> static bool scsi_target_emulate_report_luns(SCSITargetReq *r) >> > -- Alexey