From: Matthew Garrett <matthew.garrett@nebula.com>
To: matt.fleming@intel.com
Cc: linux-efi@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org,
Matthew Garrett <matthew.garrett@nebula.com>
Subject: [PATCH V4 2/3] Revert "x86, efivars: firmware bug workarounds should be in platform code"
Date: Wed, 10 Apr 2013 13:46:06 -0400 [thread overview]
Message-ID: <1365615967-27346-2-git-send-email-matthew.garrett@nebula.com> (raw)
In-Reply-To: <1365615967-27346-1-git-send-email-matthew.garrett@nebula.com>
This reverts commit a6e4d5a03e9e3587e88aba687d8f225f4f04c792. Doing this
workaround properly requires us to work within the variable code.
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
---
arch/x86/platform/efi/efi.c | 25 -------------------------
drivers/firmware/efivars.c | 18 +++++++++++++++---
include/linux/efi.h | 9 +--------
3 files changed, 16 insertions(+), 36 deletions(-)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 659da48..fdc5074 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -1023,28 +1023,3 @@ u64 efi_mem_attributes(unsigned long phys_addr)
}
return 0;
}
-
-/*
- * Some firmware has serious problems when using more than 50% of the EFI
- * variable store, i.e. it triggers bugs that can brick machines. Ensure that
- * we never use more than this safe limit.
- *
- * Return EFI_SUCCESS if it is safe to write 'size' bytes to the variable
- * store.
- */
-efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
-{
- efi_status_t status;
- u64 storage_size, remaining_size, max_size;
-
- status = efi.query_variable_info(attributes, &storage_size,
- &remaining_size, &max_size);
- if (status != EFI_SUCCESS)
- return status;
-
- if (!storage_size || size > remaining_size || size > max_size ||
- (remaining_size - size) < (storage_size / 2))
- return EFI_OUT_OF_RESOURCES;
-
- return EFI_SUCCESS;
-}
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 684a118..60e7d8f 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -439,12 +439,24 @@ static efi_status_t
check_var_size_locked(struct efivars *efivars, u32 attributes,
unsigned long size)
{
+ u64 storage_size, remaining_size, max_size;
+ efi_status_t status;
const struct efivar_operations *fops = efivars->ops;
- if (!efivars->ops->query_variable_store)
+ if (!efivars->ops->query_variable_info)
return EFI_UNSUPPORTED;
- return fops->query_variable_store(attributes, size);
+ status = fops->query_variable_info(attributes, &storage_size,
+ &remaining_size, &max_size);
+
+ if (status != EFI_SUCCESS)
+ return status;
+
+ if (!storage_size || size > remaining_size || size > max_size ||
+ (remaining_size - size) < (storage_size / 2))
+ return EFI_OUT_OF_RESOURCES;
+
+ return status;
}
@@ -2144,7 +2156,7 @@ efivars_init(void)
ops.get_variable = efi.get_variable;
ops.set_variable = efi.set_variable;
ops.get_next_variable = efi.get_next_variable;
- ops.query_variable_store = efi_query_variable_store;
+ ops.query_variable_info = efi.query_variable_info;
#ifdef CONFIG_X86
boot_used_size = efi_var_store_size - efi_var_remaining_size;
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 3d7df3d..9bf2f1f 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -333,7 +333,6 @@ typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules,
unsigned long count,
u64 *max_size,
int *reset_type);
-typedef efi_status_t efi_query_variable_store_t(u32 attributes, unsigned long size);
/*
* EFI Configuration Table and GUID definitions
@@ -576,15 +575,9 @@ extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if pos
#ifdef CONFIG_X86
extern void efi_late_init(void);
extern void efi_free_boot_services(void);
-extern efi_status_t efi_query_variable_store(u32 attributes, unsigned long size);
#else
static inline void efi_late_init(void) {}
static inline void efi_free_boot_services(void) {}
-
-static inline efi_status_t efi_query_variable_store(u32 attributes, unsigned long size)
-{
- return EFI_SUCCESS;
-}
#endif
extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr);
extern u64 efi_get_iobase (void);
@@ -738,7 +731,7 @@ struct efivar_operations {
efi_get_variable_t *get_variable;
efi_get_next_variable_t *get_next_variable;
efi_set_variable_t *set_variable;
- efi_query_variable_store_t *query_variable_store;
+ efi_query_variable_info_t *query_variable_info;
};
struct efivars {
--
1.8.1.2
next prev parent reply other threads:[~2013-04-10 17:46 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 2:41 [PATCH 1/3] efi: Determine how much space is used by boot services-only variables Matthew Garrett
2013-04-10 2:41 ` [PATCH 2/3] Revert "x86, efivars: firmware bug workarounds should be in platform code" Matthew Garrett
2013-04-10 2:41 ` [PATCH 3/3] efi: Distinguish between "remaining space" and actually used space Matthew Garrett
2013-04-10 6:02 ` Lingzhu Xiang
2013-04-10 17:46 ` [PATCH V4 1/3] efi: Determine how much space is used by boot services-only variables Matthew Garrett
2013-04-10 17:46 ` Matthew Garrett [this message]
2013-04-11 13:24 ` [PATCH V4 2/3] Revert "x86, efivars: firmware bug workarounds should be in platform code" Matt Fleming
2013-04-11 13:30 ` Matthew Garrett
2013-04-10 17:46 ` [PATCH V4 3/3] efi: Distinguish between "remaining space" and actually used space Matthew Garrett
2013-04-12 10:16 ` [PATCH V4 1/3] efi: Determine how much space is used by boot services-only variables Lingzhu Xiang
2013-04-12 10:22 ` Matt Fleming
2013-04-12 12:19 ` Lingzhu Xiang
2013-04-15 15:53 ` [PATCH V5 1/2] efi: Pass boot services variable info to runtime code Matthew Garrett
2013-04-15 15:53 ` [PATCH V5 2/2] efi: Distinguish between "remaining space" and actually used space Matthew Garrett
2013-04-15 20:09 ` Fix UEFI variable paranoia Matthew Garrett
2013-04-15 20:09 ` [PATCH V6 1/3] Move utf16 functions to kernel core and rename Matthew Garrett
2013-04-15 20:09 ` [PATCH V6 2/3] efi: Pass boot services variable info to runtime code Matthew Garrett
2013-04-22 15:03 ` Paul Bolle
2013-04-15 20:09 ` [PATCH V6 3/3] efi: Distinguish between "remaining space" and actually used space Matthew Garrett
2013-04-16 14:31 ` [PATCH 1/2] x86/Kconfig: Make EFI select UCS2_STRING Sergey Vlasov
2013-04-16 14:31 ` [PATCH 2/2] efi: Export efi_query_variable_store() for efivars.ko Sergey Vlasov
2013-04-16 16:39 ` Matt Fleming
2013-04-16 16:39 ` [PATCH 1/2] x86/Kconfig: Make EFI select UCS2_STRING Matt Fleming
2013-04-17 10:49 ` [PATCH V6 3/3] efi: Distinguish between "remaining space" and actually used space Lingzhu Xiang
2013-04-24 10:08 ` joeyli
2013-04-24 10:14 ` Matthew Garrett
2013-04-24 10:59 ` joeyli
2013-04-24 11:57 ` Matthew Garrett
2013-04-24 13:23 ` joeyli
2013-04-16 10:15 ` Fix UEFI variable paranoia Matt Fleming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365615967-27346-2-git-send-email-matthew.garrett@nebula.com \
--to=matthew.garrett@nebula.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®