From b57373b058046815ee987d35eaa1c1729d9fd26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Sat, 13 Feb 2021 01:57:14 +0200 Subject: [PATCH] util/cbfstool: Fix build in 32-bit userspace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/50618 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Angel Pons --- util/cbfstool/cbfstool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 57c9e5117f..2f920e0988 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -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; }