Attention is currently required from: Jakub Czapiga, Jérémy Compostella, Werner Zeh.

Werner Zeh uploaded patch set #2 to this change.

View Change

The following approvals got outdated and were removed: Verified-1 by build bot (Jenkins)

tree: Refactor region_end() to return last used address of a region

Currently, function region_end() does return the next address after the
end of a given region. This is not only confusing (as the next address
after a region is not part of this region anymore) but can lead to
integer overflow if the region's end reaches SIZE_MAX. This possible
overflow can then lead to not catching a region overlap as reported in a
bug in [1].

This patch changes now the behavior of region_end() and makes it return
the last valid address of a region. In addition, the integer overflow is
checked and if it would happen, SIZE_MAX is returned (which truncates
the region's end to SIZE_MAX for this corner case).

And since region_end() now returns a different address, some unit-tests
need adjustments.

[1]: https://ticket.coreboot.org/issues/522

Change-Id: Ide7a39af1609fed63d08832a6dcc4679a85c5027
Signed-off-by: Werner Zeh <werner.zeh@siemens.com>
---
M src/commonlib/include/commonlib/region.h
M src/commonlib/region.c
M src/cpu/x86/smm/smm_module_loader.c
M src/drivers/spi/winbond.c
M src/include/cpu/x86/smm.h
M tests/commonlib/region-test.c
M util/cbfstool/cse_serger.c
7 files changed, 33 insertions(+), 13 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/79977/2

To view, visit change 79977. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Ide7a39af1609fed63d08832a6dcc4679a85c5027
Gerrit-Change-Number: 79977
Gerrit-PatchSet: 2
Gerrit-Owner: Werner Zeh <werner.zeh@siemens.com>
Gerrit-Reviewer: Jakub Czapiga <czapiga@google.com>
Gerrit-Reviewer: Jérémy Compostella <jeremy.compostella@intel.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-Attention: Jakub Czapiga <czapiga@google.com>
Gerrit-Attention: Jérémy Compostella <jeremy.compostella@intel.com>
Gerrit-Attention: Werner Zeh <werner.zeh@siemens.com>
Gerrit-MessageType: newpatchset