From owner-freebsd-current@freebsd.org Tue Jun 4 13:11:52 2019 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 838DF15B0108 for ; Tue, 4 Jun 2019 13:11:52 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from dec.sakura.ne.jp (dec.sakura.ne.jp [210.188.226.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2FF7096BF5; Tue, 4 Jun 2019 13:11:49 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from fortune.joker.local (124-18-96-116.dz.commufa.jp [124.18.96.116]) (authenticated bits=0) by dec.sakura.ne.jp (8.15.2/8.15.2/[SAKURA-WEB]/20080708) with ESMTPA id x54CSVfR058237; Tue, 4 Jun 2019 21:28:32 +0900 (JST) (envelope-from junchoon@dec.sakura.ne.jp) Date: Tue, 4 Jun 2019 21:28:31 +0900 From: Tomoaki AOKI To: freebsd-current@freebsd.org Cc: johalun@FreeBSD.org, imp@FreeBSD.org Subject: Re: UEFI boot broken in 13? Message-Id: <20190604212831.360fd1a0c34c9f329e3084fc@dec.sakura.ne.jp> In-Reply-To: <71a0c9f7-0b1f-3757-fc04-4c0d0a1e1085@FreeBSD.org> References: <71a0c9f7-0b1f-3757-fc04-4c0d0a1e1085@FreeBSD.org> Reply-To: junchoon@dec.sakura.ne.jp Organization: Junchoon corps X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd12.0) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Tue__4_Jun_2019_21_28_31_+0900_MxCTCUDeohEuf_Wy" X-Rspamd-Queue-Id: 2FF7096BF5 X-Spamd-Bar: +++++ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [5.86 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[junchoon@dec.sakura.ne.jp]; MV_CASE(0.50)[]; HAS_ATTACHMENT(0.00)[]; TO_DN_NONE(0.00)[]; REPLYTO_ADDR_EQ_FROM(0.00)[]; HAS_ORG_HEADER(0.00)[]; MX_GOOD(-0.01)[dec.sakura.ne.jp]; FROM_EQ_ENVFROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[116.96.18.124.zen.spamhaus.org : 127.0.0.10]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:9370, ipnet:210.188.224.0/19, country:JP]; SUBJECT_ENDS_QUESTION(1.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_UNKNOWN(0.10)[text/x-diff]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; DMARC_NA(0.00)[sakura.ne.jp]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.99)[0.990,0]; NEURAL_SPAM_SHORT(0.99)[0.994,0]; MIME_TRACE(0.00)[0:+,1:+,2:~]; NEURAL_SPAM_LONG(1.00)[1.000,0]; R_SPF_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.39)[ipnet: 210.188.224.0/19(0.63), asn: 9370(1.36), country: JP(-0.05)] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2019 13:11:52 -0000 This is a multi-part message in MIME format. --Multipart=_Tue__4_Jun_2019_21_28_31_+0900_MxCTCUDeohEuf_Wy Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi. Try attached patch for stand/efi/boot1/boot1.c. This partially reverts r347193 and works at least for me. Without this, boot1.efi (bootx64.efi) forcibly boot from first physical HDD/SSD, even if forcibly booted from other physical drive via BIOS (UEFI firmware) menu. Remaining parts of r347193 and following some commits does not affect. *Hand-crafted reverse patch from commit mail [1]. Reverting whole r347193 is fine, too. [1] https://lists.freebsd.org/pipermail/svn-src-head/2019-May/124677.html On Mon, 3 Jun 2019 18:38:47 -0700 Johannes Lundberg wrote: > Hi > > I'm using poudriere-image to create usb memstick images. The images are > identical except OS version. They are tested on a laptop with 13-CURRENT > installed as only OS, having UEFI boot and root on zfs. > > 12-STABLE memstick boots fine with in UEFI mode. > > With 13-CURRENT memstick it boots the installed FreeBSD from the SSD > instead (I choose USB UEFI OS in boot menu but it silently boots from > the SSD instead). If I switch to legacy boot, the memstick image boots fine. > > Any ideas? > > /Johannes > > > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" -- Tomoaki AOKI --Multipart=_Tue__4_Jun_2019_21_28_31_+0900_MxCTCUDeohEuf_Wy Content-Type: text/x-diff; name="REV_r347193-2_Reach_over_and_pull_in_devpath.c_from_libefi-stand_efi_boot1_boot1.c.diff" Content-Disposition: attachment; filename="REV_r347193-2_Reach_over_and_pull_in_devpath.c_from_libefi-stand_efi_boot1_boot1.c.diff" Content-Transfer-Encoding: 7bit Author: imp Date: Mon May 6 18:38:46 2019 New Revision: 347193 URL: https://svnweb.freebsd.org/changeset/base/347193 Log: Reach over and pull in devpath.c from libefi This allows us to remove three nearly identical functions because the differences don't matter, and the size difference is trivial. Modified: head/stand/efi/boot1/Makefile head/stand/efi/boot1/boot1.c Modified: head/stand/efi/boot1/boot1.c ============================================================================== --- head/stand/efi/boot1/boot1.c Mon May 6 18:24:07 2019 (r347192) +++ head/stand/efi/boot1/boot1.c Mon May 6 18:38:46 2019 (r347193) @@ -79,6 +79,53 @@ Free(void *buf, const char *file __unused, int line __ } /* + * nodes_match returns TRUE if the imgpath isn't NULL and the nodes match, + * FALSE otherwise. + */ +static BOOLEAN +nodes_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath) +{ + size_t len; + + if (imgpath == NULL || imgpath->Type != devpath->Type || + imgpath->SubType != devpath->SubType) + return (FALSE); + + len = DevicePathNodeLength(imgpath); + if (len != DevicePathNodeLength(devpath)) + return (FALSE); + + return (memcmp(imgpath, devpath, (size_t)len) == 0); +} + +/* + * device_paths_match returns TRUE if the imgpath isn't NULL and all nodes + * in imgpath and devpath match up to their respective occurrences of a + * media node, FALSE otherwise. + */ +static BOOLEAN +device_paths_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath) +{ + + if (imgpath == NULL) + return (FALSE); + + while (!IsDevicePathEnd(imgpath) && !IsDevicePathEnd(devpath)) { + if (IsDevicePathType(imgpath, MEDIA_DEVICE_PATH) && + IsDevicePathType(devpath, MEDIA_DEVICE_PATH)) + return (TRUE); + + if (!nodes_match(imgpath, devpath)) + return (FALSE); + + imgpath = NextDevicePathNode(imgpath); + devpath = NextDevicePathNode(devpath); + } + + return (FALSE); +} + +/* * load_loader attempts to load the loader image data. * * It tries each module and its respective devices, identified by mod->probe, @@ -261,7 +308,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, B if (!blkio->Media->LogicalPartition) return (EFI_UNSUPPORTED); - *preferred = efi_devpath_match(imgpath, devpath); + *preferred = device_paths_match(imgpath, devpath); /* Run through each module, see if it can load this partition */ for (i = 0; i < NUM_BOOT_MODULES; i++) { --Multipart=_Tue__4_Jun_2019_21_28_31_+0900_MxCTCUDeohEuf_Wy--