From nobody Sun Feb 8 17:04:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165606260733694.2837336320747; Fri, 24 Jun 2022 02:23:27 -0700 (PDT) Received: from localhost ([::1]:54556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4fXB-0002Yo-J0 for importer@patchew.org; Fri, 24 Jun 2022 05:23:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4f1k-0004SC-AJ for qemu-devel@nongnu.org; Fri, 24 Jun 2022 04:50:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4f1h-0000cO-Dv for qemu-devel@nongnu.org; Fri, 24 Jun 2022 04:50:56 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-542-0459Pz4OML-gNPNpCyjJNw-1; Fri, 24 Jun 2022 04:50:48 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2D4A3C17300; Fri, 24 Jun 2022 08:50:47 +0000 (UTC) Received: from thuth.com (unknown [10.39.195.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCCB740334F; Fri, 24 Jun 2022 08:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656060651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4XXn1OIdkndJpaLggvfVr8ryIuyu6eDfWM7T0X5CZSk=; b=hUyvm6XbAuyzhtwYjQztRioZlBEHQMJUq8IsGbIUzQ5xy4798g6uTtH0CQDNn/zJFSdrbf 45jh2wydIW0mqZW/5tfG8Ew2RV60zt4zN7x85l3+oPXBft+z2IO4ElV23aPAlB597WznaF 5Y0punzOJRM44rnG11Ygg2X8ReWBLbU= X-MC-Unique: 0459Pz4OML-gNPNpCyjJNw-1 From: Thomas Huth To: qemu-s390x@nongnu.org, Eric Farman Cc: qemu-devel@nongnu.org, Christian Borntraeger Subject: [PATCH 1/2] pc-bios/s390-ccw/virtio-blkdev: Simplify/fix virtio_ipl_disk_is_valid() Date: Fri, 24 Jun 2022 10:50:36 +0200 Message-Id: <20220624085037.612235-2-thuth@redhat.com> In-Reply-To: <20220624085037.612235-1-thuth@redhat.com> References: <20220624085037.612235-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1656062609316100001 Content-Type: text/plain; charset="utf-8" The s390-ccw bios fails to boot if the boot disk is a virtio-blk disk with a sector size of 4096. For example: dasdfmt -b 4096 -d cdl -y -p -M quick /dev/dasdX fdasd -a /dev/dasdX install a guest onto /dev/dasdX1 using virtio-blk qemu-system-s390x -nographic -hda /dev/dasdX1 The bios then bails out with: ! Cannot read block 0 ! Looking at virtio_ipl_disk_is_valid() and especially the function virtio_disk_is_scsi(), it does not really make sense that we expect only such a limited disk geometry (like a block size of 512) for out boot disks. Let's relax the check and allow everything that remotely looks like a sane disk. Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/virtio.h | 2 -- pc-bios/s390-ccw/virtio-blkdev.c | 41 ++++++-------------------------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index 19fceb6495..07fdcabd9f 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -186,8 +186,6 @@ void virtio_assume_scsi(void); void virtio_assume_eckd(void); void virtio_assume_iso9660(void); =20 -extern bool virtio_disk_is_scsi(void); -extern bool virtio_disk_is_eckd(void); extern bool virtio_ipl_disk_is_valid(void); extern int virtio_get_block_size(void); extern uint8_t virtio_get_heads(void); diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blk= dev.c index 7d35050292..b5506bb29d 100644 --- a/pc-bios/s390-ccw/virtio-blkdev.c +++ b/pc-bios/s390-ccw/virtio-blkdev.c @@ -166,46 +166,19 @@ void virtio_assume_eckd(void) virtio_eckd_sectors_for_block_size(vdev->config.blk.blk_size); } =20 -bool virtio_disk_is_scsi(void) -{ - VDev *vdev =3D virtio_get_device(); - - if (vdev->guessed_disk_nature =3D=3D VIRTIO_GDN_SCSI) { - return true; - } - switch (vdev->senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return (vdev->config.blk.geometry.heads =3D=3D 255) - && (vdev->config.blk.geometry.sectors =3D=3D 63) - && (virtio_get_block_size() =3D=3D VIRTIO_SCSI_BLOCK_SIZE); - case VIRTIO_ID_SCSI: - return true; - } - return false; -} - -bool virtio_disk_is_eckd(void) +bool virtio_ipl_disk_is_valid(void) { + int blksize =3D virtio_get_block_size(); VDev *vdev =3D virtio_get_device(); - const int block_size =3D virtio_get_block_size(); =20 - if (vdev->guessed_disk_nature =3D=3D VIRTIO_GDN_DASD) { + if (vdev->guessed_disk_nature =3D=3D VIRTIO_GDN_SCSI || + vdev->guessed_disk_nature =3D=3D VIRTIO_GDN_DASD) { return true; } - switch (vdev->senseid.cu_model) { - case VIRTIO_ID_BLOCK: - return (vdev->config.blk.geometry.heads =3D=3D 15) - && (vdev->config.blk.geometry.sectors =3D=3D - virtio_eckd_sectors_for_block_size(block_size)); - case VIRTIO_ID_SCSI: - return false; - } - return false; -} =20 -bool virtio_ipl_disk_is_valid(void) -{ - return virtio_disk_is_scsi() || virtio_disk_is_eckd(); + return (vdev->senseid.cu_model =3D=3D VIRTIO_ID_BLOCK || + vdev->senseid.cu_model =3D=3D VIRTIO_ID_SCSI) && + blksize >=3D 512 && blksize <=3D 4096; } =20 int virtio_get_block_size(void) --=20 2.31.1 From nobody Sun Feb 8 17:04:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1656062314091695.1542148795434; Fri, 24 Jun 2022 02:18:34 -0700 (PDT) Received: from localhost ([::1]:45672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4fSS-0004gT-NF for importer@patchew.org; Fri, 24 Jun 2022 05:18:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4f1l-0004SB-56 for qemu-devel@nongnu.org; Fri, 24 Jun 2022 04:50:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4f1h-0000cl-Mk for qemu-devel@nongnu.org; Fri, 24 Jun 2022 04:50:56 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-7-w_OGnBK3MAywTInPH4U8Zw-1; Fri, 24 Jun 2022 04:50:50 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5E981044561; Fri, 24 Jun 2022 08:50:49 +0000 (UTC) Received: from thuth.com (unknown [10.39.195.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC2B0416171; Fri, 24 Jun 2022 08:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656060653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=55hGLXhOR2nDCAeVvl7yrXQsnj+f1eWR4ThmVybT+g4=; b=iSe1HSMBlW5tjFxj4CEsx5Y9lcmUawxEEEfQWuTzY0/HYORblgXkzAJMZf3Dc2wMJ4rzTx PieHqdFSmtXISj0Z9QD9He4YmLIHM/BUKrjGGCn3zTzXmpTs9C7hUDZTk1iTNcCSrB0CVK unSpDi2CffhgbLN8MSPLlDszk4jvGE8= X-MC-Unique: w_OGnBK3MAywTInPH4U8Zw-1 From: Thomas Huth To: qemu-s390x@nongnu.org, Eric Farman Cc: qemu-devel@nongnu.org, Christian Borntraeger Subject: [PATCH 2/2] pc-bios/s390-ccw/virtio-blkdev: Remove virtio_assume_scsi() Date: Fri, 24 Jun 2022 10:50:37 +0200 Message-Id: <20220624085037.612235-3-thuth@redhat.com> In-Reply-To: <20220624085037.612235-1-thuth@redhat.com> References: <20220624085037.612235-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1656062316416100001 Content-Type: text/plain; charset="utf-8" The virtio_assume_scsi() function is very questionable: First, it is only called for virtio-blk, and not for virtio-scsi, so the naming is already quite confusing. Second, it is called if we detected a "invalid" IPL disk, trying to fix it by blindly setting a sector size of 512. This of course won't work in most cases since disks might have a different sector size for a reason. Thus let's remove this strange function now. The calling code can also be removed completely, since there is another spot in main.c that does "IPL_assert(virtio_ipl_disk_is_valid(), ...)" to make sure that we do not try to IPL from an invalid device. Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/virtio-blkdev.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blk= dev.c index b5506bb29d..9ba28c6f54 100644 --- a/pc-bios/s390-ccw/virtio-blkdev.c +++ b/pc-bios/s390-ccw/virtio-blkdev.c @@ -112,23 +112,6 @@ VirtioGDN virtio_guessed_disk_nature(void) return virtio_get_device()->guessed_disk_nature; } =20 -void virtio_assume_scsi(void) -{ - VDev *vdev =3D virtio_get_device(); - - switch (vdev->senseid.cu_model) { - case VIRTIO_ID_BLOCK: - vdev->guessed_disk_nature =3D VIRTIO_GDN_SCSI; - vdev->config.blk.blk_size =3D VIRTIO_SCSI_BLOCK_SIZE; - vdev->config.blk.physical_block_exp =3D 0; - vdev->blk_factor =3D 1; - break; - case VIRTIO_ID_SCSI: - vdev->scsi_block_size =3D VIRTIO_SCSI_BLOCK_SIZE; - break; - } -} - void virtio_assume_iso9660(void) { VDev *vdev =3D virtio_get_device(); @@ -247,13 +230,6 @@ int virtio_blk_setup_device(SubChannelId schid) switch (vdev->senseid.cu_model) { case VIRTIO_ID_BLOCK: sclp_print("Using virtio-blk.\n"); - if (!virtio_ipl_disk_is_valid()) { - /* make sure all getters but blocksize return 0 for - * invalid IPL disk - */ - memset(&vdev->config.blk, 0, sizeof(vdev->config.blk)); - virtio_assume_scsi(); - } break; case VIRTIO_ID_SCSI: IPL_assert(vdev->config.scsi.sense_size =3D=3D VIRTIO_SCSI_SENSE_S= IZE, --=20 2.31.1