From patchwork Tue May 2 13:36:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 757601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wHMpV1cYsz9s7C for ; Tue, 2 May 2017 23:39:30 +1000 (AEST) Received: from localhost ([::1]:58907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5Y1X-0003VM-KK for incoming@patchwork.ozlabs.org; Tue, 02 May 2017 09:39:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5Xyh-0001Qn-Kl for qemu-devel@nongnu.org; Tue, 02 May 2017 09:36:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5Xye-0001rw-H1 for qemu-devel@nongnu.org; Tue, 02 May 2017 09:36:31 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d5Xye-0001ri-8r for qemu-devel@nongnu.org; Tue, 02 May 2017 09:36:28 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v42DYK32031163 for ; Tue, 2 May 2017 09:36:27 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a6q0n54jt-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 02 May 2017 09:36:27 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 May 2017 14:36:24 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 2 May 2017 14:36:22 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v42DaLcp17695168; Tue, 2 May 2017 13:36:21 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8841CA4082; Tue, 2 May 2017 14:35:08 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EDE1A4065; Tue, 2 May 2017 14:35:08 +0100 (BST) Received: from gondolin.boeblingen.de.ibm.com (unknown [9.152.224.119]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 2 May 2017 14:35:08 +0100 (BST) From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 2 May 2017 15:36:04 +0200 X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170502133604.17735-1-cornelia.huck@de.ibm.com> References: <20170502133604.17735-1-cornelia.huck@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17050213-0040-0000-0000-0000039B01DF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050213-0041-0000-0000-00001FF1B970 Message-Id: <20170502133604.17735-13-cornelia.huck@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-02_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705020077 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 12/12] hw/s390x/ipl: Fix crash with virtio-scsi-pci device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , borntraeger@de.ibm.com, Thomas Huth , agraf@suse.de, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth qemu-system-s390x currently crashes when it is started with a virtio-scsi-pci device, e.g.: qemu-system-s390x -nographic -enable-kvm -device virtio-scsi-pci \ -drive file=/tmp/disk.dat,if=none,id=d1,format=raw \ -device scsi-cd,drive=d1,bootindex=1 The problem is that the code in s390_gen_initial_iplb() currently assumes that all SCSI devices are also CCW devices, which is not the case for virtio-scsi-pci of course. Fix it by adding an appropriate check for TYPE_CCW_DEVICE here. Signed-off-by: Thomas Huth Signed-off-by: Christian Borntraeger Message-Id: <1493126327-13162-1-git-send-email-thuth@redhat.com> Reviewed-by: Christian Borntraeger Signed-off-by: Cornelia Huck --- hw/s390x/ipl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 0711ee927a..75d3c681a4 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -249,7 +249,13 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) SCSIBus *bus = scsi_bus_from_device(sd); VirtIOSCSI *vdev = container_of(bus, VirtIOSCSI, bus); VirtIOSCSICcw *scsi_ccw = container_of(vdev, VirtIOSCSICcw, vdev); - CcwDevice *ccw_dev = CCW_DEVICE(scsi_ccw); + CcwDevice *ccw_dev; + + ccw_dev = (CcwDevice *)object_dynamic_cast(OBJECT(scsi_ccw), + TYPE_CCW_DEVICE); + if (!ccw_dev) { /* It might be a PCI device instead */ + return false; + } ipl->iplb.len = cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN); ipl->iplb.blk0_len =