From aa423f2bc610daab9ad75e120e86bb1281a97c46 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Tue, 18 Oct 2022 14:12:46 -0400 Subject: [PATCH 01/12] freescale: Remove Rajesh Bhagat MAINTAINERS Rajesh's email bounces. Remove his email from all boards he maintains. Fortunately, he has co-maintainers on most boards. I have taken the liberty of volunteering Pramod to maintain the LS1012AFRDM, since he also maintains the LS1012AFRWY. Let me know if the board should be orphaned instead. Signed-off-by: Sean Anderson --- board/freescale/ls1012afrdm/MAINTAINERS | 2 +- board/freescale/ls1012aqds/MAINTAINERS | 1 - board/freescale/ls1012ardb/MAINTAINERS | 1 - board/freescale/ls1028a/MAINTAINERS | 2 -- board/freescale/ls1043aqds/MAINTAINERS | 1 - board/freescale/ls1043ardb/MAINTAINERS | 1 - board/freescale/ls1046aqds/MAINTAINERS | 1 - board/freescale/ls1046ardb/MAINTAINERS | 1 - board/freescale/ls1088a/MAINTAINERS | 2 -- board/freescale/ls2080aqds/MAINTAINERS | 1 - board/freescale/ls2080ardb/MAINTAINERS | 1 - 11 files changed, 1 insertion(+), 13 deletions(-) diff --git a/board/freescale/ls1012afrdm/MAINTAINERS b/board/freescale/ls1012afrdm/MAINTAINERS index 5fc7e93850e..89d1085b00b 100644 --- a/board/freescale/ls1012afrdm/MAINTAINERS +++ b/board/freescale/ls1012afrdm/MAINTAINERS @@ -1,5 +1,5 @@ LS1012AFRDM BOARD -M: Rajesh Bhagat +M: Pramod Kumar S: Maintained F: board/freescale/ls1012afrdm/ F: include/configs/ls1012afrdm.h diff --git a/board/freescale/ls1012aqds/MAINTAINERS b/board/freescale/ls1012aqds/MAINTAINERS index c1bb8d51508..eabf5805765 100644 --- a/board/freescale/ls1012aqds/MAINTAINERS +++ b/board/freescale/ls1012aqds/MAINTAINERS @@ -1,5 +1,4 @@ LS1012AQDS BOARD -M: Rajesh Bhagat M: Pramod Kumar S: Maintained F: board/freescale/ls1012aqds/ diff --git a/board/freescale/ls1012ardb/MAINTAINERS b/board/freescale/ls1012ardb/MAINTAINERS index b0c008b5fc9..ce2f9a16cc7 100644 --- a/board/freescale/ls1012ardb/MAINTAINERS +++ b/board/freescale/ls1012ardb/MAINTAINERS @@ -1,5 +1,4 @@ LS1012ARDB BOARD -M: Rajesh Bhagat M: Pramod Kumar S: Maintained F: board/freescale/ls1012ardb/ diff --git a/board/freescale/ls1028a/MAINTAINERS b/board/freescale/ls1028a/MAINTAINERS index 9e7b0697ff6..551f6a08651 100644 --- a/board/freescale/ls1028a/MAINTAINERS +++ b/board/freescale/ls1028a/MAINTAINERS @@ -1,5 +1,4 @@ LS1028AQDS BOARD -M: Rajesh Bhagat M: Tang Yuantian S: Maintained F: board/freescale/ls1028a/ @@ -9,7 +8,6 @@ F: configs/ls1028aqds_tfa_defconfig F: configs/ls1028aqds_tfa_lpuart_defconfig LS1028ARDB BOARD -M: Rajesh Bhagat M: Tang Yuantian S: Maintained F: board/freescale/ls1028a/ diff --git a/board/freescale/ls1043aqds/MAINTAINERS b/board/freescale/ls1043aqds/MAINTAINERS index 9fb6cc85cd0..f7420ecd303 100644 --- a/board/freescale/ls1043aqds/MAINTAINERS +++ b/board/freescale/ls1043aqds/MAINTAINERS @@ -1,6 +1,5 @@ LS1043AQDS BOARD M: Mingkai Hu -M: Rajesh Bhagat S: Maintained F: board/freescale/ls1043aqds/ F: include/configs/ls1043aqds.h diff --git a/board/freescale/ls1043ardb/MAINTAINERS b/board/freescale/ls1043ardb/MAINTAINERS index 8e14ba3608b..06b23889f6d 100644 --- a/board/freescale/ls1043ardb/MAINTAINERS +++ b/board/freescale/ls1043ardb/MAINTAINERS @@ -1,6 +1,5 @@ LS1043A BOARD M: Mingkai Hu -M: Rajesh Bhagat S: Maintained F: board/freescale/ls1043ardb/ F: include/configs/ls1043ardb.h diff --git a/board/freescale/ls1046aqds/MAINTAINERS b/board/freescale/ls1046aqds/MAINTAINERS index 72c4253fcf5..e1db2aaa8e4 100644 --- a/board/freescale/ls1046aqds/MAINTAINERS +++ b/board/freescale/ls1046aqds/MAINTAINERS @@ -1,6 +1,5 @@ LS1046AQDS BOARD M: Mingkai Hu -M: Rajesh Bhagat S: Maintained F: board/freescale/ls1046aqds/ F: include/configs/ls1046aqds.h diff --git a/board/freescale/ls1046ardb/MAINTAINERS b/board/freescale/ls1046ardb/MAINTAINERS index 3c8cfe720dc..d5a6b261519 100644 --- a/board/freescale/ls1046ardb/MAINTAINERS +++ b/board/freescale/ls1046ardb/MAINTAINERS @@ -1,6 +1,5 @@ LS1046A BOARD M: Mingkai Hu -M: Rajesh Bhagat S: Maintained F: board/freescale/ls1046ardb/ F: board/freescale/ls1046ardb/ls1046ardb.c diff --git a/board/freescale/ls1088a/MAINTAINERS b/board/freescale/ls1088a/MAINTAINERS index 5c7925a95f4..95a14149e4f 100644 --- a/board/freescale/ls1088a/MAINTAINERS +++ b/board/freescale/ls1088a/MAINTAINERS @@ -1,6 +1,5 @@ LS1088ARDB BOARD M: Ashish Kumar -M: Rajesh Bhagat S: Maintained F: board/freescale/ls1088a/ F: include/configs/ls1088ardb.h @@ -11,7 +10,6 @@ F: configs/ls1088ardb_tfa_SECURE_BOOT_defconfig LS1088AQDS BOARD M: Ashish Kumar -M: Rajesh Bhagat S: Maintained F: board/freescale/ls1088a/ F: include/configs/ls1088aqds.h diff --git a/board/freescale/ls2080aqds/MAINTAINERS b/board/freescale/ls2080aqds/MAINTAINERS index 39d02ae3f46..fdad199ec25 100644 --- a/board/freescale/ls2080aqds/MAINTAINERS +++ b/board/freescale/ls2080aqds/MAINTAINERS @@ -1,6 +1,5 @@ LS2080A BOARD M: Priyanka Jain -M: Rajesh Bhagat M: Wasim Khan S: Maintained F: board/freescale/ls2080aqds/ diff --git a/board/freescale/ls2080ardb/MAINTAINERS b/board/freescale/ls2080ardb/MAINTAINERS index f49d26af3a0..f2f834ffbd9 100644 --- a/board/freescale/ls2080ardb/MAINTAINERS +++ b/board/freescale/ls2080ardb/MAINTAINERS @@ -10,7 +10,6 @@ F: configs/ls2080ardb_nand_defconfig LS2088A_QSPI-boot BOARD M: Priyanka Jain -M: Rajesh Bhagat M: Wasim Khan S: Maintained F: configs/ls2088ardb_qspi_defconfig From c2ad5318d268ee513458422ead45971854d4a85d Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 18 Jul 2023 18:14:35 +0200 Subject: [PATCH 02/12] ARM: imx: Update MAINTAINERS file on DH electronics i.MX8M Plus DHCOM Make use of globs to cover all the DTs and defconfigs. Fill in missing DH u-boot list name. Signed-off-by: Marek Vasut --- board/dhelectronics/dh_imx8mp/MAINTAINERS | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/board/dhelectronics/dh_imx8mp/MAINTAINERS b/board/dhelectronics/dh_imx8mp/MAINTAINERS index 7c70cfdd949..db69781a852 100644 --- a/board/dhelectronics/dh_imx8mp/MAINTAINERS +++ b/board/dhelectronics/dh_imx8mp/MAINTAINERS @@ -1,8 +1,8 @@ -DH electronics DHCOM Premium Developer Kit (2) i.MX8M Plus +DH electronics DHCOM i.MX8M Plus and matching carrier boards M: Marek Vasut +L: u-boot@dh-electronics.com S: Maintained -F: arch/arm/dts/imx8mp-dhcom-pdk2.dts -F: arch/arm/dts/imx8mp-dhcom-pdk2-u-boot.dtsi -F: board/dhelectronics/imx8mp_dhcom_pdk2/ -F: configs/imx8mp_dhcom_pdk2_defconfig -F: include/configs/imx8mp_dhcom_pdk2.h +F: arch/arm/dts/imx8mp-dhcom* +F: board/dhelectronics/dh_imx8mp/ +F: configs/imx8mp_dhcom*defconfig +F: include/configs/imx8mp_dhcom* From b54fad3fe2019120f095aa7bea59dde2b52907c0 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 25 Jul 2023 18:31:53 -0400 Subject: [PATCH 03/12] vexpress64: Rework MAINTAINERS file slightly Given that we no longer have a configs/vexpress_aemv8a_defconfig file, drop that and then include at least the aarch64-specific config.h file here. Also move Linus and Peter up to the main entry as well so that they'll get tagged for the board code too and not literally only the defconfig. Signed-off-by: Tom Rini --- board/armltd/vexpress64/MAINTAINERS | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/board/armltd/vexpress64/MAINTAINERS b/board/armltd/vexpress64/MAINTAINERS index b3ecc9bba03..c38ab520c52 100644 --- a/board/armltd/vexpress64/MAINTAINERS +++ b/board/armltd/vexpress64/MAINTAINERS @@ -1,9 +1,10 @@ -VEXPRESS64 BOARD +VEXPRESS64 PLATFORM M: David Feng +M: Linus Walleij +M: Peter Hoyes S: Maintained F: board/armltd/vexpress64/ -F: include/configs/vexpress_aemv8a.h -F: configs/vexpress_aemv8a_defconfig +F: include/configs/vexpress_aemv8.h VEXPRESS_AEMV8A_SEMI BOARD M: Linus Walleij From eda90d2467d219cb3ff110dbcb25e0a984176647 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 25 Jul 2023 18:31:54 -0400 Subject: [PATCH 04/12] board/freescale: Drop two orphaned entries As the defconfig files here have been removed we can also remove the entries. Signed-off-by: Tom Rini Reviewed-by: Simon Glass --- board/freescale/t104xrdb/MAINTAINERS | 5 ----- board/freescale/t208xrdb/MAINTAINERS | 5 ----- 2 files changed, 10 deletions(-) diff --git a/board/freescale/t104xrdb/MAINTAINERS b/board/freescale/t104xrdb/MAINTAINERS index 4e82f7f2eee..55fdb600a16 100644 --- a/board/freescale/t104xrdb/MAINTAINERS +++ b/board/freescale/t104xrdb/MAINTAINERS @@ -24,8 +24,3 @@ F: configs/T1040RDB_SDCARD_defconfig F: configs/T1040D4RDB_SDCARD_defconfig F: configs/T1042D4RDB_SDCARD_defconfig F: configs/T1042RDB_PI_SDCARD_defconfig - -T1042D4RDB_SECURE_BOOT BOARD -M: Ruchika Gupta -S: Maintained -F: configs/T1042D4RDB_SECURE_BOOT_defconfig diff --git a/board/freescale/t208xrdb/MAINTAINERS b/board/freescale/t208xrdb/MAINTAINERS index 6e9b25fa049..5be7a25c03b 100644 --- a/board/freescale/t208xrdb/MAINTAINERS +++ b/board/freescale/t208xrdb/MAINTAINERS @@ -12,8 +12,3 @@ F: configs/T2080RDB_revD_defconfig F: configs/T2080RDB_revD_NAND_defconfig F: configs/T2080RDB_revD_SDCARD_defconfig F: configs/T2080RDB_revD_SPIFLASH_defconfig - -T2080RDB_SECURE_BOOT BOARD -M: Ruchika Gupta -S: Maintained -F: configs/T2080RDB_SECURE_BOOT_defconfig From e205fbcea0b4c94fad4ec04ebf8340fd11f80031 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 25 Jul 2023 18:31:55 -0400 Subject: [PATCH 05/12] rzn1-snarc: Add missing MAINTAINERS file This should have been included when the platform was added, make one now. Signed-off-by: Tom Rini --- board/schneider/rzn1-snarc/MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 board/schneider/rzn1-snarc/MAINTAINERS diff --git a/board/schneider/rzn1-snarc/MAINTAINERS b/board/schneider/rzn1-snarc/MAINTAINERS new file mode 100644 index 00000000000..a39b96c1163 --- /dev/null +++ b/board/schneider/rzn1-snarc/MAINTAINERS @@ -0,0 +1,9 @@ +RZN1 SNARC +M: Ralph Siemsen +S: Maintained +F: board/schneider/rzn1-snarc/ +F: arch/arm/dts/r9a06g032-ddr.dtsi +F: arch/arm/dts/r9a06g032-rzn1-snarc-u-boot.dtsi +F: arch/arm/dts/r9a06g032-rzn1-snarc.dts +F: configs/rzn1_snarc_defconfig +F: include/configs/rzn1-snarc.h From 42cd759a371acb49538344dbdb0bf9a8bbb798a0 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 26 Jul 2023 10:33:13 +0200 Subject: [PATCH 06/12] fat: correct sign for deletion mark The FAT file systems uses character '\xe5' to mark a deleted directory entry. If a file name starts with this character, it is substituted by '\x05' in the directory entry. While (signed char)'\xe5' is a negative number 0xe5 is a positive integer number. We therefore have define a constant DELETED_MARK which matches the signedness of the characters in the directory entry. Correct a comparison where we used the constant 0xe5 with the wrong sign. Use the constant aRING instead of 0x05 like in the rest of the code. Reported-by: Dan Carpenter Fixes: 57b745e2387a ("fs: fat: call set_name() only once") Fixes: 28cef9ca2e86 ("fs: fat: create correct short names") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- fs/fat/fat_write.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index e2a9913f807..a6294419b8d 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -132,9 +132,9 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname) return period_location; if (*dirent.name == ' ') *dirent.name = '_'; - /* 0xe5 signals a deleted directory entry. Replace it by 0x05. */ - if (*dirent.name == 0xe5) - *dirent.name = 0x05; + /* Substitute character 0xe5 signaling deletetion by character 0x05 */ + if (*dirent.name == DELETED_FLAG) + *dirent.name = aRING; /* If filename and short name are the same, quit. */ sprintf(buf, "%.*s.%.3s", period_location, dirent.name, dirent.ext); From 63baa841295812d77723382c74e723ab716f4563 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 26 Jul 2023 17:43:40 +0200 Subject: [PATCH 07/12] virtio: provide driver name in debug message If a driver cannot be bound, provide the driver name in the debug message. Now the debug message may look like this: (virtio-pci.l#0): virtio-rng driver not configured Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- drivers/virtio/virtio-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index 31bb21c534e..f2b3ef1d8b9 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -238,7 +238,7 @@ static int virtio_uclass_post_probe(struct udevice *udev) ret = device_bind_driver(udev, name, str, &vdev); if (ret == -ENOENT) { - debug("(%s): no driver configured\n", udev->name); + debug("(%s): %s driver not configured\n", udev->name, name); return 0; } if (ret) { From 0c0c82b5177e9afb3a248da4d004f3dc48975c91 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 26 Jul 2023 21:01:21 -0600 Subject: [PATCH 08/12] bootflow: Export setup_fs() This function is used in some bootmeth implementations. Export it. Signed-off-by: Simon Glass --- boot/bootmeth-uclass.c | 23 ++++++----------------- include/bootmeth.h | 13 +++++++++++++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index eeded08dd42..175eb1de5e1 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -240,18 +240,7 @@ int bootmeth_set_order(const char *order_str) return 0; } -/** - * setup_fs() - Set up read to read a file - * - * We must redo the setup before each filesystem operation. This function - * handles that, including setting the filesystem type if a block device is not - * being used - * - * @bflow: Information about file to try - * @desc: Block descriptor to read from (NULL if not a block device) - * Return: 0 if OK, -ve on error - */ -static int setup_fs(struct bootflow *bflow, struct blk_desc *desc) +int bootmeth_setup_fs(struct bootflow *bflow, struct blk_desc *desc) { int ret; @@ -288,7 +277,7 @@ int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc, log_debug(" %s - err=%d\n", path, ret); /* Sadly FS closes the file after fs_size() so we must redo this */ - ret2 = setup_fs(bflow, desc); + ret2 = bootmeth_setup_fs(bflow, desc); if (ret2) return log_msg_ret("fs", ret2); @@ -337,14 +326,14 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname, if (bflow->blk) desc = dev_get_uclass_plat(bflow->blk); - ret = setup_fs(bflow, desc); + ret = bootmeth_setup_fs(bflow, desc); if (ret) return log_msg_ret("fs", ret); ret = fs_size(path, &size); log_debug(" %s - err=%d\n", path, ret); - ret = setup_fs(bflow, desc); + ret = bootmeth_setup_fs(bflow, desc); if (ret) return log_msg_ret("fs", ret); @@ -369,7 +358,7 @@ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, if (bflow->blk) desc = dev_get_uclass_plat(bflow->blk); - ret = setup_fs(bflow, desc); + ret = bootmeth_setup_fs(bflow, desc); if (ret) return log_msg_ret("fs", ret); @@ -379,7 +368,7 @@ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow, if (size > *sizep) return log_msg_ret("spc", -ENOSPC); - ret = setup_fs(bflow, desc); + ret = bootmeth_setup_fs(bflow, desc); if (ret) return log_msg_ret("fs", ret); diff --git a/include/bootmeth.h b/include/bootmeth.h index c3df9702e87..7cb7da33dea 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -262,6 +262,19 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global); */ int bootmeth_set_order(const char *order_str); +/** + * bootmeth_setup_fs() - Set up read to read a file + * + * We must redo the setup before each filesystem operation. This function + * handles that, including setting the filesystem type if a block device is not + * being used + * + * @bflow: Information about file to try + * @desc: Block descriptor to read from (NULL if not a block device) + * Return: 0 if OK, -ve on error + */ +int bootmeth_setup_fs(struct bootflow *bflow, struct blk_desc *desc); + /** * bootmeth_try_file() - See we can access a given file * From 146242cc998ed6e002831d4ff409189353e1960a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 26 Jul 2023 21:01:22 -0600 Subject: [PATCH 09/12] bootstd: Use a function to detect network in EFI bootmeth This checks for a network-based bootflow in two places, one of which is less than ideal. Move the correct test into a function and use it in both places. Signed-off-by: Simon Glass --- boot/bootmeth_efi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index af31fbfc85d..e88e171ccc1 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -94,6 +94,20 @@ static int get_efi_pxe_vci(char *str, int max_len) return 0; } +/** + * bootmeth_uses_network() - check if the media device is Ethernet + * + * @bflow: Bootflow to check + * Returns: true if the media device is Ethernet, else false + */ +static bool bootmeth_uses_network(struct bootflow *bflow) +{ + const struct udevice *media = dev_get_parent(bflow->dev); + + return IS_ENABLED(CONFIG_CMD_DHCP) && + device_get_uclass_id(media) == UCLASS_ETH; +} + static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow) { const struct udevice *media_dev; @@ -354,11 +368,9 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow) static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) { - const struct udevice *media = dev_get_parent(bflow->dev); int ret; - if (IS_ENABLED(CONFIG_CMD_DHCP) && - device_get_uclass_id(media) == UCLASS_ETH) { + if (bootmeth_uses_network(bflow)) { /* we only support reading from one device, so ignore 'dev' */ ret = distro_efi_read_bootflow_net(bflow); if (ret) @@ -378,7 +390,7 @@ int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) char cmd[50]; /* A non-zero buffer indicates the kernel is there */ - if (bflow->buf) { + if (!bootmeth_uses_network(bflow)) { /* Set the EFI bootdev again, since reading an FDT loses it! */ if (bflow->blk) { struct blk_desc *desc = dev_get_uclass_plat(bflow->blk); From 6a8c2f9781cede2a7cb2b95ee6310cd53b1c20e2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 26 Jul 2023 21:01:23 -0600 Subject: [PATCH 10/12] bootstd: Avoid allocating memory for the EFI file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current bootflow-iteration algorithm reads the bootflow file into an allocated memory buffer so it can be examined. This works well in most cases. However, while the common case is that the first bootflow is immediately booted, it is also possible just to scan for available bootflows, perhaps selecting one to boot later. Even with the common case, EFI bootflows can be quite large. It doesn't make sense to read it into an allocated buffer when we have kernel_addr_t providing a suitable address for it. Even if we do have plenty of malloc() space available, it is a violation of U-Boot's lazy-init principle to read the bootflow before it is needed. So overall it seems better to make a change. Adjust the logic to read just the size of the EFI file at first. Later, when the bootflow is booted, read the rest of the file into the designated kernel buffer. Signed-off-by: Simon Glass Reported-by: Da Xue Reported-by: Vincent Stehlé --- boot/bootmeth_efi.c | 50 ++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index e88e171ccc1..bceec0d12ef 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -143,13 +143,24 @@ static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow) efi_set_bootdev(dev_name, devnum_str, bflow->fname, bflow->buf, size); } -static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow) +static int efiload_read_file(struct bootflow *bflow, ulong addr) { + struct blk_desc *desc = NULL; + loff_t bytes_read; int ret; - ret = bootmeth_alloc_file(bflow, 0x2000000, 0x10000); + if (bflow->blk) + desc = dev_get_uclass_plat(bflow->blk); + ret = bootmeth_setup_fs(bflow, desc); + if (ret) + return log_msg_ret("set", ret); + + ret = fs_read(bflow->fname, addr, 0, bflow->size, &bytes_read); if (ret) return log_msg_ret("read", ret); + bflow->buf = map_sysmem(addr, bflow->size); + + set_efi_bootdev(desc, bflow); return 0; } @@ -223,7 +234,18 @@ static int distro_efi_get_fdt_name(char *fname, int size, int seq) return 0; } -static int distro_efi_read_bootflow_file(struct udevice *dev, +/* + * distro_efi_try_bootflow_files() - Check that files are present + * + * This reads any FDT file and checks whether the bootflow file is present, for + * later reading. We avoid reading the bootflow now, since it is likely large, + * it may take a long time and we want to avoid needing to allocate memory for + * it + * + * @dev: bootmeth device to use + * @bflow: bootflow to update + */ +static int distro_efi_try_bootflow_files(struct udevice *dev, struct bootflow *bflow) { struct blk_desc *desc = NULL; @@ -247,9 +269,8 @@ static int distro_efi_read_bootflow_file(struct udevice *dev, if (ret) return log_msg_ret("try", ret); - ret = efiload_read_file(desc, bflow); - if (ret) - return log_msg_ret("read", ret); + /* Since we can access the file, let's call it ready */ + bflow->state = BOOTFLOWST_READY; fdt_addr = env_get_hex("fdt_addr_r", 0); @@ -376,7 +397,7 @@ static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) if (ret) return log_msg_ret("net", ret); } else { - ret = distro_efi_read_bootflow_file(dev, bflow); + ret = distro_efi_try_bootflow_files(dev, bflow); if (ret) return log_msg_ret("blk", ret); } @@ -388,17 +409,13 @@ int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) { ulong kernel, fdt; char cmd[50]; + int ret; - /* A non-zero buffer indicates the kernel is there */ + kernel = env_get_hex("kernel_addr_r", 0); if (!bootmeth_uses_network(bflow)) { - /* Set the EFI bootdev again, since reading an FDT loses it! */ - if (bflow->blk) { - struct blk_desc *desc = dev_get_uclass_plat(bflow->blk); - - set_efi_bootdev(desc, bflow); - } - - kernel = (ulong)map_to_sysmem(bflow->buf); + ret = efiload_read_file(bflow, kernel); + if (ret) + return log_msg_ret("read", ret); /* * use the provided device tree if available, else fall back to @@ -417,7 +434,6 @@ int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) * But this is the same behaviour for distro boot, so it can be * fixed here. */ - kernel = env_get_hex("kernel_addr_r", 0); fdt = env_get_hex("fdt_addr_r", 0); } From 2984d21a28f812c9c1fd2243cc72796f69a61585 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 26 Jul 2023 21:01:24 -0600 Subject: [PATCH 11/12] bootstd: Init the size before reading the devicetree The implementation in distro_efi_try_bootflow_files() does not pass a valid size to bootmeth_common_read_file(), so this can fail if the uninted value happens to be too small. Fix this. This was reported by someone but I cannot now find the email. Signed-off-by: Simon Glass --- boot/bootmeth_efi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index bceec0d12ef..1c9f2b1e2fe 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -21,6 +21,7 @@ #include #include #include +#include #define EFI_DIRNAME "efi/boot/" @@ -281,9 +282,12 @@ static int distro_efi_try_bootflow_files(struct udevice *dev, ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq); if (ret == -EALREADY) bflow->flags = BOOTFLOWF_USE_PRIOR_FDT; - if (!ret) + if (!ret) { + /* Limit FDT files to 4MB */ + size = SZ_4M; ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr, &size); + } } if (*fname) { From 11158aef8939bb6e54361e4dae3809a9cbe78cff Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 26 Jul 2023 21:01:25 -0600 Subject: [PATCH 12/12] bootstd: Init the size before reading extlinux file The implementation in extlinux_pxe_getfile() does not pass a valid size to bootmeth_read_file(), so this can fail if the uninited value happens to be too small. Fix this. Signed-off-by: Simon Glass --- boot/bootmeth_pxe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index ce986bd260d..8d489a11aa4 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -31,6 +31,9 @@ static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path, int ret; addr = simple_strtoul(file_addr, NULL, 16); + + /* Allow up to 1GB */ + *sizep = 1 << 30; ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr, sizep); if (ret)