From patchwork Wed Mar 27 05:41:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kautuk Consul X-Patchwork-Id: 1916562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=r8gVZHr7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V4KKT1z7Qz1yWr for ; Wed, 27 Mar 2024 19:17:33 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=r8gVZHr7; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4V4KKS3BLsz3dX1 for ; Wed, 27 Mar 2024 19:17:32 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=r8gVZHr7; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=kconsul@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4V4Fsq48LBz3d2N for ; Wed, 27 Mar 2024 16:41:50 +1100 (AEDT) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42R5O4TL008151; Wed, 27 Mar 2024 05:41:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=3l9iS3MtSGpR7wiIu0RVx0B8HU5DRJfQgew6/h52ZdI=; b=r8gVZHr7VNH2PoXqHwVebg9W/4U17lmpLJcX4AeM+6A0uOB0lOB6ha7TEDTEWxC29q+w lnUhEAXiytCTS85eCTz+shRxT2cBgi+gn8u0cYZjMk7iQgeGmLVqJJHPYwwe+YhcKVd5 VssOYqeMdB6GO8OcVrRDTKQeWtrWrlV9zmqIDLqa8F29bxw5Vznc/TuT21HvdD4E7XKT 3uP5IDLzgkklvX0STNIy8d+OtM0JqFDDANAKbJHe3vCGzyjJfdFJ0Tp6TkhnP6S1+G75 oaZh+/uJ3ew41+7YoI5spQgBP62W1l3DtOggcSdR6jgnQjYUhg2TkD7uzmbGQbkqyb3m zA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x49xwrb1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 05:41:47 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42R5cgaY030490; Wed, 27 Mar 2024 05:41:47 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3x49xwrb1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 05:41:47 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42R4x2ZO011238; Wed, 27 Mar 2024 05:41:46 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3x2bmm4a11-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 05:41:46 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42R5fgPu46858646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Mar 2024 05:41:44 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A6782004B; Wed, 27 Mar 2024 05:41:42 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF5602004E; Wed, 27 Mar 2024 05:41:41 +0000 (GMT) Received: from r223l.aus.stglabs.ibm.com (unknown [9.3.109.14]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 27 Mar 2024 05:41:41 +0000 (GMT) From: Kautuk Consul To: aik@ozlabs.ru, Thomas Huth Date: Wed, 27 Mar 2024 01:41:27 -0400 Message-Id: <20240327054127.633598-1-kconsul@linux.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: IDU1BiyWz2R2RD2JdEwINYxH87iVs0FJ X-Proofpoint-GUID: BTmey7mRh6cXOxQ9AOZLpGDZAgLR0KSm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-27_02,2024-03-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 bulkscore=0 malwarescore=0 clxscore=1011 adultscore=0 phishscore=0 mlxscore=0 impostorscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403270036 X-Mailman-Approved-At: Wed, 27 Mar 2024 19:17:30 +1100 Subject: [SLOF] [PATCH v3] slof/fs/packages/disk-label.fs: improve checking for DOS boot partitions X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: slof@lists.ozlabs.org, kvm-ppc@vger.kernel.org Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" While testing with a qcow2 with a DOS boot partition it was found that when we set the logical_block_size in the guest XML to >512 then the boot would fail in the following interminable loop: Trying to load: from: /pci@800000020000000/scsi@3 ... virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! Change the count-dos-logical-partitions Forth subroutine and the Forth subroutines calling count-dos-logical-partitions to check for this access beyond end of device error. After making the above changes, it fails properly with the correct error message as follows: Trying to load: from: /pci@800000020000000/scsi@3 ... virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! virtioblk_transfer: Access beyond end of device! E3404: Not a bootable device! E3407: Load failed Type 'boot' and press return to continue booting the system. Type 'reset-all' and press return to reboot the system. Ready! 0 > Signed-off-by: Kautuk Consul --- slof/fs/packages/disk-label.fs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/slof/fs/packages/disk-label.fs b/slof/fs/packages/disk-label.fs index 661c6b0..fa15982 100644 --- a/slof/fs/packages/disk-label.fs +++ b/slof/fs/packages/disk-label.fs @@ -132,11 +132,16 @@ CONSTANT /gpt-part-entry debug-disk-label? IF dup ." actual=" .d cr THEN ; -\ read sector to array "block" -: read-sector ( sector-number -- ) +\ read sector to array "block" and return actual bytes read +: read-sector-ret ( sector-number -- actual-bytes ) \ block-size is 0x200 on disks, 0x800 on cdrom drives block-size * 0 seek drop \ seek to sector - block block-size read drop \ read sector + block block-size read \ read sector +; + +\ read sector to array "block" +: read-sector ( sector-number -- ) + read-sector-ret drop ; : (.part-entry) ( part-entry ) @@ -204,7 +209,8 @@ CONSTANT /gpt-part-entry part-entry>sector-offset l@-le ( current sector ) dup to part-start to lpart-start ( current ) BEGIN - part-start read-sector \ read EBR + part-start read-sector-ret \ read EBR + block-size < IF UNLOOP drop 0 EXIT THEN 1 partition>start-sector IF \ ." Logical Partition found at " part-start .d cr 1+ @@ -279,6 +285,7 @@ CONSTANT /gpt-part-entry THEN count-dos-logical-partitions TO dos-logical-partitions + dos-logical-partitions 0= IF false EXIT THEN debug-disk-label? IF ." Found " dos-logical-partitions .d ." logical partitions" cr @@ -352,6 +359,7 @@ CONSTANT /gpt-part-entry no-mbr? IF drop FALSE EXIT THEN \ read MBR and check for DOS disk-label magic count-dos-logical-partitions TO dos-logical-partitions + dos-logical-partitions 0= IF drop 0 EXIT THEN debug-disk-label? IF ." Found " dos-logical-partitions .d ." logical partitions" cr