From 7f2aed2f989431930d981e2498685661e611eb99 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Tue, 12 Mar 2024 00:18:30 +0000 Subject: [PATCH] 2024.04 RC4, upstream fixes --- sources | 2 +- uboot-tools.spec | 10 +- ...ll-options-for-EFI-System-Partitions.patch | 51 +++-- ..._location-for-finding-the-DT-on-disk.patch | 180 ++++++++++++++++++ 4 files changed, 224 insertions(+), 19 deletions(-) create mode 100644 uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch diff --git a/sources b/sources index be81335..0b96c52 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (u-boot-2024.04-rc3.tar.bz2) = 75f36d57330e771dd3757c49d576b3a7f1c933dad9a102f22d2438286a763f0ec7deae863a97559cac48be8fc736b68a5292b4383d45178b111bd08134352e38 +SHA512 (u-boot-2024.04-rc4.tar.bz2) = 4a546eb790d54c9aadd423888baa5c909249afeedfd71f85c8b424421c08463b0e65f3addfc2d00f4a38fb56d8051ed70c8368d49a89bd33ec69773474d4d62d diff --git a/uboot-tools.spec b/uboot-tools.spec index 4d006c4..de80725 100644 --- a/uboot-tools.spec +++ b/uboot-tools.spec @@ -1,4 +1,4 @@ -%global candidate rc3 +%global candidate rc4 %if 0%{?rhel} %bcond_with toolsonly %else @@ -7,7 +7,7 @@ Name: uboot-tools Version: 2024.04 -Release: 0.3%{?candidate:.%{candidate}}%{?dist} +Release: 0.4%{?candidate:.%{candidate}}%{?dist} Epoch: 1 Summary: U-Boot utilities License: GPLv2+ BSD LGPL-2.1+ LGPL-2.0+ @@ -22,7 +22,7 @@ Patch1: uefi-distro-load-FDT-from-any-partition-on-boot-device.patch # Identify VFAT partitions as ESP, allows EFI setvar on our images Patch2: uefi-Add-all-options-for-EFI-System-Partitions.patch # New function to find fdt for loading from disk -#Patch3: +Patch3: uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch # Fedora patches to enable/disable features Patch4: disable-VBE-by-default.patch Patch5: enable-bootmenu-by-default.patch @@ -189,6 +189,10 @@ install -p -m 0755 builds/tools/env/fw_printenv %{buildroot}%{_bindir} %endif %changelog +* Tue Mar 12 2024 Peter Robinson - 1:2024.04-0.4.rc4 +- Update to 2024.04 RC4 +- Initial fix for loading DT off /boot (rhbz 2247873) + * Thu Feb 29 2024 Peter Robinson - 1:2024.04-0.3.rc3 - Update to 2024.04 RC3 - Enable a number of new upstream devices diff --git a/uefi-Add-all-options-for-EFI-System-Partitions.patch b/uefi-Add-all-options-for-EFI-System-Partitions.patch index 22c5bcc..3bf1ec8 100644 --- a/uefi-Add-all-options-for-EFI-System-Partitions.patch +++ b/uefi-Add-all-options-for-EFI-System-Partitions.patch @@ -1,7 +1,7 @@ -From 7ce45304053f31afaea6b80305aaee164c2e260a Mon Sep 17 00:00:00 2001 +From 86782e882e9542f5f402e00cd87efb36ad0552d3 Mon Sep 17 00:00:00 2001 From: Peter Robinson -Date: Wed, 21 Feb 2024 14:43:16 +0000 -Subject: [PATCH] disk: dos: Add all options for EFI System Partitions +Date: Sat, 2 Mar 2024 11:17:42 +0000 +Subject: [PATCH v4] disk: dos: Add all options for EFI System Partitions The EFI spec states that the ESP can be any of FAT12/16/32 but for compatibility doesn't necssarily require the partition to be the @@ -12,25 +12,46 @@ permissable for an ESP. Signed-off-by: Peter Robinson --- - disk/part_dos.c | 6 ++++++ - 1 file changed, 6 insertions(+) + +v2: +- Add 0x0c option +- Make hex constants consistent +- Move from if to switch statement +v3: +- Fix switch brain fart +v4: +- Drop boot_ind out of switch + + disk/part_dos.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/disk/part_dos.c b/disk/part_dos.c -index 567ead7511d..303eb1d13ee 100644 +index 567ead7511d..a35181dff4f 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c -@@ -40,6 +40,12 @@ static int get_bootable(dos_partition_t *p) +@@ -40,10 +40,21 @@ static int get_bootable(dos_partition_t *p) { int ret = 0; -+ if (p->sys_ind == 0x1) -+ ret |= PART_EFI_SYSTEM_PARTITION; -+ if (p->sys_ind == 0x6) -+ ret |= PART_EFI_SYSTEM_PARTITION; -+ if (p->sys_ind == 0x0b) -+ ret |= PART_EFI_SYSTEM_PARTITION; - if (p->sys_ind == 0xef) +- if (p->sys_ind == 0xef) ++ switch (p->sys_ind) { ++ case 0x01: ++ case 0x06: ++ case 0x0b: ++ case 0x0c: ++ case 0xef: ret |= PART_EFI_SYSTEM_PARTITION; ++ break; ++ default: ++ break; ++ } ++ if (p->boot_ind == 0x80) + ret |= PART_BOOTABLE; ++ + return ret; + } + -- -2.43.1 +2.44.0 + diff --git a/uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch b/uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch new file mode 100644 index 0000000..e1937f8 --- /dev/null +++ b/uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch @@ -0,0 +1,180 @@ +From 47bf70fe95dd3883c08af3478f29564476f0950e Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Tue, 12 Mar 2024 00:05:23 +0000 +Subject: [PATCH] initial find_fdt_location for finding the DT on disk + +The old distro boot looked for a DT on the first boot partition +in the /dtb or /dtb/current directories, and Fedora extended this +to look not just on the boot partition but all the partitions on +that disk. + +The new ways of booting, both bootstd and bootefi bootmgr processes +don't properly look for those options. This provides a function +to search for the DTB on disk so that if the other DT mechanisms +don't work this will look for one on disk to provide a working DT +so that devices will continue to work as they did previously. + +Signed-off-by: Peter Robinson +--- + + cmd/bootefi.c | 1 + + cmd/bootmenu.c | 5 +++ + include/efi_loader.h | 2 + + lib/efi_loader/efi_helper.c | 82 ++++++++++++++++++++++++++++++++++++- + 4 files changed, 89 insertions(+), 1 deletion(-) + +diff --git a/cmd/bootefi.c b/cmd/bootefi.c +index 9cf9027bf40..8b6194a8702 100644 +--- a/cmd/bootefi.c ++++ b/cmd/bootefi.c +@@ -144,6 +144,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, + if (argc > 2) { + uintptr_t fdt_addr; + ++ /* Do we need to run find_fdt_location here?*/ + fdt_addr = hextoul(argv[2], NULL); + fdt = map_sysmem(fdt_addr, 0); + } else { +diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c +index 78184fccab2..48368c8d42e 100644 +--- a/cmd/bootmenu.c ++++ b/cmd/bootmenu.c +@@ -448,6 +448,11 @@ static void handle_uefi_bootnext(void) + u16 bootnext; + efi_status_t ret; + efi_uintn_t size; ++ const char *fdt_opt; ++ ++ /* Find the DTB on disk */ ++ log_debug("We will load the DTB\n"); ++ fdt_opt = find_fdt_location(); + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); +diff --git a/include/efi_loader.h b/include/efi_loader.h +index 7daca0afba2..a969378ff2f 100644 +--- a/include/efi_loader.h ++++ b/include/efi_loader.h +@@ -524,6 +524,8 @@ struct efi_register_notify_event { + struct list_head handles; + }; + ++/* Find the FDT on any partition */ ++char *find_fdt_location(void); + /* called at pre-initialization */ + int efi_init_early(void); + /* Initialize efi execution environment */ +diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c +index 5dd9cc876e4..59bdb2d030c 100644 +--- a/lib/efi_loader/efi_helper.c ++++ b/lib/efi_loader/efi_helper.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -24,6 +25,76 @@ + const efi_guid_t efi_lf2_initrd_guid = EFI_INITRD_MEDIA_GUID; + #endif + ++/* We need to pass a blk device in and return a location, or a loaded DT */ ++char *find_fdt_location(void) ++{ ++ const char *fdt_filename; ++ /* FIXME: dynamic size */ ++ char fdt_fullpath[60]; ++ const char *prefix; ++ struct udevice *blk; ++ /* FIXME: Fedora really only cares about first 2*/ ++ int MAX_PART = 8; ++ int part; ++ struct disk_partition info; ++ int ret; ++ int retfdt; ++ int retload; ++ loff_t fdtsize; ++ ulong pbraddr; ++ loff_t len_read; ++ ++ /* step one logic: we have the DT name we're hunting for */ ++ fdt_filename = env_get("fdtfile"); ++ if (fdt_filename) { ++ log_debug("FFL: We're looking for the DTB now!: %s\n", fdt_filename); ++ ++ /* probe all block disks to search for fdt */ ++ uclass_foreach_dev_probe(UCLASS_BLK, blk) { ++ log_debug("FFL: dev name: %s\n", blk->name); ++ struct blk_desc *desc; ++ desc = dev_get_uclass_plat(blk); ++ /* we should get a partition count here for looping */ ++ /* For loop for each partition */ ++ /* Need to also deal with zero part whole disk - part_get_info_whole_disk */ ++ for (part = 1; part <= MAX_PART; part++) { ++ log_debug("FFL: part num: %d\n", part); ++ ret = part_get_info(desc, part, &info); ++ /* if we have partition check it for DT */ ++ if (ret) { ++ log_debug("FFL: we have a partition\n"); ++ /* we should have a case/for prefix in =/ /dtb/ /dtb/current/ */ ++ /* but for now we hard code if for Fedora */ ++ prefix = "/dtb"; ++ snprintf(fdt_fullpath, sizeof(fdt_fullpath), "%s/%s", prefix, fdt_filename); ++ log_debug("FFL: full name: %s\n", fdt_fullpath); ++ /* search for DT on partition and either find and exit or continue */ ++ retfdt = fs_size(fdt_fullpath, &fdtsize); ++ if (retfdt) { ++ /* we have a fdt!*/ ++ log_debug("FFL: we have found a DT on disk\n"); ++ retload = fs_read(fdt_fullpath, pbraddr, 0, 0, &len_read); ++ if (retload) { ++ log_debug("FFL: we have a loaded DT, size %ld we can return\n", sizeof(len_read)); ++ log_info("Found DTB: %s\n", fdt_filename); ++ const char *fdt_opt; ++ fdt_opt = env_get("fdt_addr"); ++ return fdt_opt; ++ } ++ } ++ } else { ++ log_debug("FFL: no partition\n"); ++ } ++ } ++ } ++ } else { ++ log_debug("FFL: fdt_filename not defined!!\n"); ++ } ++ ++ /* We didn't find a FDT */ ++ return NULL; ++} ++ + /** + * efi_create_current_boot_var() - Return Boot#### name were #### is replaced by + * the value of BootCurrent +@@ -432,11 +503,20 @@ efi_status_t efi_install_fdt(void *fdt) + /* Look for device tree that is already installed */ + if (efi_get_configuration_table(&efi_guid_fdt)) + return EFI_SUCCESS; ++ /* Check if there is device tree loaded from disk */ ++ fdt_opt = find_fdt_location(); ++ if (fdt_opt) ++ log_debug("Found DTB: insert file name here\n"); + /* Check if there is a hardware device tree */ +- fdt_opt = env_get("fdt_addr"); ++ if (!fdt_opt) { ++ fdt_opt = env_get("fdt_addr"); ++ if (fdt_opt) ++ log_info("Found DTB: Prior firmware\n"); ++ } + /* Use our own device tree as fallback */ + if (!fdt_opt) { + fdt_opt = env_get("fdtcontroladdr"); ++ log_debug("Using DT from U-Boot\n"); + if (!fdt_opt) { + log_err("ERROR: need device tree\n"); + return EFI_NOT_FOUND; +-- +2.44.0 +