linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeffrey Hugo <jhugo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: Ard Biesheuvel
	<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: Matt Fleming
	<matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>,
	"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Timur Tabi <timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Leif Lindholm
	<leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH 1/4] efi/libstub: Allocate headspace in efi_get_memory_map()
Date: Mon, 18 Jul 2016 11:53:57 -0600	[thread overview]
Message-ID: <53b43dc6-929e-68cd-b308-a28f94563754@codeaurora.org> (raw)
In-Reply-To: <CAKv+Gu9fy0KRr9u3Euva8Jc1U-uGhCuSB5Fyt6C-o-7tD0+Phw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 7/18/2016 9:14 AM, Ard Biesheuvel wrote:
> On 18 July 2016 at 17:11, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> wrote:
>> On Mon, Jul 18, 2016 at 09:03:31AM -0600, Jeffrey Hugo wrote:
>>> On 7/18/2016 5:00 AM, Mark Rutland wrote:
>>>> Hi,
>>>>
>>>> On Sun, Jul 17, 2016 at 02:45:59PM -0600, Jeffrey Hugo wrote:
>>>>> +   if (status == EFI_BUFFER_TOO_SMALL ||
>>>>> +                           (*buff_size - *map_size) / sizeof(*m) < 8) {
>>>>>            efi_call_early(free_pool, m);
>>>>> +           /*
>>>>> +            * Make sure there is 8 entries worth of headroom so that the
>>>>> +            * buffer can be reused for a new map after allocations are
>>>>> +            * no longer permitted.  Its unlikely that the map will grow to
>>>>> +            * exceed this headroom once we are ready to trigger
>>>>> +            * ExitBootServices()
>>>>> +            */
>>>>> +           *map_size += sizeof(*m) * 8;
>>
>>>> As a general note, it's a shame that we don't know desc_size first time
>>>> through. If descs grow, 8 * sizeof(*m) might be too small. That's an
>>>> existing problem though, so I guess it makes sense to be consistent and
>>>> use sizeof(*m) here.
>>>
>>> Yep.  Unless I've missed something, it seems like the two options
>>> are either make a decent attempt to guess at desc_size the first
>>> time (current approach), or intentionally fail the first time just
>>> to get the size.  The current approach doesn't seem perfect, but it
>>> does have a chance at passing with just one attempt.  I couldn't see
>>> a better solution, but if someone else has an idea, I'd like to hear
>>> it.
>>
>> Sure, that was more of an observation than a critique. In the absence of
>> any suggestions better, sticking with sizeof(*m) makes sense.
>>
>> If it does become a problem, we're likely to have to fix up other sites
>> regardless.
>>
>
> It is worth noting that the EDK2 implementation deliberately uses a
> desc_size that exceeds the size of the type. So '8 * sizeof(*m)' is
> almost never going to be 8 slots' worth of headroom.
>

Good point, desc_size does exceed sizeof(*m) when I test an EDK2 
implementation.  I think I can rework things to use desc_size instead, 
so that we do get the expected 8 slots of headroom.  I'll incorporate 
that in V2.

-- 
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

  parent reply	other threads:[~2016-07-18 17:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-17 20:45 [PATCH 0/4] Handle EFI_INVALID_PARAMETER from ExitBootServices Jeffrey Hugo
     [not found] ` <1468788362-3962-1-git-send-email-jhugo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-07-17 20:45   ` [PATCH 1/4] efi/libstub: Allocate headspace in efi_get_memory_map() Jeffrey Hugo
     [not found]     ` <1468788362-3962-2-git-send-email-jhugo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-07-18 11:00       ` Mark Rutland
2016-07-18 15:03         ` Jeffrey Hugo
     [not found]           ` <8d1fd10a-97d0-df6e-0d52-dcc29671521d-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-07-18 15:11             ` Mark Rutland
2016-07-18 15:14               ` Ard Biesheuvel
     [not found]                 ` <CAKv+Gu9fy0KRr9u3Euva8Jc1U-uGhCuSB5Fyt6C-o-7tD0+Phw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-18 17:53                   ` Jeffrey Hugo [this message]
2016-07-17 20:46   ` [PATCH 2/4] efi/libstub: Introduce ExitBootServices helper Jeffrey Hugo
2016-07-17 20:46   ` [PATCH 3/4] efi/libstub: Use efi_exit_boot_services() in FDT Jeffrey Hugo
2016-07-17 20:46   ` [PATCH 4/4] x86/efi: Use efi_exit_boot_services() Jeffrey Hugo

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=53b43dc6-929e-68cd-b308-a28f94563754@codeaurora.org \
    --to=jhugo-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
    --cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org \
    --cc=timur-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.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;
as well as URLs for NNTP newsgroup(s).