From: Ross Lagerwall <ross.lagerwall@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH] efi: Reallocate memory map if ExitBootServices() fails
Date: Fri, 29 May 2015 10:57:25 +0100 [thread overview]
Message-ID: <55683805.1000205@citrix.com> (raw)
In-Reply-To: <55685164020000780007EE84@mail.emea.novell.com>
On 05/29/2015 10:45 AM, Jan Beulich wrote:
>>>> On 29.05.15 at 09:48, <ross.lagerwall@citrix.com> wrote:
>> --- a/xen/common/efi/boot.c
>> +++ b/xen/common/efi/boot.c
>> @@ -1053,14 +1053,14 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>> efi_arch_video_init(gop, info_size, mode_info);
>> }
>>
>> - efi_bs->GetMemoryMap(&efi_memmap_size, NULL, &map_key,
>> - &efi_mdesc_size, &mdesc_ver);
>> - efi_memmap = efi_arch_allocate_mmap_buffer(&efi_memmap_size);
>> - if ( !efi_memmap )
>> - blexit(L"Unable to allocate memory for EFI memory map");
>> -
>> for ( retry = 0; ; retry = 1 )
>> {
>> + efi_bs->GetMemoryMap(&efi_memmap_size, NULL, &map_key,
>> + &efi_mdesc_size, &mdesc_ver);
>> + efi_memmap = efi_arch_allocate_mmap_buffer(&efi_memmap_size);
>> + if ( !efi_memmap )
>> + blexit(L"Unable to allocate memory for EFI memory map");
>
> You can't blexit() anymore after having called ExitBootServices() once.
> Admittedly even the PrintErrMesg() used for "error handling" a few
> lines down is on the edge of being invalid (but this is a best effort
> thing anyway).
OK, I'll convert it into a PrintErrMesg.
>
> Further you should do a second allocation only if you positively
> identified that the new size is larger than what the existing buffer
> can hold. It may be worth allocating a couple of extra entries the
> first time through anyway; perhaps that would even avoid th need
> for this workaround.
OK.
>
> Since, finally, this is only a workaround, as the spec clearly says:
> "After an Operating System calls ExitBootServices(), firmware boot
> services are no longer available and it is illegal to call any boot
> service." Even our re-invocation of GetMemoryMap() is bending
> that (and I only hesitantly agreed for it to be added).
>
The spec kinda disagrees with that:
"It is suggested that GetMemoryMap()be called immediately before calling
ExitBootServices(). If MapKey value is incorrect, ExitBootServices()
returns EFI_INVALID_PARAMETER and GetMemoryMap() with ExitBootServices()
must be called again. Firmware implementation may choose to do a partial
shutdown of the boot services during the first call to
ExitBootServices(). EFI OS loader should not make calls to any boot
service function other then GetMemoryMap() after the first call to
ExitBootServices()."
I think the patch does the right thing in the regard.
--
Ross Lagerwall
next prev parent reply other threads:[~2015-05-29 9:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 7:48 [PATCH] efi: Reallocate memory map if ExitBootServices() fails Ross Lagerwall
2015-05-29 9:10 ` Andrew Cooper
2015-05-29 9:45 ` Jan Beulich
2015-05-29 9:57 ` Ross Lagerwall [this message]
2015-05-29 10:55 ` Jan Beulich
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=55683805.1000205@citrix.com \
--to=ross.lagerwall@citrix.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.