From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web12.5094.1592392359711617531 for ; Wed, 17 Jun 2020 04:12:40 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=vvKWfggZ; spf=pass (domain: nuviainc.com, ip: 209.85.221.65, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f65.google.com with SMTP id h5so1889946wrc.7 for ; Wed, 17 Jun 2020 04:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oWygvRlr8ZQKtzPnzdikL8RqwX4dXeOp3gOoP69+2+A=; b=vvKWfggZmJ0UAMjOFvUviwgun208FqUX1NafiStcIk1iQy6IPJQTp93zVs8GCDLSD+ CvQRp9W0Lot/n2I0yabrcNfFPllpnRm/rHNysuyuFJ99JPuKV4o5+68zozFDqRGfLXfi IJ1kalXnMdaVEmpA/SjuPItlYPakFWLHctG5nrFOx3d6lTpE/m6M/XMlAEMh/3ogsTuQ Y5eYsF2wANKkmEvPwd9cDae+65vG8blnNkaITQ7cUiViK7paY2a+x2lziujgsiq8qOF0 OoFZ9LCYCJpsKzAGtVOTRjMRck2nPNvRXU+KE4ERANrNrzgvs7bSRmfuBX6MoSSzHLKl zPeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oWygvRlr8ZQKtzPnzdikL8RqwX4dXeOp3gOoP69+2+A=; b=Iu8DFzLhTqdpnGFwvqg0Z5IMR3+a14yUABIYk6ns4xxGE3O+IXbstGHHCfBsvYMkct s6dck7xgsvZsbMXCHQtJfar5a5KuWEZUmHw2UAk8lWKwTgRkS1Z9v/ODTSBYKS+jU7mA IfhAfjoAM2arEIOmCQUaqzKvAg2BBEwYbARpTM3yModk542ekQhPlcSe3ZaY8nSXMNaP raHhmxC2yE/4/qhkLf39TFXF5MJQcXyAElT1SNOnXtdKEDXRXUH6kQdGRZJH1wQdWdA9 zrXaA5aRjWN2Mr88k0ZJBaBLFGHSkf8KWOYNBtQ02ZO8UOQkCLlcRHjqMKqmyHHzQlBQ bYxA== X-Gm-Message-State: AOAM532tqVjfuWLRWm81pYoV1Q8WvaOl30eaXfJXB3TwyvdqFFeLJu/8 Rjpf5Jh/Xp0to8Rzy8dvI5h1iA== X-Google-Smtp-Source: ABdhPJy8VbuIfWUvSlC0Sg7FPQ7/LQA7dnEqoHEszvSil3FVQ+Hbjr3pSvArzPA8TJn8qFMgJC9jrQ== X-Received: by 2002:adf:f00f:: with SMTP id j15mr8745863wro.347.1592392358317; Wed, 17 Jun 2020 04:12:38 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id p7sm33596242wro.26.2020.06.17.04.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 04:12:37 -0700 (PDT) Date: Wed, 17 Jun 2020 12:12:35 +0100 From: "Leif Lindholm" To: Ard Biesheuvel Cc: devel@edk2.groups.io, Pete Batard , Andrei Warkentin , Samer El-Haj-Mahmoud Subject: Re: [PATCH] ArmPkg/PlatformBootManagerLib: regenerate boot options on boot failure Message-ID: <20200617111235.GJ6739@vanye> References: <20200616174834.1110310-1-ard.biesheuvel@arm.com> MIME-Version: 1.0 In-Reply-To: <20200616174834.1110310-1-ard.biesheuvel@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jun 16, 2020 at 19:48:34 +0200, Ard Biesheuvel wrote: > 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, The passive voice is confusing me a bit here - who does the updating, and when specifically? / Leif > 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 > --- > ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 34 ++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/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 = 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 = 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 != OldBootOptionCount) { > + DEBUG ((DEBUG_WARN, "%a: rebooting after refreshing all boot options\n", > + __FUNCTION__)); > + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); > + } > > Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); > if (EFI_ERROR (Status)) { > -- > 2.27.0 >