From: Eugene Uriev <eugeneuriev@gmail.com>
To: Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de, Eugene Uriev <eugeneuriev@gmail.com>
Subject: [PATCH 7/9] mcheck: introduce mcheck_on_ramrelocation(.)
Date: Sun, 31 Mar 2024 23:03:25 +0300 [thread overview]
Message-ID: <20240331200327.29141-8-eugeneuriev@gmail.com> (raw)
In-Reply-To: <20240331200327.29141-1-eugeneuriev@gmail.com>
The using of pre-reloc/malloc_simple heap is
too hard to follow after the relocation.
So lets drop it from the pedantic registry
and switch to dlmalloc, when moved.
The offset is ignored, but kept in the API
for the probable case, when that early
heap is relocated too.
Signed-off-by: Eugene Uriev <eugeneuriev@gmail.com>
---
common/board_f.c | 4 ++++
common/mcheck_core.inc.h | 11 +++++++++++
2 files changed, 15 insertions(+)
diff --git a/common/board_f.c b/common/board_f.c
index 442b8349d0..ca4d5291a9 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -719,6 +719,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)) {
@@ -744,6 +745,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),
diff --git a/common/mcheck_core.inc.h b/common/mcheck_core.inc.h
index 85a34de295..bade03598f 100644
--- a/common/mcheck_core.inc.h
+++ b/common/mcheck_core.inc.h
@@ -273,5 +273,16 @@ static void mcheck_initialize(mcheck_abortfunc_t new_func, char pedantic_flag)
mcheck_pedantic_flag = pedantic_flag;
}
+void mcheck_on_ramrelocation(size_t offset)
+{
+ char *p;
+ int i;
+ // Simple, but inaccurate strategy: drop the pre-reloc heap
+ for (i = 0; i < REGISTRY_SZ; ++i)
+ if ((p = mcheck_registry[i]) != NULL ) {
+ printf("mcheck, WRN: forgetting %p chunk\n", p);
+ mcheck_registry[i] = 0;
+ }
+}
#endif
#endif
--
2.25.1
next prev parent reply other threads:[~2024-03-31 21:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-31 20:03 [PATCH 0/9] mcheck implementation for U-Boot Eugene Uriev
2024-03-31 20:03 ` [PATCH 1/9] mcheck: prepare +1 tier for mcheck-wrappers, in dl-*alloc commands Eugene Uriev
2024-03-31 20:03 ` [PATCH 2/9] mcheck: Use memset/memcpy instead of MALLOC_ZERO/MALLOC_COPY for mcheck Eugene Uriev
2024-03-31 20:03 ` [PATCH 3/9] mcheck: introduce essentials of mcheck Eugene Uriev
2024-03-31 20:03 ` [PATCH 4/9] mcheck: integrate mcheck into dlmalloc.c Eugene Uriev
2024-03-31 20:03 ` [PATCH 5/9] mcheck: support memalign Eugene Uriev
2024-03-31 20:03 ` [PATCH 6/9] mcheck: add pedantic mode support Eugene Uriev
2024-03-31 20:03 ` Eugene Uriev [this message]
2024-03-31 20:03 ` [PATCH 8/9] mcheck: add stats, add a comment with test results Eugene Uriev
2024-03-31 20:03 ` [PATCH 9/9] mcheck: let mcheck_abortfunc_t print the pointer Eugene Uriev
2024-04-13 16:18 ` [PATCH 0/9] mcheck implementation for U-Boot Tom Rini
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=20240331200327.29141-8-eugeneuriev@gmail.com \
--to=eugeneuriev@gmail.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.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