From nobody Wed Apr 24 15:23:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61347+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61347+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592329760; cv=none; d=zohomail.com; s=zohoarc; b=Wgba0/UAcQdMlu1p0sbSDR1BXjc1Uko8LB5mIyF9DqafnpBsZw7sPyI7Ws15ZEo+BDY4/9j7Ed+IG7N7NjMNXNMqFudS4ZL/xEbgHJckSU77sQb+Z2WbNCb/BJBJSPY//Sd4qFt4Nquo0A3Cg/H7YQOlsY/SOZHorhvSDQrLWow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592329760; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=JPSxG2d8lpvRJLAhPBLYJnxOVG9zh3RjiNAN+j+6u6A=; b=EVfl9XbVV/EV7LnGfK7jYw/WMJ6V8qZLS9VIIgGvJUlrT31UFqsCDui3w6L4SxWy21Lfgt2Olukk+wT7c5ELU8VQoHJ2hgfv8BcbDD3/cChqPWNAH3jNLevbGdxM3uHjllUiU0McGxuGGSbY8pPZUpnHlJEIbW38qQWZjHfTGmQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61347+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592329760596919.9728858377442; Tue, 16 Jun 2020 10:49:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id yBRoYY1788612xcqOUEVeGYB; Tue, 16 Jun 2020 10:49:20 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.789.1592329759294244057 for ; Tue, 16 Jun 2020 10:49:19 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BFB841F1; Tue, 16 Jun 2020 10:49:17 -0700 (PDT) X-Received: from localhost.localdomain (unknown [10.37.8.36]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 54DE83F73C; Tue, 16 Jun 2020 10:49:16 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel , Pete Batard , Andrei Warkentin , Samer El-Haj-Mahmoud Subject: [edk2-devel] [PATCH] ArmPkg/PlatformBootManagerLib: regenerate boot options on boot failure Date: Tue, 16 Jun 2020 19:48:34 +0200 Message-Id: <20200616174834.1110310-1-ard.biesheuvel@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@arm.com X-Gm-Message-State: orC0dFP5fmZeyUyZmbRB9Znzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592329760; bh=GWSOyGi0lxUrJ+zwGiXUyl+VoM3uasfZG9unhrMzMBI=; h=Cc:Date:From:Reply-To:Subject:To; b=UQMUQ8DjASfAyQR/2XNeDyPO6A60kaAxH0ofAF2zne7eMAvkY/PDqaTmZ317IpFk4Mu e16o67ToSfNaSdgtvHXKONdbOt4HKwSmGlVxnuUfLtDggH9zYl/PenIq4MNAksQCiyQ1l ba6X7IIrUFPgR4OPftbqsVj0FY6YbZarzDg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" One of the side effects of the recent changes to PlatformBootManagerLib changes to avoid connecting all devices on every boot is that we no longer default to network boot on a virgin boot, but end up in the UiApp menu. At this point, the autogenerated boot options that we used to rely on will be instantiated too, but it does break the unattended boot case where devices are expected to attempt a network boot on the very first power on. Let's work around this by refreshing all boot options explicitly in the UnableToBoot() handler, and rebooting the system if doing so resulted in a change to the total number of configured boot options. This way, we ultimately end up in the UiApp as before if no boot options could be started, but only after all the autogenerated ones have been attempted as well. Cc: Pete Batard Cc: Andrei Warkentin (awarkentin@vmware.com) Cc: Samer El-Haj-Mahmoud Signed-off-by: Ard Biesheuvel Acked-by: Laszlo Ersek Reviewed-by: Andrei Warkentin Reviewed-by: Leif Lindholm Reviewed-by: Samer El-Haj-Mahmoud --- ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 34 ++++++++++++++++++= ++ 1 file changed, 34 insertions(+) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Li= brary/PlatformBootManagerLib/PlatformBm.c index 15c5cac1bea0..9905cad22908 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -820,6 +820,40 @@ PlatformBootManagerUnableToBoot ( { EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu; + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; + UINTN OldBootOptionCount; + UINTN NewBootOptionCount; + + // + // Record the total number of boot configured boot options + // + BootOptions =3D EfiBootManagerGetLoadOptions (&OldBootOptionCount, + LoadOptionTypeBoot); + EfiBootManagerFreeLoadOptions (BootOptions, OldBootOptionCount); + + // + // Connect all devices, and regenerate all boot options + // + EfiBootManagerConnectAll (); + EfiBootManagerRefreshAllBootOption (); + + // + // Record the updated number of boot configured boot options + // + BootOptions =3D EfiBootManagerGetLoadOptions (&NewBootOptionCount, + LoadOptionTypeBoot); + EfiBootManagerFreeLoadOptions (BootOptions, NewBootOptionCount); + + // + // If the number of configured boot options has changed, reboot + // the system so the new boot options will be taken into account + // while executing the ordinary BDS bootflow sequence. + // + if (NewBootOptionCount !=3D OldBootOptionCount) { + DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot options\n= ", + __FUNCTION__)); + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + } =20 Status =3D EfiBootManagerGetBootManagerMenu (&BootManagerMenu); if (EFI_ERROR (Status)) { --=20 2.27.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61347): https://edk2.groups.io/g/devel/message/61347 Mute This Topic: https://groups.io/mt/74921613/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-