_lmb_alloc_addr() returns -EINVAL when a reservation overlaps an available memory bank but does not fully fit inside it, and -EFAULT when it does not overlap any bank at all.
So for the partial-overlap case, it returns -EINVAL and boot_fdt_handle_region() in boot/image-fdt.c prints "ERROR: reserving fdt memory region failed" during boot which makes it sound like a serious error. So to avoid this, return -EFAULT for the partial-overlap case also, so boot_fdt_handle_region() suppresses it. Updated the -EINVAL assertions in test/lib/lmb.c's test_alloc_addr() that cover this boundary case to expect -EFAULT. Signed-off-by: Balaji Selvanathan <[email protected]> --- lib/lmb.c | 2 -- test/lib/lmb.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index ca00047f624..745410a8895 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -752,8 +752,6 @@ static int _lmb_alloc_addr(phys_addr_t base, phys_size_t size, u32 flags) base + size - 1, 1)) /* ok, reserve the memory */ return lmb_reserve(base, size, flags); - - return -EINVAL; } return -EFAULT; diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 168c66ae649..e6c05a492df 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -781,9 +781,9 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) ret = lmb_alloc_addr(ram_end, 1, LMB_NONE); ut_asserteq(ret, -EFAULT); ret = lmb_alloc_addr(ram_end - 1, 2, LMB_NOMAP); - ut_asserteq(ret, -EINVAL); + ut_asserteq(ret, -EFAULT); ret = lmb_alloc_addr(ram_end - 1, 2, LMB_NOOVERWRITE); - ut_asserteq(ret, -EINVAL); + ut_asserteq(ret, -EFAULT); } if (ram != 0) { ret = lmb_alloc_addr(ram - 1, 1, LMB_NONE); --- base-commit: 509312dc5386ff4c5adabf53a573abca0aac4ce5 change-id: 20260907-lmb-alloc-addr-efault-a29212da721d Best regards, -- Balaji Selvanathan <[email protected]>
