Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755040AbcCRTSY (ORCPT ); Fri, 18 Mar 2016 15:18:24 -0400 Received: from mga02.intel.com ([134.134.136.20]:48889 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751321AbcCRTSW (ORCPT ); Fri, 18 Mar 2016 15:18:22 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,356,1455004800"; d="scan'208";a="672042793" From: "Stanacar, Stefan" To: "Baluta, Daniel" , "matt@codeblueprint.co.uk" CC: "linux-efi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Abbas, Mohamed" , "Gumbel, Matthew K" , "Musca, Constantin" , "Purdila, Octavian" Subject: Re: [PATCH v2] efi: Introduce EFI bootloader control driver Thread-Topic: [PATCH v2] efi: Introduce EFI bootloader control driver Thread-Index: AQHRgP4gz9DmkaiYq0aye7ci0K473J9fYK2AgAAzMIA= Date: Fri, 18 Mar 2016 19:18:17 +0000 Message-ID: <1458328697.16385.21.camel@intel.com> References: <1458295910-26557-1-git-send-email-daniel.baluta@intel.com> <20160318161505.GU2619@codeblueprint.co.uk> In-Reply-To: <20160318161505.GU2619@codeblueprint.co.uk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.237.105.93] Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u2IJITIm027882 Content-Length: 2441 Lines: 64 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 > > > > 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 > > Signed-off-by: Mohamed Abbas > > Signed-off-by: Constantin Musca > > Signed-off-by: Daniel Baluta > > --- > > 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 ", 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