From patchwork Thu Feb 22 06:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kautuk Consul X-Patchwork-Id: 1903782 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=lL8E67Yc; 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4ThhxD4pnpz23q4 for ; Sat, 24 Feb 2024 20:52:00 +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=lL8E67Yc; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4ThhxD3mF0z3vZf for ; Sat, 24 Feb 2024 20:52:00 +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=lL8E67Yc; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=kconsul@linux.vnet.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 4TgN754myDz3cDy for ; Thu, 22 Feb 2024 17:10:57 +1100 (AEDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41M5adZc006771; Thu, 22 Feb 2024 06:10:55 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=DpQsqAgQyzMIfrcOFy9LNqTB/lK7iH0vLQhb5W0DTgE=; b=lL8E67Yc1eA6ZlDt+riCRc76/4GbYCkDVxZIt3TxTUpizr3gyL2eIqTDXXZ2bC0a933F KopdFG3aVg/GqYf2v/86yeRKt6U/0TaY8TwNuZu8qM1ErZK9M+284HiZSPMJn0gv8eJ0 32a8EVji9dhjuiv2QvWL5X9DJB1nCwt69R8A79HS11GljXe0Rd93I1M1MugNxLh4cum7 o530n6Dd3M+i/J86ib9KamC9XuyLmvWZsAm9MKo8HaYtGfX6uK2p7q4FLfhwbbDW0Auc neqYxC2jXs+sj5ZMQ1JDAxeX74OBGdgIJB/ZW4h9nUtvq47qaFMWOnkZsjfLN5Afbhvz MA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wdywt95g3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 06:10:54 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41M5cSGc012389; Thu, 22 Feb 2024 06:10:54 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wdywt95fj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 06:10:54 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41M2uAvL017278; Thu, 22 Feb 2024 06:10:53 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wb8mmm55q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Feb 2024 06:10:53 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41M6AnjP29164094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Feb 2024 06:10:51 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D94220043; Thu, 22 Feb 2024 06:10:49 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B4C120040; Thu, 22 Feb 2024 06:10:48 +0000 (GMT) Received: from r223l.aus.stglabs.ibm.com (unknown [9.3.109.14]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 22 Feb 2024 06:10:48 +0000 (GMT) From: Kautuk Consul To: aik@ozlabs.ru, Thomas Huth Date: Thu, 22 Feb 2024 01:10:46 -0500 Message-Id: <20240222061046.42572-1-kconsul@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9WupeTNAiK3fVRsJNtP7WPmTTLBwRJmX X-Proofpoint-ORIG-GUID: CnRcyRRZaXNL-LOOXcRMbz6s4kp1pRXQ 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-02-22_03,2024-02-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxlogscore=999 clxscore=1011 bulkscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402220046 X-Mailman-Approved-At: Sat, 24 Feb 2024 20:51:37 +1100 Subject: [SLOF] [PATCH] 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, Kautuk Consul , 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/slof/fs/packages/disk-label.fs b/slof/fs/packages/disk-label.fs index 661c6b0..e680847 100644 --- a/slof/fs/packages/disk-label.fs +++ b/slof/fs/packages/disk-label.fs @@ -139,6 +139,13 @@ CONSTANT /gpt-part-entry block block-size read drop \ read sector ; +\ read sector to array "block" and return actual bytes read +: read-sector-ret ( sector-number -- actual) + \ block-size is 0x200 on disks, 0x800 on cdrom drives + block-size * 0 seek drop \ seek to sector + block block-size read \ read sector +; + : (.part-entry) ( part-entry ) cr ." part-entry>active: " dup part-entry>active c@ .d cr ." part-entry>start-head: " dup part-entry>start-head c@ .d @@ -204,7 +211,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 0 EXIT THEN 1 partition>start-sector IF \ ." Logical Partition found at " part-start .d cr 1+ @@ -279,6 +287,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 +361,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 0 EXIT THEN debug-disk-label? IF ." Found " dos-logical-partitions .d ." logical partitions" cr