diff options
author | Tom Rini <trini@konsulko.com> | 2024-04-12 16:23:19 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-04-12 16:23:19 -0600 |
commit | 977fc15e9806ce3af2c20228acc3c744f9c3ed0c (patch) | |
tree | a6c6f98a21729e6e25078c47737558a1b3518003 /common/board_f.c | |
parent | 13c1100335e40acb1066e074eb061387fd103c36 (diff) | |
parent | 707a6dfb2b8429b3d361c8c884ada48ebae6f1e4 (diff) |
Merge patch series "mcheck implementation for U-Boot"
Eugene Uriev <eugeneuriev@gmail.com> says:
There was no "mcheck" for U-Boot before.
Since U-Boot has only 1 thread, and normally makes 4000+ - 6000+
mallocs, it's better to use havier canaries to protect heap-chunks.
My variant uses 2x8 = 16byte-long protector. And
the multiplier could be changed to tune speed/protection tradeoff.
This protects not only against memset()-s, but against "near" wild
pointers too, and makes more probable to catch "distant" ones.
The core file of the set is included into the C-file, not complied
separately in order to enable (potential) coexisting of
mcheck-protectors, e.g. malloc_simple(.) and dlmalloc simultaneously.
My tests were for ARM SoC, 64bit, so the patch is
aware of alignment.
Primary this patch is for using by developers: to verify,
if a change doesn't break the heap integrity.
By default the mcheck is disabled and wouldn't affect the boot.
I used pedantic mode, canary=16byte, registry-size=6608.
For my system the overhead was 230ms.
Diffstat (limited to 'common/board_f.c')
-rw-r--r-- | common/board_f.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/common/board_f.c b/common/board_f.c index 8bada6ff2ee..039d6d712d0 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -718,6 +718,7 @@ static int reloc_bloblist(void) return 0; } +void mcheck_on_ramrelocation(size_t offset); static int setup_reloc(void) { if (!(gd->flags & GD_FLG_SKIP_RELOC)) { @@ -743,6 +744,9 @@ static int setup_reloc(void) if (gd->flags & GD_FLG_SKIP_RELOC) { debug("Skipping relocation due to flag\n"); } else { +#ifdef MCHECK_HEAP_PROTECTION + mcheck_on_ramrelocation(gd->reloc_off); +#endif debug("Relocation Offset is: %08lx\n", gd->reloc_off); debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n", gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd), |