util/cbfstool: Fix build in 32-bit userspace

Fix regression from commit 0dcc0662f3 util/cbfstool: Introduce
concept of mmap_window.

Use of region_end() wraps around at 4 GiB, if utility is run in
32bit userspace. The build completes with an invalid coreboot.rom,
while one can find error message in stdout or make.log:

E: Host address(ffc002e4) not in any mmap window!

Change-Id: Ib9b6b60c7b5031122901aabad7b3aa8d59f1bc68
Signed-off-by: Furquan Shaikh <furquan@google.com>
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50618
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Kyösti Mälkki 2021-02-13 01:57:14 +02:00 committed by Angel Pons
parent 985f3e05e3
commit b57373b058
1 changed files with 2 additions and 1 deletions

View File

@ -255,7 +255,8 @@ static int find_mmap_window(enum mmap_addr_type addr_type, unsigned int addr)
else
reg = &mmap_window_table[i].flash_space;
if (region_offset(reg) <= addr && region_end(reg) >= addr)
if (region_offset(reg) <= addr &&
((uint64_t)region_offset(reg) + (uint64_t)region_sz(reg) - 1) >= addr)
return i;
}