[PATCH 11/11] test: boot: imagemap: caller-owned region not resized
Simon Glass
sjg at chromium.org
Tue Oct 20 00:57:07 PDT 2026
Hi Daniel,
On 2026-10-14T08:38:38, Daniel Golle <daniel at makrotopia.org> wrote:
> test: boot: imagemap: caller-owned region not resized
>
> Add a unit test that locks down the fix in imagemap_map(): a larger
> request against a region recorded by imagemap_map_to() (which the
> caller owns and is not LMB-reserved) falls through to a fresh LMB
> allocation instead of resizing the caller's memory.
>
> The test reserves a caller-owned buffer inside the LMB-managed RAM,
> records a 64-byte region there via imagemap_map_to() with a guard
> pattern beyond the payload, then issues a 256-byte imagemap_map() at the
> same base. It verifies the returned pointer differs from the caller's
> buffer, the guard tail is unchanged, and the new region is LMB-reserved.
>
> Signed-off-by: Daniel Golle <daniel at makrotopia.org>
>
> test/boot/imagemap.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 97 insertions(+)
> diff --git a/test/boot/imagemap.c b/test/boot/imagemap.c
> @@ -316,6 +316,103 @@ static int imagemap_test_map_to(struct unit_test_state *uts)
> + * Mirrors the scenario Simon Glass asked to be locked down: a guard
> + * pattern in dst beyond the requested 64 bytes must survive, the returned
> + * pointer must differ from dst, and the new region must be LMB-reserved.
> + */
Please drop my name from the comment - the preceding paragraphs
already explain the scenario.
> diff --git a/test/boot/imagemap.c b/test/boot/imagemap.c
> @@ -316,6 +316,103 @@ static int imagemap_test_map_to(struct unit_test_state *uts)
> + phys_addr_t dst_phys;
> + u8 *dst;
> + const ulong dst_size = 512;
> + u8 guard[512 - 64];
It would be worth lifting 512 and 64 to named constants (or deriving
the guard size from dst_size) so the two spellings cannot drift.
> diff --git a/test/boot/imagemap.c b/test/boot/imagemap.c
> @@ -316,6 +316,103 @@ static int imagemap_test_map_to(struct unit_test_state *uts)
> + /* Returned pointer must be a different buffer */
> + ut_assert((char *)p != (char *)dst);
The casts to 'char *' do not buy anything - ut_assert(p != dst)
compiles and reads more cleanly.
Regards,
Simon
More information about the openwrt-devel
mailing list