From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwZdZ-00062H-Kp for qemu-devel@nongnu.org; Wed, 11 Nov 2015 12:57:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwZdP-0004hx-Tr for qemu-devel@nongnu.org; Wed, 11 Nov 2015 12:56:49 -0500 Received: from e06smtp08.uk.ibm.com ([195.75.94.104]:33466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwZdP-0004ga-JA for qemu-devel@nongnu.org; Wed, 11 Nov 2015 12:56:39 -0500 Received: from localhost by e06smtp08.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Nov 2015 17:56:38 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 961EC17D805A for ; Wed, 11 Nov 2015 17:56:55 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tABHuaF265077392 for ; Wed, 11 Nov 2015 17:56:36 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tABGubLq014854 for ; Wed, 11 Nov 2015 09:56:37 -0700 From: Cornelia Huck Date: Wed, 11 Nov 2015 18:56:19 +0100 Message-Id: <1447264593-14625-2-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1447264593-14625-1-git-send-email-cornelia.huck@de.ibm.com> References: <1447264593-14625-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PULL for-2.5 01/15] s390x/css: sense data endianness List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: Cornelia Huck , borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, qemu-devel@nongnu.org, agraf@suse.de We keep the device's sense data in a byte array (following the architecture), but the ecws are an array of 32 bit values. If we just blindly copy the values, the sense data will change from de-facto BE data to de-facto cpu-endian data, which means we end up doing an incorrect conversion on LE hosts. Let's just explicitly convert to cpu-endianness while assembling the irb. Reported-by: Andy Lutomirski Tested-by: Andy Lutomirski Signed-off-by: Cornelia Huck Reviewed-by: Christian Borntraeger --- hw/s390x/css.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index c033612..19851ce 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -892,8 +892,14 @@ int css_do_tsch_get_irb(SubchDev *sch, IRB *target_irb, int *irb_len) /* If a unit check is pending, copy sense data. */ if ((s->dstat & SCSW_DSTAT_UNIT_CHECK) && (p->chars & PMCW_CHARS_MASK_CSENSE)) { + int i; + irb.scsw.flags |= SCSW_FLAGS_MASK_ESWF | SCSW_FLAGS_MASK_ECTL; + /* Attention: sense_data is already BE! */ memcpy(irb.ecw, sch->sense_data, sizeof(sch->sense_data)); + for (i = 0; i < ARRAY_SIZE(irb.ecw); i++) { + irb.ecw[i] = be32_to_cpu(irb.ecw[i]); + } irb.esw[1] = 0x01000000 | (sizeof(sch->sense_data) << 8); } } -- 2.6.3