From: Randolph Sapp <rs@ti.com>
To: Simon Glass <sjg@chromium.org>, <rs@ti.com>
Cc: <robertcnelson@gmail.com>, <ayush@beagleboard.org>,
<Erik.Welsh@octavosystems.com>, <anshuld@ti.com>, <bb@ti.com>,
<trini@konsulko.com>, <afd@ti.com>, <xypron.glpk@gmx.de>,
<ilias.apalodimas@linaro.org>, <u-boot@lists.denx.de>
Subject: Re: [PATCHv7 2/3] test: boot: add a fdt reserved region check
Date: Wed, 13 May 2026 15:22:47 -0500 [thread overview]
Message-ID: <DIHTV2COJM6C.38XX35SDOM6Y@ti.com> (raw)
In-Reply-To: <CAFLszTg+rP=UirpTzUZcg+qo0M2gY7T=BRxPfH=PV+aDSvnjHQ@mail.gmail.com>
On Wed May 13, 2026 at 11:34 AM CDT, Simon Glass wrote:
> Hi Randolph,
>
> On 2026-05-13T01:56:06, Randolph Sapp <rs@ti.com> wrote:
>> test: boot: add a fdt reserved region check
>>
>> Add a image_fdt suite and a check for boot_fdt_add_mem_rsv_regions. This
>> will ensure the user is properly informed of any reservation failures.
>> It will also validate that reservations are cleaned up correctly when
>> switching FDTs.
>>
>> Signed-off-by: Randolph Sapp <rs@ti.com>
>>
>> test/boot/Makefile | 1 +
>> test/boot/image_fdt.c | 53 +++++++++++++++++++++++++++++++++++++++++++++
>> test/cmd_ut.c | 2 ++
>> test/py/tests/test_suite.py | 2 +-
>> 4 files changed, 57 insertions(+), 1 deletion(-)
>
> Change log?
No change log for a patch that didn't exist in the series previously.
>> diff --git a/test/boot/image_fdt.c b/test/boot/image_fdt.c
>> @@ -0,0 +1,53 @@
>> +#include <fdt_support.h>
>> +#include <asm/global_data.h>
>> +#include <config.h>
>> +#include <image.h>
>> +#include <lmb.h>
>> +#include <malloc.h>
>> +#include <test/test.h>
>> +#include <test/ut.h>
>
> Please sort these: config.h (if needed) first, then the plain
> top-level headers alphabetically (fdt_support.h, image.h, lmb.h,
> malloc.h), then asm/global_data.h, then test/*.
>
>> diff --git a/test/boot/image_fdt.c b/test/boot/image_fdt.c
>> @@ -0,0 +1,53 @@
>> +#define FDTDEC_MAX_SIZE (2 * 1024 * 1024)
>> +
>> +#define IMAGE_FDT_TEST(_name, _flags) UNIT_TEST(_name, _flags, image_fdt)
>
> FDTDEC_MAX_SIZE is never referenced - looks copied from
> test/dm/fdtdec.c - please drop it.
>
>> diff --git a/test/boot/image_fdt.c b/test/boot/image_fdt.c
>> @@ -0,0 +1,53 @@
>> + /* Loading a new device tree should be allowed */
>> + blob = malloc(fdt_sz);
>> + ut_assertok_ptr(blob);
>> + memcpy(blob, gd->fdt_blob, fdt_sz);
>> +
>> + nodeoffset = fdt_path_offset(blob, '/reserved-memory');
>> + ut_assertok(fdt_del_node(blob, nodeoffset));
>
> If /reserved-memory is missing, fdt_path_offset() returns a negative
> libfdt error and fdt_del_node() then fails with a confusing message.
> Please ut_assert(nodeoffset >= 0) first.
>
> Also, blob is malloc()'d but never freed.
>
>> diff --git a/test/boot/image_fdt.c b/test/boot/image_fdt.c
>> @@ -0,0 +1,53 @@
>> + boot_fdt_add_mem_rsv_regions(blob);
>> + ut_assert_console_end();
>> + boot_relocate_fdt((char **)&blob, &fdt_sz);
>> +
>> + /* Reservation should not exist now */
>> + ut_asserteq(0, lmb_is_reserved_flags(start, LMB_NOMAP));
>
> What is the boot_relocate_fdt() call testing - could you add a
> comment? The reservation at start is already gone after
> boot_fdt_add_mem_rsv_regions(blob), so the final ut_asserteq() does
> not depend on it. It also allocates from LMB for the relocated copy,
> which then leaks. I'd drop it, or split it into a separate test with
> its own assertions. The (char **)&blob cast is a hint that the call
> doesn't belong here.
>
>> diff --git a/test/boot/image_fdt.c b/test/boot/image_fdt.c
>> @@ -0,0 +1,53 @@
>> +IMAGE_FDT_TEST(test_boot_fdt_add_mem_rsv_regions, UTF_LIVE_TREE | UTF_CONSOLE);
>
> Just to check: the test only touches gd->fdt_blob (the flat tree), so
> why UTF_LIVE_TREE? If you want it to run regardless of OF_LIVE, drop
> the flag (or use UTF_FLAT_TREE). If the intent was to avoid running
> twice, please mention that in a comment.
>
> Regards,
> Simon
As far as I'm aware, UTF_LIVE_TREE is required for this test. I've tried using
UTF_FLAT_TREE and no UTF.*TREE options and for some reason this restricts part
of the parsing that's required for boot_fdt_add_mem_rsv_regions. Operations that
should report errors simply do not without UTF_LIVE_TREE.
next prev parent reply other threads:[~2026-05-13 20:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 1:56 [PATCHv7 0/3] various memory related fixups rs
2026-05-13 1:56 ` [PATCHv7 1/3] boot_fdt_add_mem_rsv_regions: free old dtb reservations rs
2026-05-13 16:26 ` Simon Glass
2026-05-13 1:56 ` [PATCHv7 2/3] test: boot: add a fdt reserved region check rs
2026-05-13 16:34 ` Simon Glass
2026-05-13 20:22 ` Randolph Sapp [this message]
2026-05-15 14:37 ` Simon Glass
2026-05-13 1:56 ` [PATCHv7 3/3] memory: reserve from start_addr_sp to initial_relocaddr rs
2026-05-13 16:26 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DIHTV2COJM6C.38XX35SDOM6Y@ti.com \
--to=rs@ti.com \
--cc=Erik.Welsh@octavosystems.com \
--cc=afd@ti.com \
--cc=anshuld@ti.com \
--cc=ayush@beagleboard.org \
--cc=bb@ti.com \
--cc=ilias.apalodimas@linaro.org \
--cc=robertcnelson@gmail.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox