From patchwork Fri Aug 29 09:01:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 384099 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 9FDDA140092 for ; Fri, 29 Aug 2014 19:04:52 +1000 (EST) Received: from localhost ([::1]:40776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNI6x-0002kv-5c for incoming@patchwork.ozlabs.org; Fri, 29 Aug 2014 05:04:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNI4K-0006UK-0g for qemu-devel@nongnu.org; Fri, 29 Aug 2014 05:02:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNI4A-0006MC-GP for qemu-devel@nongnu.org; Fri, 29 Aug 2014 05:02:03 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:36015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNI4A-0006Lp-8n for qemu-devel@nongnu.org; Fri, 29 Aug 2014 05:01:54 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 29 Aug 2014 10:01:53 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 29 Aug 2014 10:01:50 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 62B5517D804E for ; Fri, 29 Aug 2014 10:03:45 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s7T91ngw38076530 for ; Fri, 29 Aug 2014 09:01:49 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s7T91mDU009664 for ; Fri, 29 Aug 2014 03:01:49 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s7T91lMq009653; Fri, 29 Aug 2014 03:01:47 -0600 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 1122) id BEC4B122443E; Fri, 29 Aug 2014 11:01:47 +0200 (CEST) From: Jens Freimann To: Christian Borntraeger , Alexander Graf , Cornelia Huck Date: Fri, 29 Aug 2014 11:01:39 +0200 Message-Id: <1409302902-57391-5-git-send-email-jfrei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1409302902-57391-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1409302902-57391-1-git-send-email-jfrei@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14082909-3548-0000-0000-0000012F3957 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.112 Cc: "Eugene \(jno\) Dvurechenski" , Jens Freimann , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 4/7] pc-bios/s390-ccw Really big EAV ECKD DASD handling 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 From: "Eugene (jno) Dvurechenski" For EAV ECKD DASD, the cylinder count will have the magic value 0xfffeU. Therefore, use the block number to test for valid eckd addresses instead. Signed-off-by: Eugene (jno) Dvurechenski Acked-by: Cornelia Huck Acked-by: Christian Borntraeger Reviewed-by: David Hildenbrand Signed-off-by: Jens Freimann --- pc-bios/s390-ccw/bootmap.c | 31 +++++++++++++++---------------- pc-bios/s390-ccw/virtio.c | 11 ++++++----- pc-bios/s390-ccw/virtio.h | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index e4352b1..d4c579c 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -93,11 +93,23 @@ static inline void verify_boot_info(BootInfo *bip) "Bad block size in zIPL section of the 1st record."); } -static bool eckd_valid_address(BootMapPointer *p) +static block_number_t eckd_block_num(BootMapPointer *p) { + const uint64_t sectors = virtio_get_sectors(); + const uint64_t heads = virtio_get_heads(); const uint64_t cylinder = p->eckd.cylinder + ((p->eckd.head & 0xfff0) << 12); const uint64_t head = p->eckd.head & 0x000f; + const block_number_t block = sectors * heads * cylinder + + sectors * head + + p->eckd.sector + - 1; /* block nr starts with zero */ + return block; +} + +static bool eckd_valid_address(BootMapPointer *p) +{ + const uint64_t head = p->eckd.head & 0x000f; if (head >= virtio_get_heads() || p->eckd.sector > virtio_get_sectors() @@ -105,27 +117,14 @@ static bool eckd_valid_address(BootMapPointer *p) return false; } - if (!virtio_guessed_disk_nature() && cylinder >= virtio_get_cylinders()) { + if (!virtio_guessed_disk_nature() && + eckd_block_num(p) >= virtio_get_blocks()) { return false; } return true; } -static block_number_t eckd_block_num(BootMapPointer *p) -{ - const uint64_t sectors = virtio_get_sectors(); - const uint64_t heads = virtio_get_heads(); - const uint64_t cylinder = p->eckd.cylinder - + ((p->eckd.head & 0xfff0) << 12); - const uint64_t head = p->eckd.head & 0x000f; - const block_number_t block = sectors * heads * cylinder - + sectors * head - + p->eckd.sector - - 1; /* block nr starts with zero */ - return block; -} - static block_number_t load_eckd_segments(block_number_t blk, uint64_t *address) { block_number_t block_nr; diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c index 6ed3dc9..c0540d1 100644 --- a/pc-bios/s390-ccw/virtio.c +++ b/pc-bios/s390-ccw/virtio.c @@ -340,11 +340,6 @@ int virtio_get_block_size(void) return blk_cfg.blk_size << blk_cfg.physical_block_exp; } -uint16_t virtio_get_cylinders(void) -{ - return blk_cfg.geometry.cylinders; -} - uint8_t virtio_get_heads(void) { return blk_cfg.geometry.heads; @@ -355,6 +350,12 @@ uint8_t virtio_get_sectors(void) return blk_cfg.geometry.sectors; } +uint64_t virtio_get_blocks(void) +{ + return blk_cfg.capacity / + (virtio_get_block_size() / VIRTIO_SECTOR_SIZE); +} + void virtio_setup_block(struct subchannel_id schid) { struct vq_info_block info; diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index f1fb1b0..c23466b 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -192,9 +192,9 @@ 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 uint16_t virtio_get_cylinders(void); extern uint8_t virtio_get_heads(void); extern uint8_t virtio_get_sectors(void); +extern uint64_t virtio_get_blocks(void); extern int virtio_read_many(ulong sector, void *load_addr, int sec_num); #define VIRTIO_SECTOR_SIZE 512