From: "Lee, Chun-Yi" Date: Wed, 9 Jul 2014 18:39:29 +0800 Subject: efi: Autoload efivars Bug-Debian: https://bugs.debian.org/703363 Origin: https://git.kernel.org/linus/28d54022e6ff9c16bf4dacb5f64a97443a38caa9 The original patch is from Ben Hutchings's contribution to debian kernel. Got Ben's permission to remove the code of efi-pstore.c and send to linux-efi: https://github.com/BlankOn/linux-debian/blob/master/debian/patches/features/all/efi-autoload-efivars.patch efivars is generally useful to have on EFI systems, and in some cases it may be impossible to load it after a kernel upgrade in order to complete a boot loader update. At the same time we don't want to waste memory on non-EFI systems by making them built-in. Instead, give them module aliases as if they are platform drivers, and register a corresponding platform device whenever EFI runtime services are available. This should trigger udev to load them. Signed-off-by: Lee, Chun-Yi Cc: Ben Hutchings Tested-by: Ard Biesheuvel Signed-off-by: Matt Fleming --- drivers/firmware/efi/efi.c | 15 +++++++++++++++ drivers/firmware/efi/efivars.c | 1 + 2 files changed, 16 insertions(+) --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -23,6 +23,7 @@ #include #include #include +#include struct efi __read_mostly efi = { .mps = EFI_INVALID_TABLE_ADDR, @@ -321,6 +322,20 @@ int __init efi_config_init(efi_config_ta return 0; } +#ifdef CONFIG_EFI_VARS_MODULE +static int __init efi_load_efivars(void) +{ + struct platform_device *pdev; + + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return 0; + + pdev = platform_device_register_simple("efivars", 0, NULL, 0); + return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; +} +device_initcall(efi_load_efivars); +#endif + #ifdef CONFIG_EFI_PARAMS_FROM_FDT #define UEFI_PARAM(name, prop, field) \ --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c @@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch