From patchwork Sat Mar 16 07:16:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 228199 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 22D2A2C00B8 for ; Sat, 16 Mar 2013 18:16:45 +1100 (EST) Received: from localhost ([::1]:60142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGlMB-0006SL-8a for incoming@patchwork.ozlabs.org; Sat, 16 Mar 2013 03:16:43 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGlLs-0006PL-RN for qemu-devel@nongnu.org; Sat, 16 Mar 2013 03:16:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGlLq-0007al-Mx for qemu-devel@nongnu.org; Sat, 16 Mar 2013 03:16:24 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:42530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGlLq-0007aT-8V for qemu-devel@nongnu.org; Sat, 16 Mar 2013 03:16:22 -0400 Received: by mail-pb0-f52.google.com with SMTP id ma3so4773367pbc.39 for ; Sat, 16 Mar 2013 00:16:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=7/ETTEr3wzRsMeFxFed7aM37aGEpJ4rDl44UkTDjOgs=; b=hpDOhWplQF7kHCFqtoJju7UXpwWFyuh/sqAIe7mdseqrR/6sNqjlSfMrpYoP5yiomU SqaPrG0vjOhqo1KapJdMtxy31LbTrjhow0AarPAd6mKcx5ma/znOxIlCIxLdOY3yk1LD 6VYZE6eHV5wE+LVTkePVJ9UoNe6nNeN16hbnaFqQXveFGNUJJ18VW12PT+Z4DqK4sUBe VMjYJs3Dn986UeDXYUPGvp8PRtlr6ybZZjwu8hSWCb/HkkOI4rmNMgObrhtS1CSnlzYQ uRet22086IbE/+QUz3X/1Oq3bpmpA03/u3WXT+L7AVQln49ekgGVUFXc8Y9vOykd+ba9 FkNQ== X-Received: by 10.68.11.169 with SMTP id r9mr22713465pbb.221.1363418180051; Sat, 16 Mar 2013 00:16:20 -0700 (PDT) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPS id xz5sm12678480pbb.25.2013.03.16.00.16.17 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Mar 2013 00:16:19 -0700 (PDT) From: Alexey Kardashevskiy To: Paolo Bonzini Date: Sat, 16 Mar 2013 18:16:10 +1100 Message-Id: <1363418170-3391-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQmgbjD9Z1gqG1a9T1oN2WMO4l5Yij8JRHBPM2pOlwWSkpC8hLd+9xjvcoUONGZLR9+vbfOj X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.160.52 Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Subject: [Qemu-devel] [PATCH] scsi-bus: fix endianness bug in store_lun() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. 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)