Commit 25d95e40 authored by Leif Lindholm's avatar Leif Lindholm Committed by Colin Watson

efi: Add grub_efi_get_ram_base() function for arm64

Since ARM platforms do not have a common memory map, add a helper
function that finds the lowest address region with the EFI_MEMORY_WB
attribute set in the UEFI memory map.

Required for the arm64 efi linux loader to restrict the initrd
location to where it will be accessible by the kernel at runtime.
Signed-off-by: default avatarLeif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>

Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=bad144c60f664a83f5a7d3a014927bffaa2abbf1
Bug-Debian: https://bugs.debian.org/907596
Bug-Debian: https://bugs.debian.org/909420
Last-Update: 2018-12-06

Patch-Name: efi-add-grub_efi_get_ram_base-for-arm64.patch
parent 07a1b97d
......@@ -583,3 +583,34 @@ grub_efi_mm_init (void)
grub_efi_free_pages ((grub_addr_t) memory_map,
2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
}
#if defined (__aarch64__)
grub_err_t
grub_efi_get_ram_base(grub_addr_t *base_addr)
{
grub_efi_memory_descriptor_t *memory_map, *desc;
grub_efi_uintn_t memory_map_size, desc_size;
int ret;
memory_map_size = grub_efi_find_mmap_size();
memory_map = grub_malloc (memory_map_size);
if (! memory_map)
return GRUB_ERR_OUT_OF_MEMORY;
ret = grub_efi_get_memory_map (&memory_map_size, memory_map, NULL,
&desc_size, NULL);
if (ret < 1)
return GRUB_ERR_BUG;
for (desc = memory_map, *base_addr = GRUB_UINT_MAX;
(grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size);
desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
if (desc->attribute & GRUB_EFI_MEMORY_WB)
*base_addr = grub_min (*base_addr, desc->physical_start);
grub_free(memory_map);
return GRUB_ERR_NONE;
}
#endif
......@@ -96,6 +96,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
#if defined(__arm__) || defined(__aarch64__)
void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
#endif
#if defined(__aarch64__)
grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
#endif
grub_addr_t grub_efi_modules_addr (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment