diff options
| author | Tom Rini <[email protected]> | 2025-09-23 13:41:16 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-09-23 13:41:16 -0600 |
| commit | 4d84fa1261eb27d57687f2e4c404a78b8653c183 (patch) | |
| tree | a96254c4dbabf9e29d981be8a295058db7bf32d4 /test | |
| parent | b82a1fa7ddc7f3be2f3b75898d5dc44c34420bdd (diff) | |
| parent | 4907a920e8292e9e38ddab4d211dfd5499097a8c (diff) | |
Merge patch series "mkimage: Detect FIT image load address overlaps and fix related test/DTS issues"
Aristo Chen <[email protected]> says:
This patch series enhances FIT image robustness by adding **memory
region overlap detection** to `mkimage` and fixing existing overlaps
in DTS files and `binman` tests.
The primary goal is to prevent runtime memory corruption from
conflicting load addresses in FIT images.
Key Changes:
1. `mkimage` Overlap Detection: A new validation in
`tools/fit_image.c` checks for overlapping load addresses
within FIT configurations. `mkimage` now errors out with
detailed info on conflicts, preventing bad FIT image creation.
2. New Test Case: A Python test verifies the new detection.
It intentionally creates an overlap (kernel and FDT)
to confirm correct error handling.
3. Fixes for Existing Overlaps:
* Board DTS (k3-am6xx): Adjusted load addresses for TI
firmware stubs to prevent conflicts. This resolves
previously undetected overlaps.
* `binman` Tests: Fixed several tests. U-Boot load
addresses were shifted to avoid ATF conflicts. A new
linker script for TEE ELF sections ensures distinct
memory layouts.
4. Documentation: Added guidance for developers on how to
determine ELF load addresses using readelf, linker scripts,
and objdump when working with binman FIT images.
Impact:
This series improves FIT image reliability by catching overlaps
at build time, helping developers resolve issues before runtime
failures.
Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'test')
| -rw-r--r-- | test/py/tests/test_fit_mkimage_validate.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/py/tests/test_fit_mkimage_validate.py b/test/py/tests/test_fit_mkimage_validate.py index 170b2a8cbbb..27299a58f33 100644 --- a/test/py/tests/test_fit_mkimage_validate.py +++ b/test/py/tests/test_fit_mkimage_validate.py @@ -103,3 +103,68 @@ def test_fit_invalid_default_config(ubman): assert result.returncode != 0, "mkimage should fail due to missing default config" assert re.search(r"Default configuration '.*' not found under /configurations", result.stderr) + +def test_fit_load_addr_overlap(ubman): + """Test that mkimage fails when load address overlap""" + + its_fname = fit_util.make_fname(ubman, "invalid.its") + itb_fname = fit_util.make_fname(ubman, "invalid.itb") + kernel = fit_util.make_kernel(ubman, 'kernel.bin', 'kernel') + fdt = fit_util.make_dtb(ubman, ''' +/dts-v1/; +/ { + model = "Test FDT"; + compatible = "test"; +}; +''', 'test') + + # Write ITS with an invalid reference to a nonexistent default config + its_text = ''' +/dts-v1/; + +/ { + images { + kernel@1 { + description = "Test Kernel"; + data = /incbin/("kernel.bin"); + type = "kernel"; + arch = "sandbox"; + os = "linux"; + compression = "none"; + load = <0x40000>; + entry = <0x40000>; + }; + fdt@1 { + description = "Test FDT"; + data = /incbin/("test.dtb"); + type = "flat_dt"; + arch = "sandbox"; + os = "linux"; + compression = "none"; + load = <0x40000>; + entry = <0x40000>; + }; + }; + + configurations { + default = "conf@1"; + conf@1 { + kernel = "kernel@1"; + fdt = "fdt@1"; + }; + }; +}; +''' + + with open(its_fname, 'w') as f: + f.write(its_text) + + mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') + cmd = [mkimage, '-f', its_fname, itb_fname] + + result = subprocess.run(cmd, capture_output=True, text=True) + + assert result.returncode != 0, "mkimage should fail due to memory overlap" + assert "Error: Overlap detected:" in result.stderr + # Check that it identifies the specific overlapping components + assert "kernel@1" in result.stderr and "fdt@1" in result.stderr |
