From af0d4bce65df277b56e495892dff1c712ed76ddd Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Thu, 11 Jan 2024 18:59:24 +0100 Subject: region: Introduce region_create() functions We introduce two new functions to create region objects. They allow us to check for integer overflows (region_create_untrusted()) or assert their absence (region_create()). This fixes potential overflows in region_overlap() checks in SMI handlers, where we would wrongfully report MMIO as *not* overlapping SMRAM. Also, two cases of strtol() in parse_region() (cbfstool), where the results were implicitly converted to `size_t`, are replaced with the unsigned strtoul(). FIT payload support is left out, as it doesn't use the region API (only the struct). Change-Id: I4ae3e6274c981c9ab4fb1263c2a72fa68ef1c32b Ticket: https://ticket.coreboot.org/issues/522 Found-by: Vadim Zaliva Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/79905 Tested-by: build bot (Jenkins) Reviewed-by: Felix Held --- src/soc/qualcomm/common/qclib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/soc/qualcomm/common/qclib.c') diff --git a/src/soc/qualcomm/common/qclib.c b/src/soc/qualcomm/common/qclib.c index 97b6e2d4f7..deb047d45a 100644 --- a/src/soc/qualcomm/common/qclib.c +++ b/src/soc/qualcomm/common/qclib.c @@ -101,9 +101,8 @@ static void write_ddr_information(struct qclib_cb_if_table_entry *te) uint64_t ddr_size; /* Save DDR info in SRAM region to share with ramstage */ - ddr_region->offset = te->blob_address; ddr_size = te->size; - ddr_region->size = ddr_size * MiB; + *ddr_region = region_create(te->blob_address, ddr_size * MiB); /* Use DDR info to configure MMU */ qc_mmu_dram_config_post_dram_init( -- cgit v1.2.3