public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matt Fleming <matt@console-pimps.org>
To: Matthew Garrett <matthew.garrett@nebula.com>
Cc: matt.fleming@intel.com, ben@decadent.org.uk, jwboyer@redhat.com,
	linux-efi@vger.kernel.org, seth.forshee@canonical.com,
	linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH 2/2] efi: Distinguish between "remaining space" and actually used space
Date: Wed, 03 Apr 2013 14:11:34 +0100	[thread overview]
Message-ID: <515C2A86.6070606@console-pimps.org> (raw)
In-Reply-To: <1364829240-26475-2-git-send-email-matthew.garrett@nebula.com>

On 01/04/13 16:14, Matthew Garrett wrote:
> @@ -452,8 +462,33 @@ check_var_size_locked(struct efivars *efivars, u32 attributes,
>  	if (status != EFI_SUCCESS)
>  		return status;
>  
> -	if (!storage_size || size > remaining_size || size > max_size ||
> -	    (remaining_size - size) < (storage_size / 2))
> +	list_for_each_entry(entry, &efivars->list, list) {
> +		var = &entry->var;
> +		status = get_var_data_locked(efivars, var);
> +
> +		if (status || !(var->Attributes & EFI_VARIABLE_NON_VOLATILE))
> +			continue;
> +
> +		active_size += var->DataSize;
> +		active_size += utf16_strsize(var->VariableName, 1024);
> +		/*
> +		 * There's some additional metadata associated with each
> +		 * variable. Intel's reference implementation is 60 bytes -
> +		 * bump that to 128 to account for vendor additions and
> +		 * potential alignment constraints
> +		 */
> +		active_size += 128;
> +	}

This is the kind of thing I was referring to when I said, 

  Hmm... I'm not convinced this will provide a long-term solution. Is there
  anything that mandates that the size of all variables has to correlate
  sensibly with the results from QueryVariableInfo()? Even if there is in
  theory, I doubt it'll be true everywhere in practice, and trying to
  workaround implementation bugs in our workarounds for other bugs is the
  path to madness.

  We can't continue this approach where we attempt to guess how the firmware
  implements variable storage, because as we've seen, there are various
  schemes out there. 

This looks like something that will differ between implementations, and the
fact that it's appearing in our code is a sure sign that this isn't the way to
go.

-- 
Matt Fleming, Intel Open Source Technology Center

  parent reply	other threads:[~2013-04-03 13:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <515150EC.7040203@redhat.com>
2013-04-01 15:13 ` [PATCH 1/2] efi: Determine how much space is used by boot services-only variables Matthew Garrett
2013-04-01 15:14   ` [PATCH 2/2] efi: Distinguish between "remaining space" and actually used space Matthew Garrett
2013-04-01 15:50     ` Ben Hutchings
2013-04-03 13:11     ` Matt Fleming [this message]
2013-04-03 13:48       ` Matthew Garrett
2013-04-03 17:12         ` Matt Fleming
2013-04-03 17:20           ` Matthew Garrett
2013-04-01 15:42   ` [PATCH 1/2] efi: Determine how much space is used by boot services-only variables Ben Hutchings
2013-04-03 13:09   ` Matt Fleming
2013-04-03 13:42     ` Matthew Garrett

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=515C2A86.6070606@console-pimps.org \
    --to=matt@console-pimps.org \
    --cc=ben@decadent.org.uk \
    --cc=jwboyer@redhat.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=matthew.garrett@nebula.com \
    --cc=seth.forshee@canonical.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