From nobody Wed Oct 22 13:04:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15197378628011023.9297377908401; Tue, 27 Feb 2018 05:24:22 -0800 (PST) Received: from localhost ([::1]:37066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqfEz-0006Yt-D4 for importer@patchew.org; Tue, 27 Feb 2018 08:24:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqfCr-00054v-58 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 08:22:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqfCp-00084e-Ud for qemu-devel@nongnu.org; Tue, 27 Feb 2018 08:22:09 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33446 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eqfCp-00083u-Q3; Tue, 27 Feb 2018 08:22:07 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6118940FB64A; Tue, 27 Feb 2018 13:22:07 +0000 (UTC) Received: from localhost (ovpn-117-77.ams2.redhat.com [10.36.117.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B132205D521; Tue, 27 Feb 2018 13:22:05 +0000 (UTC) From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 27 Feb 2018 14:21:26 +0100 Message-Id: <20180227132150.13847-3-cohuck@redhat.com> In-Reply-To: <20180227132150.13847-1-cohuck@redhat.com> References: <20180227132150.13847-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 27 Feb 2018 13:22:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 27 Feb 2018 13:22:07 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 02/26] s390-ccw: refactor eckd_block_num to use CHS 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: thuth@redhat.com, david@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, "Collin L. Walling" , rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Collin L. Walling" Add new cylinder/head/sector struct. Use it to calculate eckd block numbers instead of a BootMapPointer (which used eckd chs anyway). Signed-off-by: Collin L. Walling Reviewed-by: Thomas Huth Acked-by: Christian Borntraeger Signed-off-by: Thomas Huth --- pc-bios/s390-ccw/bootmap.c | 28 ++++++++++++++-------------- pc-bios/s390-ccw/bootmap.h | 8 ++++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index a4eaf24c8d..9534f56060 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -95,32 +95,32 @@ static inline void verify_boot_info(BootInfo *bip) "Bad block size in zIPL section of the 1st record."); } =20 -static block_number_t eckd_block_num(BootMapPointer *p) +static block_number_t eckd_block_num(EckdCHS *chs) { const uint64_t sectors =3D virtio_get_sectors(); const uint64_t heads =3D virtio_get_heads(); - const uint64_t cylinder =3D p->eckd.cylinder - + ((p->eckd.head & 0xfff0) << 12); - const uint64_t head =3D p->eckd.head & 0x000f; + const uint64_t cylinder =3D chs->cylinder + + ((chs->head & 0xfff0) << 12); + const uint64_t head =3D chs->head & 0x000f; const block_number_t block =3D sectors * heads * cylinder + sectors * head - + p->eckd.sector + + chs->sector - 1; /* block nr starts with zero */ return block; } =20 static bool eckd_valid_address(BootMapPointer *p) { - const uint64_t head =3D p->eckd.head & 0x000f; + const uint64_t head =3D p->eckd.chs.head & 0x000f; =20 if (head >=3D virtio_get_heads() - || p->eckd.sector > virtio_get_sectors() - || p->eckd.sector <=3D 0) { + || p->eckd.chs.sector > virtio_get_sectors() + || p->eckd.chs.sector <=3D 0) { return false; } =20 if (!virtio_guessed_disk_nature() && - eckd_block_num(p) >=3D virtio_get_blocks()) { + eckd_block_num(&p->eckd.chs) >=3D virtio_get_blocks()) { return false; } =20 @@ -140,7 +140,7 @@ static block_number_t load_eckd_segments(block_number_t= blk, uint64_t *address) do { more_data =3D false; for (j =3D 0;; j++) { - block_nr =3D eckd_block_num((void *)&(bprs[j].xeckd)); + block_nr =3D eckd_block_num(&bprs[j].xeckd.bptr.chs); if (is_null_block_number(block_nr)) { /* end of chunk */ break; } @@ -198,7 +198,7 @@ static void run_eckd_boot_script(block_number_t bmt_blo= ck_nr) memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(bmt_block_nr, sec, "Cannot read Boot Map Table"); =20 - block_nr =3D eckd_block_num(&bmt->entry[loadparm]); + block_nr =3D eckd_block_num(&bmt->entry[loadparm].xeckd.bptr.chs); IPL_assert(block_nr !=3D -1, "Cannot find Boot Map Table Entry"); =20 memset(sec, FREE_SPACE_FILLER, sizeof(sec)); @@ -206,7 +206,7 @@ static void run_eckd_boot_script(block_number_t bmt_blo= ck_nr) =20 for (i =3D 0; bms->entry[i].type =3D=3D BOOT_SCRIPT_LOAD; i++) { address =3D bms->entry[i].address.load_address; - block_nr =3D eckd_block_num(&(bms->entry[i].blkptr)); + block_nr =3D eckd_block_num(&bms->entry[i].blkptr.xeckd.bptr.chs); =20 do { block_nr =3D load_eckd_segments(block_nr, &address); @@ -239,7 +239,7 @@ static void ipl_eckd_cdl(void) "Non-ECKD device type in zIPL section of IPL2 record."); =20 /* save pointer to Boot Map Table */ - bmt_block_nr =3D eckd_block_num(&mbr->blockptr); + bmt_block_nr =3D eckd_block_num(&mbr->blockptr.xeckd.bptr.chs); =20 memset(sec, FREE_SPACE_FILLER, sizeof(sec)); read_block(2, vlbl, "Cannot read Volume Label at block 2"); @@ -300,7 +300,7 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode) verify_boot_info(bip); =20 /* save pointer to Boot Map Table */ - bmt_block_nr =3D eckd_block_num((void *)&bip->bp.ipl.bm_ptr.eckd.bptr); + bmt_block_nr =3D eckd_block_num(&bip->bp.ipl.bm_ptr.eckd.bptr.chs); =20 run_eckd_boot_script(bmt_block_nr); /* no return */ diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h index 486c0f34f1..b361084073 100644 --- a/pc-bios/s390-ccw/bootmap.h +++ b/pc-bios/s390-ccw/bootmap.h @@ -32,10 +32,14 @@ typedef struct FbaBlockPtr { uint16_t blockct; } __attribute__ ((packed)) FbaBlockPtr; =20 -typedef struct EckdBlockPtr { - uint16_t cylinder; /* cylinder/head/sector is an address of the block = */ +typedef struct EckdCHS { + uint16_t cylinder; uint16_t head; uint8_t sector; +} __attribute__ ((packed)) EckdCHS; + +typedef struct EckdBlockPtr { + EckdCHS chs; /* cylinder/head/sector is an address of the block */ uint16_t size; uint8_t count; /* (size_in_blocks-1); * it's 0 for TablePtr, ScriptPtr, and SectionPtr */ --=20 2.13.6