From: Kautuk Consul <kconsul@linux.vnet.ibm.com>
To: aik@ozlabs.ru, Thomas Huth <thuth@redhat.com>
Cc: slof@lists.ozlabs.org, kvm-ppc@vger.kernel.org,
Kautuk Consul <kconsul@linux.vnet.ibm.com>
Subject: [PATCH] slof/fs/packages/disk-label.fs: improve checking for DOS boot partitions
Date: Thu, 22 Feb 2024 01:10:46 -0500 [thread overview]
Message-ID: <20240222061046.42572-1-kconsul@linux.vnet.ibm.com> (raw)
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:
<SNIP>
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!
</SNIP>
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:
<SNIP>
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 >
</SNIP>
Signed-off-by: Kautuk Consul <kconsul@linux.vnet.ibm.com>
---
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
--
2.31.1
next reply other threads:[~2024-02-22 6:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 6:10 Kautuk Consul [this message]
2024-03-07 6:35 ` [PATCH] slof/fs/packages/disk-label.fs: improve checking for DOS boot partitions Kautuk Consul
2024-03-18 5:14 ` Kautuk Consul
2024-03-18 10:12 ` Thomas Huth
2024-04-04 0:44 ` Alexey Kardashevskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240222061046.42572-1-kconsul@linux.vnet.ibm.com \
--to=kconsul@linux.vnet.ibm.com \
--cc=aik@ozlabs.ru \
--cc=kvm-ppc@vger.kernel.org \
--cc=slof@lists.ozlabs.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).