[SRU,B/D/E/F,V2,1/1] efi: efi_get_memory_map -- increase map headroom
diff mbox series

Message ID 20191108102546.233856-1-apw@canonical.com
State New
Headers show
Series
  • [SRU,B/D/E/F,V2,1/1] efi: efi_get_memory_map -- increase map headroom
Related show

Commit Message

Andy Whitcroft Nov. 8, 2019, 10:25 a.m. UTC
We are seeing some EFI based machines failing to boot hard in the EFI
stub:

    exit_boot() failed!
    efi_main() failed!

This seems to occur when the bootloader (grub2 in this case) has had
to manipulate some additional files due to a change in the way MAAS
boots the machines.  We tracked this down to the memory map dance
efi_get_memory_map().  Basically we attempt to close boot services and
it informs us it cannot do so because it failed to record the updated
memory map.  This occurs when there is insufficient space in the passed
memory map buffer to record changes during the operation.  At the point
when this occurs we are unable to call the allocation functions to
reallocate the buffer so we panic.

To avoid this we allocate some additional entries in the buffer to cover
any additional entries.  This headroom is currently insufficient for
these machines under this use case.  Increase EFI_MMAP_NR_SLACK_SLOTS to
provide space for more memory map modifications.

BugLink: https://bugs.launchpad.net/bugs/1851810
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 drivers/firmware/efi/libstub/efi-stub-helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Seth Forshee Nov. 12, 2019, 12:07 a.m. UTC | #1
On Fri, Nov 08, 2019 at 10:25:46AM +0000, Andy Whitcroft wrote:
> We are seeing some EFI based machines failing to boot hard in the EFI
> stub:
> 
>     exit_boot() failed!
>     efi_main() failed!
> 
> This seems to occur when the bootloader (grub2 in this case) has had
> to manipulate some additional files due to a change in the way MAAS
> boots the machines.  We tracked this down to the memory map dance
> efi_get_memory_map().  Basically we attempt to close boot services and
> it informs us it cannot do so because it failed to record the updated
> memory map.  This occurs when there is insufficient space in the passed
> memory map buffer to record changes during the operation.  At the point
> when this occurs we are unable to call the allocation functions to
> reallocate the buffer so we panic.
> 
> To avoid this we allocate some additional entries in the buffer to cover
> any additional entries.  This headroom is currently insufficient for
> these machines under this use case.  Increase EFI_MMAP_NR_SLACK_SLOTS to
> provide space for more memory map modifications.
> 
> BugLink: https://bugs.launchpad.net/bugs/1851810
> Signed-off-by: Andy Whitcroft <apw@canonical.com>

Should be marked as a sauce patch. With that changed:

Acked-by: Seth Forshee <seth.forshee@canonical.com>

Applied to unstable/master, thanks!
Stefan Bader Nov. 12, 2019, 2:36 p.m. UTC | #2
On 08.11.19 11:25, Andy Whitcroft wrote:
> We are seeing some EFI based machines failing to boot hard in the EFI
> stub:
> 
>     exit_boot() failed!
>     efi_main() failed!
> 
> This seems to occur when the bootloader (grub2 in this case) has had
> to manipulate some additional files due to a change in the way MAAS
> boots the machines.  We tracked this down to the memory map dance
> efi_get_memory_map().  Basically we attempt to close boot services and
> it informs us it cannot do so because it failed to record the updated
> memory map.  This occurs when there is insufficient space in the passed
> memory map buffer to record changes during the operation.  At the point
> when this occurs we are unable to call the allocation functions to
> reallocate the buffer so we panic.
> 
> To avoid this we allocate some additional entries in the buffer to cover
> any additional entries.  This headroom is currently insufficient for
> these machines under this use case.  Increase EFI_MMAP_NR_SLACK_SLOTS to
> provide space for more memory map modifications.
> 
> BugLink: https://bugs.launchpad.net/bugs/1851810
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---

with added "UBUNTU: SAUCE ..." prefix as Seth pointed out.

>  drivers/firmware/efi/libstub/efi-stub-helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
> index 39f87e6dac5c..957dff5a26a2 100644
> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
> @@ -49,7 +49,7 @@ int __pure novamap(void)
>  	return __novamap;
>  }
>  
> -#define EFI_MMAP_NR_SLACK_SLOTS	8
> +#define EFI_MMAP_NR_SLACK_SLOTS	16
>  
>  struct file_info {
>  	efi_file_handle_t *handle;
>
Stefan Bader Nov. 13, 2019, 6:14 p.m. UTC | #3
On 08.11.19 11:25, Andy Whitcroft wrote:
> We are seeing some EFI based machines failing to boot hard in the EFI
> stub:
> 
>     exit_boot() failed!
>     efi_main() failed!
> 
> This seems to occur when the bootloader (grub2 in this case) has had
> to manipulate some additional files due to a change in the way MAAS
> boots the machines.  We tracked this down to the memory map dance
> efi_get_memory_map().  Basically we attempt to close boot services and
> it informs us it cannot do so because it failed to record the updated
> memory map.  This occurs when there is insufficient space in the passed
> memory map buffer to record changes during the operation.  At the point
> when this occurs we are unable to call the allocation functions to
> reallocate the buffer so we panic.
> 
> To avoid this we allocate some additional entries in the buffer to cover
> any additional entries.  This headroom is currently insufficient for
> these machines under this use case.  Increase EFI_MMAP_NR_SLACK_SLOTS to
> provide space for more memory map modifications.
> 
> BugLink: https://bugs.launchpad.net/bugs/1851810
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
> ---

Applied to E+D+B/master-next. Thanks.

-Stefan

>  drivers/firmware/efi/libstub/efi-stub-helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
> index 39f87e6dac5c..957dff5a26a2 100644
> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
> @@ -49,7 +49,7 @@ int __pure novamap(void)
>  	return __novamap;
>  }
>  
> -#define EFI_MMAP_NR_SLACK_SLOTS	8
> +#define EFI_MMAP_NR_SLACK_SLOTS	16
>  
>  struct file_info {
>  	efi_file_handle_t *handle;
>

Patch
diff mbox series

diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 39f87e6dac5c..957dff5a26a2 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -49,7 +49,7 @@  int __pure novamap(void)
 	return __novamap;
 }
 
-#define EFI_MMAP_NR_SLACK_SLOTS	8
+#define EFI_MMAP_NR_SLACK_SLOTS	16
 
 struct file_info {
 	efi_file_handle_t *handle;