Re: [PATCH 1/2] efi: Determine how much space is used by bootservices-only variables

From: Ben Hutchings
Date: Mon Apr 01 2013 - 11:43:11 EST


On Mon, 2013-04-01 at 11:13 -0400, Matthew Garrett wrote:
> EFI variables can be flagged as being accessible only within boot services.
> This makes it awkward for us to figure out how much space they use at
> runtime. In theory we could figure this out by simply comparing the results
> from QueryVariableInfo() to the space used by all of our variables, but
> that fails if the platform doesn't garbage collect on every boot. Thankfully,
> calling QueryVariableInfo() while still inside boot services gives a more
> reliable answer. This patch passes that information from the EFI boot stub
> up to the efivars code, letting us calculate a reasonably accurate value.

Good thinking.

> Signed-off-by: Matthew Garrett <matthew.garrett@xxxxxxxxxx>
> ---
[...]
> --- a/arch/x86/platform/efi/efi.c
> +++ b/arch/x86/platform/efi/efi.c
> @@ -71,6 +71,10 @@ static efi_system_table_t efi_systab __initdata;
>
> unsigned long x86_efi_facility;
>
> +u64 efi_var_store_size;
> +u64 efi_var_remaining_size;
> +u64 efi_var_max_var_size;
[...]
> --- a/drivers/firmware/efivars.c
> +++ b/drivers/firmware/efivars.c
[...]
> @@ -2133,6 +2158,10 @@ efivars_init(void)
> ops.get_next_variable = efi.get_next_variable;
> ops.query_variable_info = efi.query_variable_info;
>
> +#ifdef CONFIG_X86
> + boot_used_size = efi_var_store_size - efi_var_remaining_size;
> +#endif

efivars can be built as a module, but these aren't exported.

Ben.

> error = register_efivars(&__efivars, &ops, efi_kobj);
> if (error)
> goto err_put;

--
Ben Hutchings
DNRC Motto: I can please only one person per day.
Today is not your day. Tomorrow isn't looking good either.

Attachment: signature.asc
Description: This is a digitally signed message part