diff mbox series

[RFC,1/2] efi: arm: do not overlap non ram memory on efi allocation

Message ID 20200828194741.7497-1-maxim.uvarov@linaro.org
State New
Headers show
Series [RFC,1/2] efi: arm: do not overlap non ram memory on efi allocation | expand

Commit Message

Maxim Uvarov Aug. 28, 2020, 7:47 p.m. UTC
This commit fixes qemu boot of armv7 where reserving memory
for fdt is failed due to reserving region outside of the
system RAM.

=> bdinfo
boot_params = 0x00000000
DRAM bank   = 0x00000000
-> start    = 0x40000000
-> size     = 0x40000000
memstart    = 0x40000000
memsize     = 0x40000000
flashstart  = 0x04000000
flashsize   = 0x04000000
flashoffset = 0x00000000
baudrate    = 115200 bps
relocaddr   = 0x7ff57000
reloc off   = 0x1ff57000
Build       = 32-bit
current eth = virtio-net#32
ethaddr     = 52:52:52:52:52:52
IP addr     = <NULL>
fdt_blob    = 0x7ef35f20
new_fdt     = 0x7ef35f20
fdt_size    = 0x00001fa0
ERROR: reserving fdt memory region failed (addr=7fe00000 size=200000)
lmb_dump_all:
    memory.cnt    = 0x1
    memory.size    = 0x0
    memory.reg[0x0].base   = 0x40000000
   .size   = 0x40000000

    reserved.cnt    = 0x2
    reserved.size    = 0x0
    reserved.reg[0x0].base = 0xe100000
     .size = 0xf00000
    reserved.reg[0x1].base = 0x7ef34d04
     .size = 0x10cb2fc
arch_number = 0x00000000
TLB addr    = 0x7fff0000
irq_sp      = 0x7ef35f10
sp start    = 0x7ef35f00
Early malloc usage: 1fc / 400

=> efidebug memmap
Type             Start            End              Attributes
-- 
2.17.1

Comments

Heinrich Schuchardt Sept. 15, 2020, 12:46 p.m. UTC | #1
On 28.08.20 21:47, Maxim Uvarov wrote:
> This commit fixes qemu boot of armv7 where reserving memory

> for fdt is failed due to reserving region outside of the

> system RAM.


From our prior communication I took this refers to incorrect allocation
in Linux.

Ard Biesheuvel is addressing this in a Linux kernel patch series:

[PATCH RFC/RFT 0/3] efi/libstub: arm32: Remove dependency on dram_base
https://lore.kernel.org/linux-efi/CAMj1kXECRr+E4=r+7fuaRAXQUyLi5Z1_HgNWgLGZVHdPSABE0A@mail.gmail.com/T/#ma22ac77a05fc89ea20ad4ab373d3997e13b683b0

Best regards

Heinrich
diff mbox series

Patch

================ ================ ================ ==========
RESERVED         000000000e100000-000000000f000000 WB <---- outside of RAM
CONVENTIONAL     0000000040000000-0000000047f00000 WB
ACPI RECLAIM MEM 0000000047f00000-0000000047f05000 WB
CONVENTIONAL     0000000047f05000-000000007d475000 WB
RESERVED         000000007d475000-000000007d477000 WB
CONVENTIONAL     000000007d477000-000000007df17000 WB
LOADER DATA      000000007df17000-000000007df18000 WB

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---

 I'm really not sure that this is correct way to fix. Current code state is that
 uboot fails to boot kernel on armv7 if memory was reserved at 0xe100000. I.e. in
 current code it does not work. Qemu target has memory started at 0x40000000 and
 this chunk is outside that memory. Flag overlap_only_ram had very confusing naming,
 I corrected it in separate path. This patch fixes booting with removing region
 from efi memmap. I send this as RFC for now.

BR,
Maxim. 


 lib/efi_loader/efi_memory.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 7be756e370..637c6c67ed 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -360,11 +360,15 @@  static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
 efi_status_t efi_add_memory_map(u64 start, u64 size, int memory_type)
 {
 	u64 pages;
+	bool overlap_only_ram = false;
 
 	pages = efi_size_in_pages(size + (start & EFI_PAGE_MASK));
 	start &= ~EFI_PAGE_MASK;
-
-	return efi_add_memory_map_pg(start, pages, memory_type, false);
+#if defined(CONFIG_ARM)
+	overlap_only_ram = true;
+#endif
+	return efi_add_memory_map_pg(start, pages, memory_type,
+				     overlap_only_ram);
 }
 
 /**