x86/efi: autoload efivars
PATCH 1/1 x86/efi: autoload efivars
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 then patch 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.
--- arch/x86/platform/efi/efi.c | 15 +++++++++++++++ drivers/firmware/efi/efivars.c | 1 + 2 files changed, 16 insertions(+)
arch/x86/platform/efi/efi.c +15 -0
@@ -44,6 +44,7 @@#include <linux/io.h> #include <linux/reboot.h> #include <linux/bcd.h> +#include <linux/platform_device.h> #include <asm/setup.h> #include <asm/efi.h>
@@ -780,6 +781,20 @@ void __init efi_late_init(void)efi_bgrt_init (); } +#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 +void __init efi_set_executable (efi_memory_desc_t *md,bool executable) {u64 addr, npages;
drivers/firmware/efi/efivars.c +1 -0
@@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <[email protected]>");MODULE_DESCRIPTION ("sysfs interface to EFI Variables" );MODULE_LICENSE ("GPL" );MODULE_VERSION (EFIVARS_VERSION ); +MODULE_ALIAS ("platform:efivars" );LIST_HEAD (efivar_sysfs_list);EXPORT_SYMBOL_GPL (efivar_sysfs_list);
Signature · 1 line
1.8.4.5
A message that is not in the archive (sent off-list or not yet received): 1404788458-32105-1-git-send-email-jlee-IBi9RG/[email protected]
Quoted 42 lines · Chun-Yi
The original patch is from Ben Hutchings's contribution to debian kernel. Got Ben's permission to remove the code of
efi-pstore.cand then patch to linux-efi:
https://github.com/BlankOn/linux-debian/blob/master/debian/patches/features/all/efi-autoload-efivars.patchefivars 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.
Cc Ben Hutchings <ben-/[email protected]>Cc Matt Fleming <[email protected]>Signed-off-by Lee, Chun-Yi <jlee-IBi9RG/[email protected]>--- arch/x86/platform/efi/efi.c | 15 +++++++++++++++ drivers/firmware/efi/efivars.c | 1 + 2 files changed, 16 insertions(+)arch/x86/platform/efi/efi.c +5
-0@@ -44,6 +44,7 @@#include <linux/io.h> #include <linux/reboot.h> #include <linux/bcd.h> +#include <linux/platform_device.h> #include <asm/setup.h> #include <asm/efi.h> @@ -780,6 +781,20 @@ void __init efi_late_init(void)efi_bgrt_init (); } +#ifdef CONFIG_EFI_VARS_MODULE +static int __init efi_load_efivars (void ) +{ +struct platform_device *pdev;
arch/x86/platform/efi/efi.c void __init efi_late_init(void) · line 797
Quoted 10 lines
arch/x86/platform/efi/efi.c +10
-0+ +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 +
Could this be moved to drivers/firmware/efi/efi.c? That way the arm64 folks could benefit from it too.
Quoted 22 lines
arch/x86/platform/efi/efi.c +0
-0void __init efi_set_executable (efi_memory_desc_t *md,bool executable) {u64 addr, npages;drivers/firmware/efi/efivars.c +1
-0@@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <[email protected]>");MODULE_DESCRIPTION ("sysfs interface to EFI Variables" );MODULE_LICENSE ("GPL" );MODULE_VERSION (EFIVARS_VERSION ); +MODULE_ALIAS ("platform:efivars" );LIST_HEAD (efivar_sysfs_list);EXPORT_SYMBOL_GPL (efivar_sysfs_list);Signature · 6 lines
1.8.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
A message that is not in the archive (sent off-list or not yet received): 20140708101434.GF27474-HNK1S37rvNbeXh+fF434Mdi2O/[email protected]
Quoted 1 line · Matt Fleming
On Tue, 08 Jul, at 11:00:58AM, Lee, Chun-Yi wrote:
[...]
Quoted 23 lines
Quoted 23 lines
arch/x86/platform/efi/efi.c +10
-0@@ -44,6 +44,7 @@#include <linux/io.h> #include <linux/reboot.h> #include <linux/bcd.h> +#include <linux/platform_device.h> #include <asm/setup.h> #include <asm/efi.h> @@ -780,6 +781,20 @@ void __init efi_late_init(void)efi_bgrt_init (); } +#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 );
Quoted 8 lines
arch/x86/platform/efi/efi.c void __init efi_late_init(void) · line 797
Quoted 5 lines
arch/x86/platform/efi/efi.c +5
-0+ return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; +} +device_initcall (efi_load_efivars); +#endif +Could this be moved to
drivers/firmware/efi/efi.c? That way the arm64 folks could benefit from it too.
It seems like that should work now that efi_enabled() is not specific to x86.
Ben.
Quoted 23 lines
Quoted 22 lines
arch/x86/platform/efi/efi.c +0
-0void __init efi_set_executable (efi_memory_desc_t *md,bool executable) {u64 addr, npages;drivers/firmware/efi/efivars.c +1
-0@@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <[email protected]>");MODULE_DESCRIPTION ("sysfs interface to EFI Variables" );MODULE_LICENSE ("GPL" );MODULE_VERSION (EFIVARS_VERSION ); +MODULE_ALIAS ("platform:efivars" );LIST_HEAD (efivar_sysfs_list);EXPORT_SYMBOL_GPL (efivar_sysfs_list);Signature · 6 lines
1.8.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Ben Hutchings Any smoothly functioning technology is indistinguishable from a rigged demo.
A message that is not in the archive (sent off-list or not yet received): 1404821982.2489.8.camel-nDn/Rdv9kqW9Jme8/[email protected]
Quoted 35 lines · Ben Hutchings
Quoted 1 line · Matt Fleming
On Tue, 08 Jul, at 11:00:58AM, Lee, Chun-Yi wrote:
[...]
Quoted 23 lines
Quoted 23 lines
arch/x86/platform/efi/efi.c +10
-0@@ -44,6 +44,7 @@#include <linux/io.h> #include <linux/reboot.h> #include <linux/bcd.h> +#include <linux/platform_device.h> #include <asm/setup.h> #include <asm/efi.h> @@ -780,6 +781,20 @@ void __init efi_late_init(void)efi_bgrt_init (); } +#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 );Quoted 8 lines
arch/x86/platform/efi/efi.c void __init efi_late_init(void) · line 797
Quoted 5 lines
arch/x86/platform/efi/efi.c +5
-0+ return IS_ERR(pdev) ? PTR_ERR(pdev) : 0; +} +device_initcall (efi_load_efivars); +#endif +Could this be moved to
drivers/firmware/efi/efi.c? That way the arm64 folks could benefit from it too.
Quoted 5 lines
It seems like that should work now that
efi_enabled()is not specific to x86.Ben.
Thanks for Matt and Ban's review, I will move platform device register code to drivers/firmware/efi/efi.c and send version 2 patch.
Joey Lee
Quoted 27 lines
Quoted 23 lines
Quoted 22 lines
arch/x86/platform/efi/efi.c +0
-0void __init efi_set_executable (efi_memory_desc_t *md,bool executable) {u64 addr, npages;drivers/firmware/efi/efivars.c +1
-0@@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <[email protected]>");MODULE_DESCRIPTION ("sysfs interface to EFI Variables" );MODULE_LICENSE ("GPL" );MODULE_VERSION (EFIVARS_VERSION ); +MODULE_ALIAS ("platform:efivars" );LIST_HEAD (efivar_sysfs_list);EXPORT_SYMBOL_GPL (efivar_sysfs_list);Signature · 6 lines
1.8.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 2 lines
Ben Hutchings Any smoothly functioning technology is indistinguishable from a rigged demo.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 36 lines · joeyli
Quoted 35 lines · Ben Hutchings
Quoted 1 line · Matt Fleming
On Tue, 08 Jul, at 11:00:58AM, Lee, Chun-Yi wrote:
[...]
Quoted 31 lines
Quoted 18 lines
arch/x86/platform/efi/efi.c +5
-0@@ -44,6 +44,7 @@#include <linux/io.h> #include <linux/reboot.h> #include <linux/bcd.h> +#include <linux/platform_device.h> #include <asm/setup.h> #include <asm/efi.h> @@ -780,6 +781,20 @@ void __init efi_late_init(void)efi_bgrt_init (); } +#ifdef CONFIG_EFI_VARS_MODULE +static int __init efi_load_efivars (void ) +{ +struct platform_device *pdev;arch/x86/platform/efi/efi.c void __init efi_late_init(void) · line 797
Quoted 10 lines
arch/x86/platform/efi/efi.c +10
-0+ +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 +Could this be moved to
drivers/firmware/efi/efi.c? That way the arm64 folks could benefit from it too.
Quoted 9 lines
Quoted 5 lines
It seems like that should work now that
efi_enabled()is not specific to x86.Ben.
Thanks for Matt and Ban's review, I will move platform device register code to
drivers/firmware/efi/efi.cand send version 2 patch.
Hi all,
I tested the version that is in Matt's -next now and it works fine on arm64.
Signature · 1 line
Ard.
A message that is not in the archive (sent off-list or not yet received): CAKv+Gu94e6Xay-m7YAPCA_frMiYWFWpsjaK1k6EwFSEhTL=-6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 4 lines · Ard Biesheuvel
Hi all,
I tested the version that is in Matt's -next now and it works fine on arm64.
Great, thanks Ard. May I add your Tested-by to the patch?
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
A message that is not in the archive (sent off-list or not yet received): 20140711075255.GF5952-HNK1S37rvNbeXh+fF434Mdi2O/[email protected]
Ard Biesheuvel
Tested-byQuoted 8 lines · Matt Fleming
Quoted 4 lines · Ard Biesheuvel
Hi all,
I tested the version that is in Matt's -next now and it works fine on arm64.
Great, thanks Ard. May I add your Tested-by to the patch?
Sure,