Attention is currently required from: Jérémy Compostella.

Nico Huber has uploaded this change for review.

View Change

[RFC] region: Allow region_end() to return 64-bit numbers

We most likely operate on regions that end exactly at the 4GiB boundary
(e.g. the boot device on x86). The current code seem to work fine even
if this overflows the `size_t` return value of region_end(). Though, to
be accurate, we should allow this value.

Change-Id: Id261d72c58659f180ca8e5cb6c4bcfc3855ad903
Signed-off-by: Nico Huber <nico.h@gmx.de>
---
M src/commonlib/include/commonlib/region.h
M src/cpu/x86/smm/smm_module_loader.c
M util/cbfstool/cbfstool.c
3 files changed, 5 insertions(+), 5 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/06/79906/1
diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h
index 8de3c5d..a730c58 100644
--- a/src/commonlib/include/commonlib/region.h
+++ b/src/commonlib/include/commonlib/region.h
@@ -122,7 +122,7 @@
return r->size;
}

-static inline size_t region_end(const struct region *r)
+static inline unsigned long long region_end(const struct region *r)
{
return region_offset(r) + region_sz(r);
}
@@ -154,7 +154,7 @@
return region_offset(region_device_region(rdev));
}

-static inline size_t region_device_end(const struct region_device *rdev)
+static inline unsigned long long region_device_end(const struct region_device *rdev)
{
return region_end(region_device_region(rdev));
}
diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c
index 39b36e61..235ef5c 100644
--- a/src/cpu/x86/smm/smm_module_loader.c
+++ b/src/cpu/x86/smm/smm_module_loader.c
@@ -348,7 +348,7 @@

static void print_region(const char *name, const struct region region)
{
- printk(BIOS_DEBUG, "%-12s [0x%zx-0x%zx]\n", name, region_offset(&region),
+ printk(BIOS_DEBUG, "%-12s [0x%zx-0x%llx]\n", name, region_offset(&region),
region_end(&region));
}

diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 10d6501..0719318 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -421,7 +421,7 @@
for (int j = i + 1; j < mmap_window_table_size; j++) {
if (region_overlap(&mmap_window_table[i].flash_space,
&mmap_window_table[j].flash_space)) {
- ERROR("Flash space windows (base=0x%zx, limit=0x%zx) and (base=0x%zx, limit=0x%zx) overlap!\n",
+ ERROR("Flash space windows (base=0x%zx, limit=0x%llx) and (base=0x%zx, limit=0x%llx) overlap!\n",
region_offset(&mmap_window_table[i].flash_space),
region_end(&mmap_window_table[i].flash_space),
region_offset(&mmap_window_table[j].flash_space),
@@ -431,7 +431,7 @@

if (region_overlap(&mmap_window_table[i].host_space,
&mmap_window_table[j].host_space)) {
- ERROR("Host space windows (base=0x%zx, limit=0x%zx) and (base=0x%zx, limit=0x%zx) overlap!\n",
+ ERROR("Host space windows (base=0x%zx, limit=0x%llx) and (base=0x%zx, limit=0x%llx) overlap!\n",
region_offset(&mmap_window_table[i].flash_space),
region_end(&mmap_window_table[i].flash_space),
region_offset(&mmap_window_table[j].flash_space),

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

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: Id261d72c58659f180ca8e5cb6c4bcfc3855ad903
Gerrit-Change-Number: 79906
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Jérémy Compostella <jeremy.compostella@intel.com>
Gerrit-Attention: Jérémy Compostella <jeremy.compostella@intel.com>
Gerrit-MessageType: newchange