
On 11/29/18 6:11 PM, Alexander Graf wrote:
On some systems, not all RAM may be usable within U-Boot. Maybe the memory maps are incomplete, maybe it's used as workaround for broken DMA. But whatever the reason may be, a platform can say that it does not wish to have its RAM accessed above a certain address by defining board_get_usable_ram_top().
In the efi_loader world, we ignored that hint, mostly because very few boards actually have real restrictions around this.
So let's honor the board's wish to not access high addresses during boot time. The best way to do so is by indicating the respective pages as "allocated by firmware". That way, Operating Systems will still use the pages after boot, but before boot no allocation will use them.
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
__weak void efi_add_known_memory(void) {
u64 ram_top = board_get_usable_ram_top(0) & ~EFI_PAGE_MASK; int i;
/* Fix for 32bit targets with ram_top at 4G */
if (!ram_top)
ram_top = U32_MAX;
Don't you need to &= ~EFI_PAGE_MASK after the U32_MAX assignment too? Perhaps just do that once:
u64 ram_top = board_get_usable_ram_top(0); /* Fix for 32bit targets with ram_top at 4G */ if (!ram_top) ram_top = U32_MAX; ram_top &= & ~EFI_PAGE_MASK;
Otherwise, Reviewed-by: Stephen Warren swarren@nvidia.com