
In efi_add_known_memory the start address is correctly rounded up to a mulitple of EFI_PAGE_SIZE. By this rounding we may loose up to EFI_PAGE_MASK bytes. The current code does not take this loss of available memory into account when calculating the number of pages.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- lib/efi_loader/efi_memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index c1a080e2e9..38b0e1d808 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -444,8 +444,14 @@ __weak void efi_add_known_memory(void) u64 ram_start = gd->bd->bi_dram[i].start; u64 ram_size = gd->bd->bi_dram[i].size; u64 start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; - u64 pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; + u64 pages;
+ if (ram_size <= EFI_PAGE_MASK) + continue; + pages = (ram_start + ram_size - start + EFI_PAGE_MASK) >> + EFI_PAGE_SHIFT; + if (pages == 0) + continue; efi_add_memory_map(start, pages, EFI_CONVENTIONAL_MEMORY, false); }