From: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: Ard Biesheuvel
<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
<matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org"
<bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>,
"roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] efi: stub: call get_memory_map() to obtain map and desc sizes
Date: Fri, 9 Jan 2015 10:55:29 +0000 [thread overview]
Message-ID: <20150109105529.GP3827@bivouac.eciton.net> (raw)
In-Reply-To: <20150109101950.GA27421@leverpostej>
On Fri, Jan 09, 2015 at 10:19:50AM +0000, Mark Rutland wrote:
> On Thu, Jan 08, 2015 at 07:09:22PM +0000, Ard Biesheuvel wrote:
> > On 8 January 2015 at 19:04, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> wrote:
> > > Hi Ard,
> > >
> > > On Thu, Jan 08, 2015 at 05:51:47PM +0000, Ard Biesheuvel wrote:
> > >> This fixes two minor issues in the implementation of get_memory_map():
> > >> - Currently, it assumes that sizeof(efi_memory_desc_t) == desc_size,
> > >> which is usually true, but not mandated by the spec. (This was added
> > >> intentionally to allow future additions to the definition of
> > >> efi_memory_desc_t). The way the loop is implemented currently, the
> > >> added slack space may be insufficient if desc_size is larger, which in
> > >> some corner cases could result in the loop never terminating.
> > >> - It allocates 32 efi_memory_desc_t entries first (again, using the size
> > >> of the struct instead of desc_size), and frees and reallocates if it
> > >> turns out to be insufficient. Few implementations of UEFI have such small
> > >> memory maps, which results in a unnecessary allocate/free pair on each
> > >> invocation.
> > >>
> > >> Fix this by calling the get_memory_map() boot service first with a '0'
> > >> input value for map size to retrieve the map size and desc size from the
> > >> firmware and only then perform the allocation, using desc_size rather
> > >> than sizeof(efi_memory_desc_t).
> > >
> > > Is the desc_size guaranteed to be set up correctly if the size is too
> > > small?
> > >
> > > As far as I can see, for that case the spec only mandates that
> > > MemoryMapSize is updated nd EFI_BUFFER_TOO_SMALL is returned.
> > >
> > > It's not clear to me whether DescriptorSize or DescriptorVersion are
> > > initialised in cases other than success.
> > >
> >
> > The way I read it, descriptor size and descriptor version are always
> > returned, e.g., as opposed to MapKey, which is only returned on
> > success, and the spec mentions that specifically.
>
> I agree that that would be the sensible reading of the spec. I just fear
> that there's room for an implementor to read it slightly differently,
> and cause pain for us.
I disagree.
The intent is clear, and you can not follow the current text and
provide a version that does not do the right thing. Only the MapKey
return is conditional on success.
> > We could ask for clarification just to be sure.
>
> I think we should.
>
> Given it could take a while for any conclusion to be reached and
> published, I'm happy to go with the patch below in the meantime, so long
> as the issue gets raised.
We could ask for clarification of the spec, but I see no need to ask
for guidance on the current text.
/
Leif
next prev parent reply other threads:[~2015-01-09 10:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-08 17:51 [PATCH] efi: stub: call get_memory_map() to obtain map and desc sizes Ard Biesheuvel
[not found] ` <1420739507-1708-1-git-send-email-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-08 19:04 ` Mark Rutland
2015-01-08 19:09 ` Ard Biesheuvel
[not found] ` <CAKv+Gu9tVjfU5S=3oLTznUFnv0WAbGcKueNjKtDtYqGQ+cxtxw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-09 10:19 ` Mark Rutland
2015-01-09 10:55 ` Leif Lindholm [this message]
[not found] ` <20150109105529.GP3827-t77nlHhSwNqAroYi2ySoxKxOck334EZe@public.gmane.org>
2015-01-09 11:16 ` Mark Rutland
2015-01-12 11:09 ` 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=20150109105529.GP3827@bivouac.eciton.net \
--to=leif.lindholm-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=roy.franz-QSEj5FYQhm4dnm+yROfE0A@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