diff options
author | Hongxu Jia <hongxu.jia@windriver.com> | 2025-04-26 16:03:52 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-04-29 09:59:01 +0100 |
commit | 161ff4d39d13435f8c68d48b8b0800dc2faa8609 (patch) | |
tree | a483a1ed2d15a6fdbe6d7991258a5c415039dcc7 /meta | |
parent | 7ff5ecce289eb4d634600b53e3ae9874234fe8e6 (diff) | |
download | poky-161ff4d39d13435f8c68d48b8b0800dc2faa8609.tar.gz |
syslinux: improve isohybrid to process extra sector count for ISO 9660 image
Due to commit [cdrtools-native: fix booting EFI ISO live failed]
applied to improve mkisofs to fix nsectors exceeds 0xffff situation
which set selection criteria type = 2 and save extra nsectors to
vendor unique selection criteria
In following case, add 64MB extra space to bootable image efi.img,
and the partition table of EFI is truncated to 32M
$ echo 'IMAGE_FSTYPES:pn-core-image-minimal = " live"' >> conf/local.conf
$ echo 'MACHINE_FEATURES:append = " efi pcbios"' >> conf/local.conf
$ echo '# 64MB extra space to bootable image efi.img' >> conf/local.conf
$ echo 'BOOTIMG_EXTRA_SPACE = "65535"' >> conf/local.conf
$ bitbake core-image-minimal
$ fdisk -l tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso
...
Device Boot Start End Sectors Size Id Type
tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso1 * 0 376831 376832 184M 0 Empty
tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso2 120 65654 65535 32M ef EFI (FAT-12/16/32)
After applying this patch to process extra sector count, the partition
table of EFI is 90.3M
$ fdisk -l tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso
...
Device Boot Start End Sectors Size Id Type
tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso1 * 0 376831 376832 184M 0 Empty
tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso2 120 185151 185032 90.3M ef EFI (FAT-12/16/32)
[1]https://pdos.csail.mit.edu/6.828/2017/readings/boot-cdrom.pdf
(From OE-Core rev: b4e112ed7e6ba5a6c6df530d696485a588831851)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-devtools/syslinux/syslinux/0001-Add-extra-sector-count-from-section-entry-for-EFI-ca.patch | 104 | ||||
-rw-r--r-- | meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb | 1 |
2 files changed, 105 insertions, 0 deletions
diff --git a/meta/recipes-devtools/syslinux/syslinux/0001-Add-extra-sector-count-from-section-entry-for-EFI-ca.patch b/meta/recipes-devtools/syslinux/syslinux/0001-Add-extra-sector-count-from-section-entry-for-EFI-ca.patch new file mode 100644 index 0000000000..5422d9b2de --- /dev/null +++ b/meta/recipes-devtools/syslinux/syslinux/0001-Add-extra-sector-count-from-section-entry-for-EFI-ca.patch | |||
@@ -0,0 +1,104 @@ | |||
1 | From 79a26046d178ae132cb88ba75de7141bd169ff16 Mon Sep 17 00:00:00 2001 | ||
2 | From: Hongxu Jia <hongxu.jia@windriver.com> | ||
3 | Date: Sat, 26 Apr 2025 10:45:08 +0800 | ||
4 | Subject: [PATCH] Add extra sector count from section entry for EFI catalogue | ||
5 | |||
6 | According to page 11: `Figure 5 - Section Entry' in El Torito Bootable | ||
7 | CD-ROM Format Specification [1]. The sector count tooks 2 byte which | ||
8 | means max sector count is 0xffff (65535), for 512-byte sector, the | ||
9 | size of bootable image is no more than 32MB (65536 * 512 / 1024 / 1024) | ||
10 | |||
11 | If the size of efi.img > 32MB, the partition table will be truncated | ||
12 | in ISO, which caused UEFI system or grub-efi read efi.img broken | ||
13 | occasionally. | ||
14 | |||
15 | This patch extend efi_count, mac_count and count to 4 byte int, if | ||
16 | Yocto defines `Selection criteria type = 2', add extra sector count | ||
17 | to original sector count as total count; for other situation, still use | ||
18 | original sector count as usual | ||
19 | |||
20 | [1]https://pdos.csail.mit.edu/6.828/2017/readings/boot-cdrom.pdf | ||
21 | |||
22 | Upstream-Status: Inappropriate [Yocto specific] | ||
23 | |||
24 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
25 | --- | ||
26 | utils/isohybrid.c | 48 ++++++++++++++++++++++++++++++++++++++++++----- | ||
27 | 1 file changed, 43 insertions(+), 5 deletions(-) | ||
28 | |||
29 | diff --git a/utils/isohybrid.c b/utils/isohybrid.c | ||
30 | index a9e38d4..1bbfd45 100644 | ||
31 | --- a/utils/isohybrid.c | ||
32 | +++ b/utils/isohybrid.c | ||
33 | @@ -76,7 +76,7 @@ uint32_t de_lba = 0; | ||
34 | uint16_t de_seg = 0, de_count = 0, de_mbz2 = 0; | ||
35 | uint8_t de_boot = 0, de_media = 0, de_sys = 0, de_mbz1 = 0; | ||
36 | uint32_t efi_lba = 0, mac_lba = 0; | ||
37 | -uint16_t efi_count = 0, mac_count = 0; | ||
38 | +uint32_t efi_count = 0, mac_count = 0; | ||
39 | uint8_t efi_boot = 0, efi_media = 0, efi_sys = 0; | ||
40 | |||
41 | int apm_parts = 3; | ||
42 | @@ -552,17 +552,55 @@ read_efi_section(const uint8_t *buf) | ||
43 | } | ||
44 | |||
45 | int | ||
46 | -read_efi_catalogue(const uint8_t *buf, uint16_t *count, uint32_t *lba) | ||
47 | +read_efi_catalogue(const uint8_t *buf, uint32_t *count, uint32_t *lba) | ||
48 | { | ||
49 | + uint16_t _count = 0; | ||
50 | + | ||
51 | + // Jump to offset 6 byte | ||
52 | buf += 6; | ||
53 | |||
54 | - memcpy(count, buf, 2); | ||
55 | - *count = lendian_short(*count); | ||
56 | + *count = 0; | ||
57 | + | ||
58 | + // Offset : 6-7 byte | ||
59 | + // Type : Word | ||
60 | + // Description: Sector Count, the number of virtual/emulated sectors | ||
61 | + // the system will store at Load Segment during the initial boot procedure | ||
62 | + memcpy(&_count, buf, 2); | ||
63 | + _count = lendian_short(_count); | ||
64 | buf += 2; | ||
65 | |||
66 | + // Offset : 8-0B byte | ||
67 | + // Type : D Word | ||
68 | + // Description: Load RBA. This is the start address of the virtual disk. CD’s use | ||
69 | + // Relative/Logical block addressing. | ||
70 | memcpy(lba, buf, 4); | ||
71 | *lba = lendian_int(*lba); | ||
72 | - buf += 6; | ||
73 | + buf += 4; | ||
74 | + | ||
75 | + // Offset : 0C byte | ||
76 | + // Type : Byte | ||
77 | + // Description: Selection criteria type. This defines a vendor unique format | ||
78 | + // for bytes 0D-1F. | ||
79 | + // The following formats have currently been assigned: | ||
80 | + // 0 - No selection criteria | ||
81 | + // 1 - Language and Version Information (IBM) | ||
82 | + // 2 - Save extra sector count to vendor unique selection criteria (Yocto) | ||
83 | + // 3-FF - Reserved | ||
84 | + unsigned char slection_criteria_type = *buf; | ||
85 | + buf += 1; | ||
86 | + | ||
87 | + // Offset : 0D-0E-0F-10 byte | ||
88 | + // Type : D Word | ||
89 | + // Description: Selection criteria type = 2, reserved by Yocto, | ||
90 | + // save extra sector count to vendor unique selection criteria | ||
91 | + if (slection_criteria_type == 2) { | ||
92 | + memcpy(count, buf, 4); | ||
93 | + *count = lendian_int(*count); | ||
94 | + buf += 4; | ||
95 | + } | ||
96 | + | ||
97 | + // total count = sector count + extra sector count | ||
98 | + *count += _count; | ||
99 | |||
100 | return 0; | ||
101 | } | ||
102 | -- | ||
103 | 2.34.1 | ||
104 | |||
diff --git a/meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb b/meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb index 7cf737170c..2522205fa1 100644 --- a/meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb +++ b/meta/recipes-devtools/syslinux/syslinux_6.04-pre2.bb | |||
@@ -23,6 +23,7 @@ SRC_URI = "https://www.zytor.com/pub/syslinux/Testing/6.04/syslinux-${PV}.tar.xz | |||
23 | file://0013-remove-clean-script.patch \ | 23 | file://0013-remove-clean-script.patch \ |
24 | file://0014-Fix-reproducibility-issues.patch \ | 24 | file://0014-Fix-reproducibility-issues.patch \ |
25 | file://0001-ext2_fs.h-do-not-carry-an-outdated-copy.patch \ | 25 | file://0001-ext2_fs.h-do-not-carry-an-outdated-copy.patch \ |
26 | file://0001-Add-extra-sector-count-from-section-entry-for-EFI-ca.patch \ | ||
26 | " | 27 | " |
27 | 28 | ||
28 | SRC_URI[md5sum] = "2b31c78f087f99179feb357da312d7ec" | 29 | SRC_URI[md5sum] = "2b31c78f087f99179feb357da312d7ec" |