From patchwork Wed Jun 18 12:16:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 361444 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 96C0D140076 for ; Wed, 18 Jun 2014 22:19:26 +1000 (EST) Received: from localhost ([::1]:56930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxEpo-0007pr-Hx for incoming@patchwork.ozlabs.org; Wed, 18 Jun 2014 08:19:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxEnx-0005Gb-1d for qemu-devel@nongnu.org; Wed, 18 Jun 2014 08:17:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxEnn-0003Jr-QQ for qemu-devel@nongnu.org; Wed, 18 Jun 2014 08:17:28 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:57440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxEnn-0003Jf-Ie for qemu-devel@nongnu.org; Wed, 18 Jun 2014 08:17:19 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Jun 2014 13:17:18 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Jun 2014 13:17:14 +0100 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 8E92E17D8059 for ; Wed, 18 Jun 2014 13:18:38 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5ICHE6322478878 for ; Wed, 18 Jun 2014 12:17:14 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5ICHCKQ029091 for ; Wed, 18 Jun 2014 06:17:13 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s5ICHBTx029062; Wed, 18 Jun 2014 06:17:11 -0600 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 1122) id A909F1224439; Wed, 18 Jun 2014 14:17:11 +0200 (CEST) From: Jens Freimann To: Christian Borntraeger , Alexander Graf , Cornelia Huck Date: Wed, 18 Jun 2014 14:16:46 +0200 Message-Id: <1403093807-32836-4-git-send-email-jfrei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1403093807-32836-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1403093807-32836-1-git-send-email-jfrei@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14061812-2966-0000-0000-0000003DE602 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.109 Cc: "Eugene \(jno\) Dvurechenski" , Jens Freimann , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/4] pc-bios/s390-ccw: fix for fragmented SCSI bootmap 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" We need to interpret the last entry of the bootmap with zero block count as "continuation pointer". The "last entry" is being detected by pre-filling of the scratch space with known values and respective look-ahead. Signed-off-by: Eugene (jno) Dvurechenski Signed-off-by: Jens Freimann Tested-by: Christian Borntraeger Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck --- pc-bios/s390-ccw/bootmap.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index c07553b..5ee3fcb 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -118,10 +118,26 @@ static int zipl_magic(uint8_t *ptr) return 1; } +#define FREE_SPACE_FILLER '\xAA' + +static inline bool unused_space(const void *p, unsigned int size) +{ + int i; + const unsigned char *m = p; + + for (i = 0; i < size; i++) { + if (m[i] != FREE_SPACE_FILLER) { + return false; + } + } + return true; +} + static int zipl_load_segment(struct component_entry *entry) { const int max_entries = (SECTOR_SIZE / sizeof(struct scsi_blockptr)); struct scsi_blockptr *bprs = (void*)sec; + const int bprs_size = sizeof(sec); uint64_t blockno; long address; int i; @@ -133,6 +149,7 @@ static int zipl_load_segment(struct component_entry *entry) debug_print_int("addr", address); do { + memset(bprs, FREE_SPACE_FILLER, bprs_size); if (virtio_read(blockno, (uint8_t *)bprs)) { debug_print_int("failed reading bprs at", blockno); goto fail; @@ -150,6 +167,16 @@ static int zipl_load_segment(struct component_entry *entry) if (i == (max_entries - 1)) break; + if (bprs[i].blockct == 0 && unused_space(&bprs[i + 1], + sizeof(struct scsi_blockptr))) { + /* This is a "continue" pointer. + * This ptr is the last one in the current script section. + * I.e. the next ptr must point to the unused memory area. + * The blockno is not zero, so the upper loop must continue + * reading next section of BPRS. + */ + break; + } address = virtio_load_direct(cur_desc[0], cur_desc[1], 0, (void*)address); if (address == -1)