CVS commit: [netbsd-10] src/sys/stand/efiboot
Module Name:src Committed By: martin Date: Thu Apr 18 15:32:36 UTC 2024 Modified Files: src/sys/stand/efiboot [netbsd-10]: efiboot.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #656): sys/stand/efiboot/efiboot.c: revision 1.23 efiboot: Duplicate efi_bootdp before we clobber it in efi_net_probe. Patch from jakllsch@. Makes Socionext Synquacer boot considerably more reliably. PR kern/58075 To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/stand/efiboot/efiboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiboot.c diff -u src/sys/stand/efiboot/efiboot.c:1.22 src/sys/stand/efiboot/efiboot.c:1.22.4.1 --- src/sys/stand/efiboot/efiboot.c:1.22 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/efiboot.c Thu Apr 18 15:32:36 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.c,v 1.22 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: efiboot.c,v 1.22.4.1 2024/04/18 15:32:36 martin Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -86,6 +86,8 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS status = uefi_call_wrapper(BS->HandleProtocol, 3, efi_li->DeviceHandle, , (void **)_bootdp); if (EFI_ERROR(status)) efi_bootdp = NULL; + else + efi_bootdp = DuplicateDevicePath(efi_bootdp); #ifdef EFIBOOT_DEBUG Print(L"Loaded image : 0x%" PRIxEFIPTR "\n", efi_li);
CVS commit: [netbsd-10] src/sys/stand/efiboot
Module Name:src Committed By: martin Date: Thu Apr 18 15:32:36 UTC 2024 Modified Files: src/sys/stand/efiboot [netbsd-10]: efiboot.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #656): sys/stand/efiboot/efiboot.c: revision 1.23 efiboot: Duplicate efi_bootdp before we clobber it in efi_net_probe. Patch from jakllsch@. Makes Socionext Synquacer boot considerably more reliably. PR kern/58075 To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.22.4.1 src/sys/stand/efiboot/efiboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-10] src/sys/stand/efiboot
Module Name:src Committed By: martin Date: Mon Jan 1 14:00:17 UTC 2024 Modified Files: src/sys/stand/efiboot [netbsd-10]: efinet.c Log Message: Additionally pull up following revision(s) (requested by rin in ticket #524): sys/stand/efiboot/efinet.c: revision 1.9 MI efiboot: Revert "Stop using efi_bootdp after exclusive open for PXE" http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/stand/efiboot/efinet.c#rev1.7 Some UEFI implementations pass multiple boot options as boot device path, and NULL-clearing it results in boot failures. Thanks skrll@ for pointing it out. To generate a diff of this commit: cvs rdiff -u -r1.6.32.1 -r1.6.32.2 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efinet.c diff -u src/sys/stand/efiboot/efinet.c:1.6.32.1 src/sys/stand/efiboot/efinet.c:1.6.32.2 --- src/sys/stand/efiboot/efinet.c:1.6.32.1 Sat Dec 30 19:33:25 2023 +++ src/sys/stand/efiboot/efinet.c Mon Jan 1 14:00:17 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efinet.c,v 1.6.32.1 2023/12/30 19:33:25 martin Exp $ */ +/* $NetBSD: efinet.c,v 1.6.32.2 2024/01/01 14:00:17 martin Exp $ */ /*- * Copyright (c) 2001 Doug Rabson @@ -333,7 +333,7 @@ efi_net_probe(void) EFI_STATUS status; UINTN i, nhandles; int nifs, depth = -1; - bool found, is_bootdp; + bool found; status = LibLocateHandle(ByProtocol, , NULL, , ); @@ -377,9 +377,6 @@ efi_net_probe(void) if (!found) continue; - is_bootdp = depth > 0 && - efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0; - status = uefi_call_wrapper(BS->OpenProtocol, 6, handles[i], , (void **), IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE); @@ -407,21 +404,10 @@ efi_net_probe(void) return; } - if (is_bootdp) { - /* - * This is boot device... - */ + if (depth > 0 && efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0) { char devname[9]; - snprintf(devname, sizeof(devname), "net%u", nifs); set_default_device(devname); - - /* - * and now opened for us excluively. Therefore, - * access via device path is illegal. - */ - efi_bootdp = NULL; - depth = -1; } nifs++;
CVS commit: [netbsd-10] src/sys/stand/efiboot
Module Name:src Committed By: martin Date: Mon Jan 1 14:00:17 UTC 2024 Modified Files: src/sys/stand/efiboot [netbsd-10]: efinet.c Log Message: Additionally pull up following revision(s) (requested by rin in ticket #524): sys/stand/efiboot/efinet.c: revision 1.9 MI efiboot: Revert "Stop using efi_bootdp after exclusive open for PXE" http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/stand/efiboot/efinet.c#rev1.7 Some UEFI implementations pass multiple boot options as boot device path, and NULL-clearing it results in boot failures. Thanks skrll@ for pointing it out. To generate a diff of this commit: cvs rdiff -u -r1.6.32.1 -r1.6.32.2 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-10] src/sys/stand/efiboot
Module Name:src Committed By: martin Date: Sat Dec 30 19:33:25 UTC 2023 Modified Files: src/sys/stand/efiboot [netbsd-10]: efinet.c Log Message: Pull up following revision(s) (requested by rin in ticket #524): sys/stand/efiboot/efinet.c: revision 1.7 sys/stand/efiboot/efinet.c: revision 1.8 MI efiboot: Stop using efi_bootdp after exclusive open for PXE Once boot device is exclusively opened for Simple Network Protocol, further access via device path (efi_bootdp) is illegal. For some implementations, boot device path gets corrupted by exclusive open, and subsequent access by efi_device_path_depth(), e.g., causes infinite recursion. Fix PXE boot for QEMU/aarch64 with EDK2 on some Linux distributions. Thanks yamaguchi@ for comments and tests. MI efiboot: efi_net_probe: Examine Messaging Device Path also Network devices can be found as Hardware or Messaging Device Paths, see Sec 10.4.4 of UEFI Spec 2.10. In addition to Hardware Device Path, try Messaging Device Path also. This fixes PXE boot on implementations with the latter choice, e.g., Raspberry Pi 4 UEFI firmware. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.6.32.1 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efinet.c diff -u src/sys/stand/efiboot/efinet.c:1.6 src/sys/stand/efiboot/efinet.c:1.6.32.1 --- src/sys/stand/efiboot/efinet.c:1.6 Sun Mar 31 22:24:41 2019 +++ src/sys/stand/efiboot/efinet.c Sat Dec 30 19:33:25 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: efinet.c,v 1.6 2019/03/31 22:24:41 jmcneill Exp $ */ +/* $NetBSD: efinet.c,v 1.6.32.1 2023/12/30 19:33:25 martin Exp $ */ /*- * Copyright (c) 2001 Doug Rabson @@ -333,7 +333,7 @@ efi_net_probe(void) EFI_STATUS status; UINTN i, nhandles; int nifs, depth = -1; - bool found; + bool found, is_bootdp; status = LibLocateHandle(ByProtocol, , NULL, , ); @@ -346,7 +346,15 @@ efi_net_probe(void) memset(enis, 0, nhandles * sizeof(*enis)); if (efi_bootdp) { + /* + * Either Hardware or Messaging Device Paths can be used + * here, see Sec 10.4.4 of UEFI Spec 2.10. Try both. + */ depth = efi_device_path_depth(efi_bootdp, HARDWARE_DEVICE_PATH); + if (depth == -1) { + depth = efi_device_path_depth(efi_bootdp, + MESSAGING_DEVICE_PATH); + } if (depth == 0) depth = 1; } @@ -369,6 +377,9 @@ efi_net_probe(void) if (!found) continue; + is_bootdp = depth > 0 && + efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0; + status = uefi_call_wrapper(BS->OpenProtocol, 6, handles[i], , (void **), IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE); @@ -396,10 +407,21 @@ efi_net_probe(void) return; } - if (depth > 0 && efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0) { + if (is_bootdp) { + /* + * This is boot device... + */ char devname[9]; + snprintf(devname, sizeof(devname), "net%u", nifs); set_default_device(devname); + + /* + * and now opened for us excluively. Therefore, + * access via device path is illegal. + */ + efi_bootdp = NULL; + depth = -1; } nifs++;
CVS commit: [netbsd-10] src/sys/stand/efiboot
Module Name:src Committed By: martin Date: Sat Dec 30 19:33:25 UTC 2023 Modified Files: src/sys/stand/efiboot [netbsd-10]: efinet.c Log Message: Pull up following revision(s) (requested by rin in ticket #524): sys/stand/efiboot/efinet.c: revision 1.7 sys/stand/efiboot/efinet.c: revision 1.8 MI efiboot: Stop using efi_bootdp after exclusive open for PXE Once boot device is exclusively opened for Simple Network Protocol, further access via device path (efi_bootdp) is illegal. For some implementations, boot device path gets corrupted by exclusive open, and subsequent access by efi_device_path_depth(), e.g., causes infinite recursion. Fix PXE boot for QEMU/aarch64 with EDK2 on some Linux distributions. Thanks yamaguchi@ for comments and tests. MI efiboot: efi_net_probe: Examine Messaging Device Path also Network devices can be found as Hardware or Messaging Device Paths, see Sec 10.4.4 of UEFI Spec 2.10. In addition to Hardware Device Path, try Messaging Device Path also. This fixes PXE boot on implementations with the latter choice, e.g., Raspberry Pi 4 UEFI firmware. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.6.32.1 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-10] src/sys/stand/efiboot
Module Name:src Committed By: martin Date: Fri Nov 3 09:59:04 UTC 2023 Modified Files: src/sys/stand/efiboot [netbsd-10]: Makefile.efiboot boot.c efiblock.c exec.c Log Message: Pull up following revision(s) (requested by rin in ticket #451): sys/stand/efiboot/efiblock.c: revision 1.20 sys/stand/efiboot/exec.c: revision 1.24 sys/stand/efiboot/Makefile.efiboot: revision 1.29 sys/stand/efiboot/boot.c: revision 1.45 Add missing member for terminating sentinel. Avoid void * pointer arithmetic; cast to UINT8 * explicitly. No binary changes for aarch64 at least. Use %zd instead of %ld for ssize_t. Add missing include paths for libz. Not used at the moment although. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.26.4.1 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.44 -r1.44.4.1 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/stand/efiboot/efiblock.c cvs rdiff -u -r1.23 -r1.23.4.1 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.26 src/sys/stand/efiboot/Makefile.efiboot:1.26.4.1 --- src/sys/stand/efiboot/Makefile.efiboot:1.26 Fri Mar 25 21:23:00 2022 +++ src/sys/stand/efiboot/Makefile.efiboot Fri Nov 3 09:59:04 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.26 2022/03/25 21:23:00 jmcneill Exp $ +# $NetBSD: Makefile.efiboot,v 1.26.4.1 2023/11/03 09:59:04 martin Exp $ S= ${.CURDIR}/../../.. @@ -133,6 +133,7 @@ LIBKERN= ${KERNLIB} ### find out what to use for libz Z_AS= library .include "${S}/lib/libz/Makefile.inc" +CPPFLAGS+= -I${S}/lib/libz -I${S}/../common/dist/zlib LIBZ= ${ZLIB} ### find out what to use for libgnuefi Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.44 src/sys/stand/efiboot/boot.c:1.44.4.1 --- src/sys/stand/efiboot/boot.c:1.44 Sun Aug 14 11:26:41 2022 +++ src/sys/stand/efiboot/boot.c Fri Nov 3 09:59:04 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.44 2022/08/14 11:26:41 jmcneill Exp $ */ +/* $NetBSD: boot.c,v 1.44.4.1 2023/11/03 09:59:04 martin Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -148,7 +148,7 @@ const struct boot_command commands[] = { { "help", command_help, "help|?" }, { "?", command_help, NULL }, { "quit", command_quit, "quit" }, - { NULL, NULL }, + { NULL, NULL, NULL }, }; static int Index: src/sys/stand/efiboot/efiblock.c diff -u src/sys/stand/efiboot/efiblock.c:1.19 src/sys/stand/efiboot/efiblock.c:1.19.4.1 --- src/sys/stand/efiboot/efiblock.c:1.19 Sun Apr 24 06:49:38 2022 +++ src/sys/stand/efiboot/efiblock.c Fri Nov 3 09:59:04 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: efiblock.c,v 1.19 2022/04/24 06:49:38 mlelstv Exp $ */ +/* $NetBSD: efiblock.c,v 1.19.4.1 2023/11/03 09:59:04 martin Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -442,7 +442,7 @@ efi_block_find_partitions_gpt(struct efi } for (entry = 0; entry < le32toh(hdr.hdr_entries); entry++) { - memcpy(, buf + (entry * le32toh(hdr.hdr_entsz)), + memcpy(, (UINT8 *)buf + (entry * le32toh(hdr.hdr_entsz)), sizeof(ent)); efi_block_find_partitions_gpt_entry(bdev, , , entry); } Index: src/sys/stand/efiboot/exec.c diff -u src/sys/stand/efiboot/exec.c:1.23 src/sys/stand/efiboot/exec.c:1.23.4.1 --- src/sys/stand/efiboot/exec.c:1.23 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/exec.c Fri Nov 3 09:59:04 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.23 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: exec.c,v 1.23.4.1 2023/11/03 09:59:04 martin Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -109,7 +109,7 @@ load_file(const char *path, u_long extra if (len < 0) { printf(": %s\n", strerror(errno)); } else { - printf(": returned %ld (expected %ld)\n", len, + printf(": returned %zd (expected %zd)\n", len, expectedlen); } return EIO;
CVS commit: [netbsd-10] src/sys/stand/efiboot
Module Name:src Committed By: martin Date: Fri Nov 3 09:59:04 UTC 2023 Modified Files: src/sys/stand/efiboot [netbsd-10]: Makefile.efiboot boot.c efiblock.c exec.c Log Message: Pull up following revision(s) (requested by rin in ticket #451): sys/stand/efiboot/efiblock.c: revision 1.20 sys/stand/efiboot/exec.c: revision 1.24 sys/stand/efiboot/Makefile.efiboot: revision 1.29 sys/stand/efiboot/boot.c: revision 1.45 Add missing member for terminating sentinel. Avoid void * pointer arithmetic; cast to UINT8 * explicitly. No binary changes for aarch64 at least. Use %zd instead of %ld for ssize_t. Add missing include paths for libz. Not used at the moment although. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.26.4.1 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.44 -r1.44.4.1 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/stand/efiboot/efiblock.c cvs rdiff -u -r1.23 -r1.23.4.1 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.