Re: [PATCH v2] efi: Introduce EFI bootloader control driver
From: Stanacar, Stefan
Date: Fri Mar 18 2016 - 15:18:28 EST
On Fri, 2016-03-18 at 16:15 +0000, Matt Fleming wrote:
> On Fri, 18 Mar, at 12:11:50PM, Daniel Baluta wrote:
> >
> > From: Matt Gumbel <matthew.k.gumbel@xxxxxxxxx>
> >
> > This driver intercepts system reboot requests and populates the
> > LoaderEntryOneShot EFI variable with the user-supplied reboot
> > argument. EFI bootloaders such as Gummiboot will consume this
> > variable and use it to control which OS is booted next.
> >
> > We use this with Android where reboot() tells the kernel that
> > we want to boot into recovery or other non-default OS environment.
> >
> > It is the bootloader's job to guard against this variable being
> > uninitialzed or containing invalid data, and just boot normally
> > if that is the case.
> >
> > Signed-off-by: Matt Gumbel <matthew.k.gumbel@xxxxxxxxx>
> > Signed-off-by: Mohamed Abbas <mohamed.abbas@xxxxxxxxx>
> > Signed-off-by: Constantin Musca <constantin.musca@xxxxxxxxx>
> > Signed-off-by: Daniel Baluta <daniel.baluta@xxxxxxxxx>
> > ---
> > Changes since v1:
> > * updated Makefile after changing source name from efibc.c ->
> > efi-bc.c
> > to comply with naming rules in drivers/firmware/efi/
> >
> > Âdrivers/firmware/efi/KconfigÂÂ|ÂÂ11 ++
> > Âdrivers/firmware/efi/Makefile |ÂÂÂ1 +
> > Âdrivers/firmware/efi/efi-bc.c | 251
> > ++++++++++++++++++++++++++++++++++++++++++
> > Â3 files changed, 263 insertions(+)
> > Âcreate mode 100644 drivers/firmware/efi/efi-bc.c
> Why does this require a driver? Why is it not possible to solve this
> problem by creating the variable in userspace before invoking
> reboot(2)?
Hi Matt,
It is possible, but that means modifying those userspace apps :)
There are reboot implementations that do "reboot <reason>", such as
Android's reboot command [1] and Upstart's reboot replacement [2], which
pass the reason as an argument to the reboot syscall.Â
Probably your first question will be - "Why don't you modify those
apps?" Well, I don't see platform-agnostic way how those could be
modified to pass the reason to the bootloader, regardless of platform or
bootloader.
Other non-EFI platforms use a driver as well:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/dri
vers/soc/tegra/pmc.c#n382
[1]Âhttps://android.googlesource.com/platform/system/core/+/master/libcu
tils/android_reboot.c#228
[2]Âhttps://bazaar.launchpad.net/~upstart-devel/upstart/trunk/view/head:
/util/reboot.c#L259
Cheers,
Stefan