* [PATCH 1/2] x86,efi: Check max_size only if it is non-zero.
@ 2013-04-10 8:59 Richard Weinberger
2013-04-10 8:59 ` [PATCH 2/2] x86,efi: Implement no_storage_paranoia parameter Richard Weinberger
2013-04-11 15:13 ` [PATCH 1/2] x86,efi: Check max_size only if it is non-zero Matt Fleming
0 siblings, 2 replies; 4+ messages in thread
From: Richard Weinberger @ 2013-04-10 8:59 UTC (permalink / raw)
To: matt.fleming
Cc: cbouatmailru, ccross, keescook, tony.luck, linux-efi,
linux-kernel, matthew.garrett, Richard Weinberger
Some EFI implementations return always a MaximumVariableSize of 0,
check against max_size only if it is non-zero.
My Intel DQ67SW desktop board has such an implementation.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/x86/platform/efi/efi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index c89c245..3f96a48 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -1018,7 +1018,12 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
if (status != EFI_SUCCESS)
return status;
- if (!storage_size || size > remaining_size || size > max_size ||
+ if (!max_size && remaining_size > size)
+ printk_once(KERN_ERR FW_BUG "Broken EFI implementation"
+ " is returning MaxVariableSize=0\n");
+
+ if (!storage_size || size > remaining_size ||
+ (max_size && size > max_size) ||
(remaining_size - size) < (storage_size / 2))
return EFI_OUT_OF_RESOURCES;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] x86,efi: Implement no_storage_paranoia parameter
2013-04-10 8:59 [PATCH 1/2] x86,efi: Check max_size only if it is non-zero Richard Weinberger
@ 2013-04-10 8:59 ` Richard Weinberger
[not found] ` <1365584375-9372-2-git-send-email-richard-/L3Ra7n9ekc@public.gmane.org>
2013-04-11 15:13 ` [PATCH 1/2] x86,efi: Check max_size only if it is non-zero Matt Fleming
1 sibling, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2013-04-10 8:59 UTC (permalink / raw)
To: matt.fleming
Cc: cbouatmailru, ccross, keescook, tony.luck, linux-efi,
linux-kernel, matthew.garrett, Richard Weinberger
Using this parameter one can disable the storage_size/2 check if
he is really sure that the UEFI does sane gc and fulfills the spec.
This parameter is useful if a devices uses more than 50% of the
storage by default.
The Intel DQSW67 desktop board is such an sucker for exmaple.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/x86/platform/efi/efi.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 3f96a48..1b0efb6 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -41,6 +41,7 @@
#include <linux/io.h>
#include <linux/reboot.h>
#include <linux/bcd.h>
+#include <linux/module.h>
#include <asm/setup.h>
#include <asm/efi.h>
@@ -71,6 +72,13 @@ static efi_system_table_t efi_systab __initdata;
unsigned long x86_efi_facility;
+static bool efivars_no_storage_paranoia;
+module_param_named(no_storage_paranoia, efivars_no_storage_paranoia, bool, 0644);
+MODULE_PARM_DESC(no_storage_paranoia, "Use this parameter only if you are very"
+ " sure that your EFI implemenation does sane garbage"
+ " collection and fulfills the UEFI spec."
+ " Otherwise your board may brick."
+ " See: http://mjg59.dreamwidth.org/#entry-22855");
/*
* Returns 1 if 'facility' is enabled, 0 otherwise.
*/
@@ -1023,7 +1031,10 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
" is returning MaxVariableSize=0\n");
if (!storage_size || size > remaining_size ||
- (max_size && size > max_size) ||
+ (max_size && size > max_size))
+ return EFI_OUT_OF_RESOURCES;
+
+ if (!efivars_no_storage_paranoia &&
(remaining_size - size) < (storage_size / 2))
return EFI_OUT_OF_RESOURCES;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] x86,efi: Check max_size only if it is non-zero.
2013-04-10 8:59 [PATCH 1/2] x86,efi: Check max_size only if it is non-zero Richard Weinberger
2013-04-10 8:59 ` [PATCH 2/2] x86,efi: Implement no_storage_paranoia parameter Richard Weinberger
@ 2013-04-11 15:13 ` Matt Fleming
1 sibling, 0 replies; 4+ messages in thread
From: Matt Fleming @ 2013-04-11 15:13 UTC (permalink / raw)
To: Richard Weinberger
Cc: cbouatmailru, ccross, keescook, tony.luck, linux-efi,
linux-kernel, matthew.garrett
On 10/04/13 09:59, Richard Weinberger wrote:
> Some EFI implementations return always a MaximumVariableSize of 0,
> check against max_size only if it is non-zero.
> My Intel DQ67SW desktop board has such an implementation.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> arch/x86/platform/efi/efi.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] x86,efi: Implement no_storage_paranoia parameter
[not found] ` <1365584375-9372-2-git-send-email-richard-/L3Ra7n9ekc@public.gmane.org>
@ 2013-04-11 15:19 ` Matt Fleming
0 siblings, 0 replies; 4+ messages in thread
From: Matt Fleming @ 2013-04-11 15:19 UTC (permalink / raw)
To: Richard Weinberger
Cc: cbouatmailru-Re5JQEeQqe8AvxtiuMwx3w,
ccross-z5hGa2qSFaRBDgjK7y7TUQ, keescook-F7+t8E8rja9g9hUCZPvPmw,
tony.luck-ral2JQCrhuEAvxtiuMwx3w,
linux-efi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
matthew.garrett-05XSO3Yj/JvQT0dZR+AlfA
On 10/04/13 09:59, Richard Weinberger wrote:
> Using this parameter one can disable the storage_size/2 check if
> he is really sure that the UEFI does sane gc and fulfills the spec.
>
> This parameter is useful if a devices uses more than 50% of the
> storage by default.
> The Intel DQSW67 desktop board is such an sucker for exmaple.
>
> Signed-off-by: Richard Weinberger <richard-/L3Ra7n9ekc@public.gmane.org>
> ---
> arch/x86/platform/efi/efi.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
> index 3f96a48..1b0efb6 100644
> --- a/arch/x86/platform/efi/efi.c
> +++ b/arch/x86/platform/efi/efi.c
> @@ -41,6 +41,7 @@
> #include <linux/io.h>
> #include <linux/reboot.h>
> #include <linux/bcd.h>
> +#include <linux/module.h>
>
> #include <asm/setup.h>
> #include <asm/efi.h>
> @@ -71,6 +72,13 @@ static efi_system_table_t efi_systab __initdata;
>
> unsigned long x86_efi_facility;
>
> +static bool efivars_no_storage_paranoia;
> +module_param_named(no_storage_paranoia, efivars_no_storage_paranoia, bool, 0644);
Could you rename this to 'efi_no_storage_paranoia' so that it isn't
confused with drivers/firmware/efivars.c? Also, it would be a good idea
to document this new kernel parameter in Documentation/kernel-parameters.
> +MODULE_PARM_DESC(no_storage_paranoia, "Use this parameter only if you are very"
> + " sure that your EFI implemenation does sane garbage"
> + " collection and fulfills the UEFI spec."
> + " Otherwise your board may brick."
> + " See: http://mjg59.dreamwidth.org/#entry-22855");
I think we should avoid including urls in the kernel source. The rest of
the description is fine.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-11 15:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-10 8:59 [PATCH 1/2] x86,efi: Check max_size only if it is non-zero Richard Weinberger
2013-04-10 8:59 ` [PATCH 2/2] x86,efi: Implement no_storage_paranoia parameter Richard Weinberger
[not found] ` <1365584375-9372-2-git-send-email-richard-/L3Ra7n9ekc@public.gmane.org>
2013-04-11 15:19 ` Matt Fleming
2013-04-11 15:13 ` [PATCH 1/2] x86,efi: Check max_size only if it is non-zero Matt Fleming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).