[U-Boot] [PATCH 1/1] efi_loader: memory reservations according to e820 table

Heinrich Schuchardt xypron.glpk at gmx.de
Sun Jan 14 15:59:59 UTC 2018


On 01/14/2018 04:27 AM, Heinrich Schuchardt wrote:
> On the x86 architecture the e820 BIOS table defines reserved memory.
> Mark it as EFI reserved memory.
> 

Hello Simon, hello Bin,

is there a place in the x86 start up code where we could put the new 
e820_memory_reservation() function?

Putting this into the EFI mainline code is a bit awkward.

Best regards

Heinrich

> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>   lib/efi_loader/efi_memory.c | 28 ++++++++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
> 
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index aaf64421a3..bee0a0c97d 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -10,6 +10,9 @@
>   #include <efi_loader.h>
>   #include <malloc.h>
>   #include <asm/global_data.h>
> +#ifdef CONFIG_X86
> +#include <asm/e820.h>
> +#endif
>   #include <libfdt_env.h>
>   #include <linux/list_sort.h>
>   #include <inttypes.h>
> @@ -493,6 +496,30 @@ __weak void efi_add_known_memory(void)
>   	}
>   }
>   
> +/*
> + * Create reservations according to the BIOS e820 table.
> + */
> +static void e820_memory_reservation(void)
> +{
> +#ifdef CONFIG_X86
> +	struct e820entry e820[32];
> +	unsigned int i, num;
> +	unsigned long start, pages;
> +
> +	num = install_e820_map(ARRAY_SIZE(e820), e820);
> +
> +	for (i = 0; i < num; ++i) {
> +		if (e820[i].type == E820_RESERVED) {
> +			start = e820[i].addr;
> +			pages = ALIGN(e820[i].size, EFI_PAGE_SIZE) >>
> +				EFI_PAGE_SHIFT;
> +			efi_add_memory_map(start, pages,
> +					   EFI_RESERVED_MEMORY_TYPE, false);
> +		}
> +	}
> +#endif
> +}
> +
>   int efi_memory_init(void)
>   {
>   	unsigned long runtime_start, runtime_end, runtime_pages;
> @@ -525,6 +552,7 @@ int efi_memory_init(void)
>   
>   	efi_bounce_buffer = (void*)(uintptr_t)efi_bounce_buffer_addr;
>   #endif
> +	e820_memory_reservation();
>   
>   	return 0;
>   }
> 


More information about the U-Boot mailing list