[U-Boot] [PATCH v2 2/9] efi_loader: fix efi_find_free_memory()

Alexander Graf agraf at suse.de
Tue Nov 13 20:56:51 UTC 2018



On 12.11.18 18:55, Heinrich Schuchardt wrote:
> In efi_find_free_memory() the sandbox uses its virtual address space.
> Add the missing mapping.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>

The real bug here is much worse. According to 2.3.4 "x64 Platforms" of
the UEFI spec:

===
Paging mode is enabled and any memory space defined by the UEFI memory
map is identity mapped (virtual address equals physical address),
although the attributes of certain regions may not have all read, write,
and execute attributes or be unmarked for purposes of platform
protection. The mappings to other regions are undefined and may vary
from implementation to implementation.
===

This means we can't have virtual != physical. We need to go with all
physical (pointers) instead. Anything else violates the spec.


Alex

> ---
> v2:
> 	no change
> ---
>  lib/efi_loader/efi_memory.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index dc282fe249f..c0277355056 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -294,6 +294,9 @@ static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr)
>  {
>  	struct list_head *lhandle;
>  
> +	/* Map to virtual address on sandbox */
> +	max_addr = map_to_sysmem((void *)(uintptr_t)max_addr);
> +
>  	/*
>  	 * Prealign input max address, so we simplify our matching
>  	 * logic below and can just reuse it as return pointer.
> 


More information about the U-Boot mailing list