public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/efi: autoload efivars
@ 2014-07-08  3:00 Lee, Chun-Yi
       [not found] ` <1404788458-32105-1-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Lee, Chun-Yi @ 2014-07-08  3:00 UTC (permalink / raw)
  To: Matt Fleming
  Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, Lee, Chun-Yi, Ben Hutchings

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.

Cc: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
Cc: Matt Fleming <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Lee, Chun-Yi <jlee-IBi9RG/b67k@public.gmane.org>
---
 arch/x86/platform/efi/efi.c    | 15 +++++++++++++++
 drivers/firmware/efi/efivars.c |  1 +
 2 files changed, 16 insertions(+)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 87fc96b..c295c08 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -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;
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index 463c565..f256ecd 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch-DYMqY+WieiM@public.gmane.org>");
 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);
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/efi: autoload efivars
       [not found] ` <1404788458-32105-1-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
@ 2014-07-08 10:14   ` Matt Fleming
       [not found]     ` <20140708101434.GF27474-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Fleming @ 2014-07-08 10:14 UTC (permalink / raw)
  To: Lee, Chun-Yi
  Cc: Matt Fleming, linux-efi-u79uwXL29TY76Z2rM5mHXA, Lee, Chun-Yi,
	Ben Hutchings, Catalin Marinas, Leif Lindholm, Ard Biesheuvel

On Tue, 08 Jul, at 11:00:58AM, Lee, Chun-Yi wrote:
> 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.
> 
> Cc: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
> Cc: Matt Fleming <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Lee, Chun-Yi <jlee-IBi9RG/b67k@public.gmane.org>
> ---
>  arch/x86/platform/efi/efi.c    | 15 +++++++++++++++
>  drivers/firmware/efi/efivars.c |  1 +
>  2 files changed, 16 insertions(+)
> 
> diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
> index 87fc96b..c295c08 100644
> --- a/arch/x86/platform/efi/efi.c
> +++ b/arch/x86/platform/efi/efi.c
> @@ -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
> +

Could this be moved to drivers/firmware/efi/efi.c? That way the arm64
folks could benefit from it too.

>  void __init efi_set_executable(efi_memory_desc_t *md, bool executable)
>  {
>  	u64 addr, npages;
> diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
> index 463c565..f256ecd 100644
> --- a/drivers/firmware/efi/efivars.c
> +++ b/drivers/firmware/efi/efivars.c
> @@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch-DYMqY+WieiM@public.gmane.org>");
>  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);
> -- 
> 1.8.4.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-efi" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/efi: autoload efivars
       [not found]     ` <20140708101434.GF27474-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
@ 2014-07-08 12:19       ` Ben Hutchings
       [not found]         ` <1404821982.2489.8.camel-nDn/Rdv9kqW9Jme8/bJn5UCKIB8iOfG2tUK59QYPAWc@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Ben Hutchings @ 2014-07-08 12:19 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Lee, Chun-Yi, Matt Fleming, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	Lee, Chun-Yi, Catalin Marinas, Leif Lindholm, Ard Biesheuvel

[-- Attachment #1: Type: text/plain, Size: 2140 bytes --]

On Tue, 2014-07-08 at 11:14 +0100, Matt Fleming wrote:
> On Tue, 08 Jul, at 11:00:58AM, Lee, Chun-Yi wrote:
[...]
> > --- a/arch/x86/platform/efi/efi.c
> > +++ b/arch/x86/platform/efi/efi.c
> > @@ -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
> > +
> 
> 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.

> >  void __init efi_set_executable(efi_memory_desc_t *md, bool executable)
> >  {
> >  	u64 addr, npages;
> > diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
> > index 463c565..f256ecd 100644
> > --- a/drivers/firmware/efi/efivars.c
> > +++ b/drivers/firmware/efi/efivars.c
> > @@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch-DYMqY+WieiM@public.gmane.org>");
> >  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);
> > -- 
> > 1.8.4.5
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-efi" in
> > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/efi: autoload efivars
       [not found]         ` <1404821982.2489.8.camel-nDn/Rdv9kqW9Jme8/bJn5UCKIB8iOfG2tUK59QYPAWc@public.gmane.org>
@ 2014-07-09  6:40           ` joeyli
       [not found]             ` <20140709064050.GI18225-empE8CJ7fzk2xCFIczX1Fw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: joeyli @ 2014-07-09  6:40 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: Matt Fleming, Lee, Chun-Yi, Matt Fleming,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Catalin Marinas, Leif Lindholm,
	Ard Biesheuvel

On Tue, Jul 08, 2014 at 01:19:42PM +0100, Ben Hutchings wrote:
> On Tue, 2014-07-08 at 11:14 +0100, Matt Fleming wrote:
> > On Tue, 08 Jul, at 11:00:58AM, Lee, Chun-Yi wrote:
> [...]
> > > --- a/arch/x86/platform/efi/efi.c
> > > +++ b/arch/x86/platform/efi/efi.c
> > > @@ -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
> > > +
> > 
> > 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.
> 

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

> > >  void __init efi_set_executable(efi_memory_desc_t *md, bool executable)
> > >  {
> > >  	u64 addr, npages;
> > > diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
> > > index 463c565..f256ecd 100644
> > > --- a/drivers/firmware/efi/efivars.c
> > > +++ b/drivers/firmware/efi/efivars.c
> > > @@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch-DYMqY+WieiM@public.gmane.org>");
> > >  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);
> > > -- 
> > > 1.8.4.5
> > > 
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-efi" in
> > > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 
> -- 
> Ben Hutchings
> Any smoothly functioning technology is indistinguishable from a rigged demo.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/efi: autoload efivars
       [not found]             ` <20140709064050.GI18225-empE8CJ7fzk2xCFIczX1Fw@public.gmane.org>
@ 2014-07-11  7:47               ` Ard Biesheuvel
       [not found]                 ` <CAKv+Gu94e6Xay-m7YAPCA_frMiYWFWpsjaK1k6EwFSEhTL=-6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Ard Biesheuvel @ 2014-07-11  7:47 UTC (permalink / raw)
  To: joeyli
  Cc: Ben Hutchings, Matt Fleming, Lee, Chun-Yi, Matt Fleming,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Catalin Marinas, Leif Lindholm

On 9 July 2014 08:40, joeyli <jlee-IBi9RG/b67k@public.gmane.org> wrote:
> On Tue, Jul 08, 2014 at 01:19:42PM +0100, Ben Hutchings wrote:
>> On Tue, 2014-07-08 at 11:14 +0100, Matt Fleming wrote:
>> > On Tue, 08 Jul, at 11:00:58AM, Lee, Chun-Yi wrote:
>> [...]
>> > > --- a/arch/x86/platform/efi/efi.c
>> > > +++ b/arch/x86/platform/efi/efi.c
>> > > @@ -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
>> > > +
>> >
>> > 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.
>>
>
> 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.
>

Hi all,

I tested the version that is in Matt's -next now and it works fine on arm64.

-- 
Ard.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/efi: autoload efivars
       [not found]                 ` <CAKv+Gu94e6Xay-m7YAPCA_frMiYWFWpsjaK1k6EwFSEhTL=-6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-07-11  7:52                   ` Matt Fleming
       [not found]                     ` <20140711075255.GF5952-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Fleming @ 2014-07-11  7:52 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: joeyli, Ben Hutchings, Lee, Chun-Yi, Matt Fleming,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Catalin Marinas, Leif Lindholm

On Fri, 11 Jul, at 09:47:23AM, Ard Biesheuvel wrote:
> 
> 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?

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/efi: autoload efivars
       [not found]                     ` <20140711075255.GF5952-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
@ 2014-07-11  7:57                       ` Ard Biesheuvel
  0 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2014-07-11  7:57 UTC (permalink / raw)
  To: Matt Fleming
  Cc: joeyli, Ben Hutchings, Lee, Chun-Yi, Matt Fleming,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Catalin Marinas, Leif Lindholm

On 11 July 2014 09:52, Matt Fleming <matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org> wrote:
> On Fri, 11 Jul, at 09:47:23AM, Ard Biesheuvel wrote:
>>
>> 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,

Tested-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-07-11  7:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-08  3:00 [PATCH] x86/efi: autoload efivars Lee, Chun-Yi
     [not found] ` <1404788458-32105-1-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
2014-07-08 10:14   ` Matt Fleming
     [not found]     ` <20140708101434.GF27474-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-07-08 12:19       ` Ben Hutchings
     [not found]         ` <1404821982.2489.8.camel-nDn/Rdv9kqW9Jme8/bJn5UCKIB8iOfG2tUK59QYPAWc@public.gmane.org>
2014-07-09  6:40           ` joeyli
     [not found]             ` <20140709064050.GI18225-empE8CJ7fzk2xCFIczX1Fw@public.gmane.org>
2014-07-11  7:47               ` Ard Biesheuvel
     [not found]                 ` <CAKv+Gu94e6Xay-m7YAPCA_frMiYWFWpsjaK1k6EwFSEhTL=-6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-07-11  7:52                   ` Matt Fleming
     [not found]                     ` <20140711075255.GF5952-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2014-07-11  7:57                       ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox