efivars: Allow disabling use as a pstore backend
PATCH 1/1 efivars: Allow disabling use as a pstore backend
We know that with some firmware implementations writing too much data to UEFI variables can lead to bricking machines. Recent changes attempt to address this issue, but for some it may still be prudent to avoid writing large amounts of data until the solution has been proven on a wide variety of hardware.
Crash dumps or other data from pstore can potentially be a large data source. Add a new option, CONFIG_EFI_VARS_PSTORE, which can be set to N to avoid using efivars as a backend to pstore.
--- drivers/firmware/Kconfig | 9 +++++++ drivers/firmware/efivars.c | 64 ++++++++++++++------------------------------ 2 files changed, 29 insertions(+), 44 deletions(-)
drivers/firmware/Kconfig +9 -0
@@ -53,6 +53,15 @@ config EFI_VARS Subsequent efibootmgr releases may be found at: <http://linux.dell.com/efibootmgr> +config EFI_VARS_PSTORE + bool "Register efivars backend for pstore" + depends on EFI_VARS && PSTORE + default y + help + Say Y here to enable use efivars as a backend to pstore. This + will allow writing console messages, crash dumps, or anything + else supported by pstore to EFI variables. + config EFI_PCDP bool "Console device selection via EFI PCDP or HCDP table" depends on ACPI && EFI && IA64
drivers/firmware/efivars.c +20 -44
88 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 9 lines · Seth Forshee
We know that with some firmware implementations writing too much data to UEFI variables can lead to bricking machines. Recent changes attempt to address this issue, but for some it may still be prudent to avoid writing large amounts of data until the solution has been proven on a wide variety of hardware.
Crash dumps or other data from pstore can potentially be a large data source. Add a new option,
CONFIG_EFI_VARS_PSTORE, which can be set to N to avoid using efivars as a backend to pstore.
What about a command line option?
drivers/firmware/efivars.c static const struct inode_operations efivarfs_dir_inode_operations = { · line 1256
Quoted 2 lines
drivers/firmware/efivars.c +1
-1-#ifdef CONFIG_PSTORE +#if defined(CONFIG_PSTORE ) && defined(CONFIG_EFI_VARS_PSTORE )
Redundant.
-hpa
Quoted 7 lines · H. Peter Anvin
Quoted 6 lines · Seth Forshee
We know that with some firmware implementations writing too much data to UEFI variables can lead to bricking machines. Recent changes attempt to address this issue, but for some it may still be prudent to avoid writing large amounts of data until the solution has been proven on a wide variety of hardware.
Quoted 5 lines
Quoted 3 lines
Crash dumps or other data from pstore can potentially be a large data source. Add a new option,
CONFIG_EFI_VARS_PSTORE, which can be set to N to avoid using efivars as a backend to pstore.What about a command line option?
That could be done. I'm assuming you want this instead of a config option, defaulted to on?
How would you feel about a config option for the default value of the command line option? I intend to default this to off in Ubuntu for a while as a colleague's machine was recently bricked on two different occasions after the kernel oopsed. The config option would simplify things a bit for us, though we could always carry a patch changing the default value.
Quoted 4 lines
drivers/firmware/efivars.c static const struct inode_operations efivarfs_dir_inode_operations = { · line 1256
Quoted 2 lines
drivers/firmware/efivars.c +1
-1-#ifdef CONFIG_PSTORE +#if defined(CONFIG_PSTORE ) && defined(CONFIG_EFI_VARS_PSTORE )Redundant.
Yes, good point.
Thanks,
Seth
Quoted 17 lines · Seth Forshee
Quoted 7 lines · H. Peter Anvin
Quoted 6 lines · Seth Forshee
We know that with some firmware implementations writing too much data to UEFI variables can lead to bricking machines. Recent changes attempt to address this issue, but for some it may still be prudent to avoid writing large amounts of data until the solution has been proven on a wide variety of hardware.
Quoted 5 lines
Quoted 3 lines
Crash dumps or other data from pstore can potentially be a large data source. Add a new option,
CONFIG_EFI_VARS_PSTORE, which can be set to N to avoid using efivars as a backend to pstore.What about a command line option?
That could be done. I'm assuming you want this instead of a config option, defaulted to on?
Quoted 6 lines
How would you feel about a config option for the default value of the command line option? I intend to default this to off in Ubuntu for a while as a colleague's machine was recently bricked on two different occasions after the kernel oopsed. The config option would simplify things a bit for us, though we could always carry a patch changing the default value.
Not sure why a command line option would be a more natural solution to this problem? The original patch looked fine to me. All other pstore backends are guarded by Kconfig options.
Though I could see an argument for a kernel parameter to turn off the EFI pstore backend code, even if it's compiled into the kernel. But that would be better as an additional patch.
Quoted 13 lines · Matt Fleming
Quoted 6 lines
Quoted 2 lines
What about a command line option?
That could be done. I'm assuming you want this instead of a config option, defaulted to on?
Quoted 6 lines
How would you feel about a config option for the default value of the command line option? I intend to default this to off in Ubuntu for a while as a colleague's machine was recently bricked on two different occasions after the kernel oopsed. The config option would simplify things a bit for us, though we could always carry a patch changing the default value.
Quoted 8 lines
Not sure why a command line option would be a more natural solution to this problem? The original patch looked fine to me. All other pstore backends are guarded by
Kconfigoptions.Though I could see an argument for a kernel parameter to turn off the EFI pstore backend code, even if it's compiled into the kernel. But that would be better as an additional patch.
That way it can be enabled if needed, without the user having to build their own kernel.
-hpa
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Quoted 18 lines · H. Peter Anvin
Quoted 17 lines · Matt Fleming
Quoted 6 lines
Quoted 2 lines
What about a command line option?
That could be done. I'm assuming you want this instead of a config option, defaulted to on?
Quoted 6 lines
How would you feel about a config option for the default value of the command line option? I intend to default this to off in Ubuntu for a while as a colleague's machine was recently bricked on two different occasions after the kernel oopsed. The config option would simplify things a bit for us, though we could always carry a patch changing the default value.
Not sure why a command line option would be a more natural solution to this problem? The original patch looked fine to me. All other pstore backends are guarded by
Kconfigoptions.
Quoted 7 lines
Quoted 4 lines
Though I could see an argument for a kernel parameter to turn off the EFI pstore backend code, even if it's compiled into the kernel. But that would be better as an additional patch.
That way it can be enabled if needed, without the user having to build their own kernel.
Here's a patch that does the command line option. I'm happy with either one.
Quoted 1 line
From
2febf7014f6fa0abf05326504423749505430b3fMon Sep 17 00:00:00 2001
From: Seth Forshee <[email protected]>
Date: Wed, 6 Mar 2013 14:25:36 -0600
Subject: [PATCH] efivars: Add module parameter to disable use as a pstore
backend
We know that with some firmware implementations writing too much data to UEFI variables can lead to bricking machines. Recent changes attempt to address this issue, but for some it may still be prudent to avoid writing large amounts of data until the solution has been proven on a wide variety of hardware.
Crash dumps or other data from pstore can potentially be a large data source. Add a pstore_module parameter to efivars to allow disabling its use as a backend for pstore. Also add a config option, CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE, to allow setting the default value of this paramter to true (i.e. disabled by default).
--- drivers/firmware/Kconfig | 9 ++++++ drivers/firmware/efivars.c | 70 +++++++++++++++++--------------------------- 2 files changed, 36 insertions(+), 43 deletions(-)
drivers/firmware/Kconfig +9 -0
@@ -53,6 +53,15 @@ config EFI_VARS Subsequent efibootmgr releases may be found at: <http://linux.dell.com/efibootmgr> +config EFI_VARS_PSTORE_DEFAULT_DISABLE + bool "Disable using efivars as a pstore backend by default" + depends on EFI_VARS && PSTORE + default n + help + Saying Y here will disable the use of efivars as a storage + backend for pstore by default. This setting can be overridden + using the efivars module's pstore_disable parameter. + config EFI_PCDP bool "Console device selection via EFI PCDP or HCDP table" depends on ACPI && EFI && IA64
drivers/firmware/efivars.c +27 -43
100 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 2 lines · Seth Forshee
Here's a patch that does the command line option. I'm happy with either one.
I like the idea, but isn't the logic backwards? I would have expected s/EFI_VARS_PSTORE_DEFAULT_DISABLE/EFI_VARS_PSTORE/g and then 'default y' in the Kconfig file to maintain backward compatibility?
Is there a reason that wouldn't work?
I know that Linus has previously denounced setting new Kconfig symbols to 'y' by default, but I think there's a case here for doing exactly that since the previous behaviour was always enabled. The networking folks did something similar recently, where they introduced new Kconfig symbols for existing functionality that was previously on by default.
[...]
drivers/firmware/efivars.c MODULE_VERSION(EFIVARS_VERSION); · line 112
Quoted 7 lines
drivers/firmware/efivars.c +7
-0+#ifdef CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE +static bool efivars_pstore_disable = true; +#else +static bool efivars_pstore_disable = false; +#endif +module_param_named (pstore_disable, efivars_pstore_disable, bool,0644 ); +
static bool efivars_pstore_enable = IS_ENABLED(CONFIG_EFI_VARS_PSTORE) ?
Quoted 9 lines · Matt Fleming
Quoted 2 lines · Seth Forshee
Here's a patch that does the command line option. I'm happy with either one.
I like the idea, but isn't the logic backwards? I would have expected s/EFI_VARS_PSTORE_DEFAULT_DISABLE/EFI_VARS_PSTORE/g and then 'default y' in the
Kconfigfile to maintain backward compatibility?Is there a reason that wouldn't work?
It should work, just a change of perspective I guess. When the feature is enabled by default a foo_disable parameter feels more natural to me than foo_enable, but it's just semantics. I've switched it to your suggestion in the patch below. I must admit that the name of the config option is much better this way.
Quoted 8 lines
I know that Linus has previously denounced setting new
Kconfigsymbols to 'y' by default, but I think there's a case here for doing exactly that since the previous behaviour was always enabled. The networking folks did something similar recently, where they introduced newKconfigsymbols for existing functionality that was previously on by default.[...]
Quoted 9 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+#ifdef CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE +static bool efivars_pstore_disable = true; +#else +static bool efivars_pstore_disable = false; +#endif +module_param_named(pstore_disable, efivars_pstore_disable, bool, 0644); +static bool
efivars_pstore_enable=IS_ENABLED(CONFIG_EFI_VARS_PSTORE)?
Yes, that's much nicer.
Quoted 1 line
From
91df4dd0d1e20f44ea16b3653cffecd507fdb500Mon Sep 17 00:00:00 2001
From: Seth Forshee <[email protected]>
Date: Wed, 6 Mar 2013 14:25:36 -0600
Subject: [PATCH] efivars: Add module parameter to allow disabling use as a
pstore backend
We know that with some firmware implementations writing too much data to UEFI variables can lead to bricking machines. Recent changes attempt to address this issue, but for some it may still be prudent to avoid writing large amounts of data until the solution has been proven on a wide variety of hardware.
Crash dumps or other data from pstore can potentially be a large data source. Add a pstore_enable parameter to efivars to allow disabling its use as a backend for pstore. Also add a config option, CONFIG_EFI_VARS_PSTORE, which will specify the default value for this parameter. Default this option to Y to maintain the existing behavior.
--- drivers/firmware/Kconfig | 9 ++++++ drivers/firmware/efivars.c | 66 +++++++++++++++----------------------------- 2 files changed, 32 insertions(+), 43 deletions(-)
drivers/firmware/Kconfig +9 -0
@@ -53,6 +53,15 @@ config EFI_VARS Subsequent efibootmgr releases may be found at: <http://linux.dell.com/efibootmgr> +config EFI_VARS_PSTORE + bool "Use efivars as a pstore backend" + depends on EFI_VARS + default y + help + Say Y here to enable the use of efivars as a storage backend + for pstore. This setting can be overridden using the + efivars.pstore_enable parameter. + config EFI_PCDP bool "Console device selection via EFI PCDP or HCDP table" depends on ACPI && EFI && IA64
drivers/firmware/efivars.c +23 -43
96 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 18 lines · Seth Forshee
From
91df4dd0d1e20f44ea16b3653cffecd507fdb500Mon Sep 17 00:00:00 2001
From: Seth Forshee <[email protected]>
Date: Wed, 6 Mar 2013 14:25:36 -0600
Subject: [PATCH] efivars: Add module parameter to allow disabling use as a
pstore backendWe know that with some firmware implementations writing too much data to UEFI variables can lead to bricking machines. Recent changes attempt to address this issue, but for some it may still be prudent to avoid writing large amounts of data until the solution has been proven on a wide variety of hardware.
Crash dumps or other data from pstore can potentially be a large data source. Add a
pstore_enableparameter to efivars to allow disabling its use as a backend for pstore. Also add a config option,CONFIG_EFI_VARS_PSTORE, which will specify the default value for this parameter. Default this option to Y to maintain the existing behavior.
Quoted 5 lines
Signed-off-by Seth Forshee <[email protected]>--- drivers/firmware/Kconfig | 9 ++++++ drivers/firmware/efivars.c | 66 +++++++++++++++----------------------------- 2 files changed, 32 insertions(+), 43 deletions(-)
Thanks for sticking with this Seth. I think this is a nice solution. I've tossed this patch into my urgent queue and tagged it for stable and added some Cc's.
I did make one minor adjustment below. Let me know if you disagree.
Peter, are you happy with this version?
Quoted 7 lines
drivers/firmware/Kconfig +0
-0@@ -53,6 +53,15 @@ config EFI_VARS Subsequent efibootmgr releases may be found at: <http://linux.dell.com/efibootmgr>
drivers/firmware/Kconfig config EFI_VARS · line 64
Quoted 10 lines
drivers/firmware/Kconfig +9
-0+config EFI_VARS_PSTORE + bool "Use efivars as a pstore backend" + depends on EFI_VARS + default y + help + Say Y here to enable the use of efivars as a storage backend + for pstore. This setting can be overridden using the + efivars.pstore_enable parameter. +
The depends here should probably include PSTORE, which I think it did on previous iterations. I can't think of a situation where you'd want to disable CONFIG_PSTORE but enable CONFIG_EFI_VARS_PSTORE. Also, we don't need to use CONFIG_EFI_VARS_PSTORE solely for the purpose of setting the initial value of efivars_pstore_enabled - there's merit in also using it to leave out the pstore code in efivars.c during compilation.
Granted, this change does mean that your decision at compile time may be final, and you can't enable the pstore code at runtime if you built your kernel/efivars module with CONFIG_EFI_VARS_PSTORE=n. Arguably, I think that's a feature that some people will want, e.g. "Don't allow enabling the efivars pstore backend at all... no, srsly!".
[...]
drivers/firmware/Kconfig static const struct inode_operations efivarfs_dir_inode_operations = { · line 1315
Quoted 7 lines
drivers/firmware/Kconfig +0
-2@@ -1309,8 +1312,6 @@ static const struct inode_operations efivarfs_dir_inode_operations = { .create = efivarfs_create, }; -static struct pstore_info efi_pstore_info; - #ifdef CONFIG_PSTORE
... I've changed this to #ifdef CONFIG_EFI_VARS_PSTORE, since if CONFIG_EFI_VARS_PSTORE=n there's no point compiling the pstore code.
Quoted 25 lines · Matt Fleming
Quoted 7 lines
drivers/firmware/Kconfig +0
-0@@ -53,6 +53,15 @@ config EFI_VARS Subsequent efibootmgr releases may be found at: <http://linux.dell.com/efibootmgr>drivers/firmware/Kconfig config EFI_VARS · line 64
Quoted 10 lines
drivers/firmware/Kconfig +9
-0+config EFI_VARS_PSTORE + bool "Use efivars as a pstore backend" + depends on EFI_VARS + default y + help + Say Y here to enable the use of efivars as a storage backend + for pstore. This setting can be overridden using the + efivars.pstore_enable parameter. +The depends here should probably include PSTORE, which I think it did on previous iterations. I can't think of a situation where you'd want to disable
CONFIG_PSTOREbut enableCONFIG_EFI_VARS_PSTORE. Also, we don't need to useCONFIG_EFI_VARS_PSTOREsolely for the purpose of setting the initial value ofefivars_pstore_enabled- there's merit in also using it to leave out the pstore code inefivars.cduring compilation.
Quoted 5 lines
Granted, this change does mean that your decision at compile time may be final, and you can't enable the pstore code at runtime if you built your kernel/efivars module with
CONFIG_EFI_VARS_PSTORE=n. Arguably, I think that's a feature that some people will want, e.g. "Don't allow enabling the efivars pstore backend at all... no, srsly!".
Hmm. Since my original patch was to compile pstore support out completely, I interpreted Peter's suggestion to be allowing the user override the default even if the default is disabled. That's the assumption my implementation was based off of, but maybe I misunderstood.
But if Peter agrees with your changes then I'm fine with them too.
Thanks,
Seth
Quoted 7 lines · Seth Forshee
Quoted 6 lines
Granted, this change does mean that your decision at compile time may be final, and you can't enable the pstore code at runtime if you built your kernel/efivars module with
CONFIG_EFI_VARS_PSTORE=n. Arguably, I think that's a feature that some people will want, e.g. "Don't allow enabling the efivars pstore backend at all... no, srsly!".
Quoted 8 lines
Hmm. Since my original patch was to compile pstore support out completely, I interpreted Peter's suggestion to be allowing the user override the default even if the default is disabled. That's the assumption my implementation was based off of, but maybe I misunderstood.
But if Peter agrees with your changes then I'm fine with them too.
I think there should be two compile-time options (one to compile in the EFI pstore code at all, and one to set its default.)
-hpa
Quoted 2 lines · H. Peter Anvin
I think there should be two compile-time options (one to compile in the EFI pstore code at all, and one to set its default.)
OK, sorry Seth, looks like I'm the one that misunderstood. I've picked up your first two patches and pushed them out to the urgent branch. Please check that they look OK - they required minor fixups.
Quoted 7 lines · Matt Fleming
Quoted 2 lines · H. Peter Anvin
I think there should be two compile-time options (one to compile in the EFI pstore code at all, and one to set its default.)
OK, sorry Seth, looks like I'm the one that misunderstood. I've picked up your first two patches and pushed them out to the urgent branch. Please check that they look OK - they required minor fixups.
A minor nit from the second patch:
+static bool efivars_pstore_disable = \
+ IS_ENABLED(EFI_VARS_PSTORE_DEFAULT_DISABLE);
The backslash isn't necessary.
Otherwise everything looks fine afaict.
Thanks,
Seth
Quoted 14 lines · Seth Forshee
Quoted 7 lines · Matt Fleming
Quoted 2 lines · H. Peter Anvin
I think there should be two compile-time options (one to compile in the EFI pstore code at all, and one to set its default.)
OK, sorry Seth, looks like I'm the one that misunderstood. I've picked up your first two patches and pushed them out to the urgent branch. Please check that they look OK - they required minor fixups.
A minor nit from the second patch:
(quoted diff) +2
-0+static bool efivars_pstore_disable = \ + IS_ENABLED(EFI_VARS_PSTORE_DEFAULT_DISABLE);
Quoted 1 line
The backslash isn't necessary.
Whoops. Fixed.
Quoted 1 line
Otherwise everything looks fine afaict.
Thanks!