diff options
author | Daniel Axtens <dja@axtens.net> | 2022-04-21 15:24:16 +1000 |
---|---|---|
committer | Daniel Kiper <daniel.kiper@oracle.com> | 2022-07-04 14:25:29 +0200 |
commit | 8afa5ef45b797ba5d8147ceee85ac2c59dcc7f09 (patch) | |
tree | e0ddb870d96ed242bed594457e99a968f47e1e3c | |
parent | 052e6068be622ff53f1238b449c300dbd0a8abcd (diff) | |
download | grub-8afa5ef45b797ba5d8147ceee85ac2c59dcc7f09.tar.gz |
mm: Debug support for region operations
This is handy for debugging. Enable with "set debug=regions".
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Patrick Steinhardt <ps@pks.im>
-rw-r--r-- | grub-core/kern/mm.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index b406906a9..43d4e609f 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -115,9 +115,8 @@ grub_mm_init_region (void *addr, grub_size_t size) grub_mm_header_t h; grub_mm_region_t r, *p, q; -#if 0 - grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size); -#endif + grub_dprintf ("regions", "Using memory for heap: start=%p, end=%p\n", + addr, (char *) addr + (unsigned int) size); /* Exclude last 4K to avoid overflows. */ /* If addr + 0x1000 overflows then whole region is in excluded zone. */ @@ -142,8 +141,14 @@ grub_mm_init_region (void *addr, grub_size_t size) * addr q * |----size-----|-q->pre_size-|<q region>| */ + grub_dprintf ("regions", "Can we extend into region above?" + " %p + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " ?=? %p\n", + (grub_uint8_t *) addr, size, q->pre_size, (grub_uint8_t *) q); if ((grub_uint8_t *) addr + size + q->pre_size == (grub_uint8_t *) q) { + grub_dprintf ("regions", "Yes: extending a region: (%p -> %p) -> (%p -> %p)\n", + q, (grub_uint8_t *) q + sizeof (*q) + q->size, + addr, (grub_uint8_t *) q + sizeof (*q) + q->size); /* * Yes, we can merge the memory starting at addr into the * existing region from below. Align up addr to GRUB_MM_ALIGN @@ -185,9 +190,15 @@ grub_mm_init_region (void *addr, grub_size_t size) * q addr * |<q region>|-q->post_size-|----size-----| */ + grub_dprintf ("regions", "Can we extend into region below?" + " %p + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " ?=? %p\n", + (grub_uint8_t *) q, sizeof(*q), q->size, q->post_size, (grub_uint8_t *) addr); if ((grub_uint8_t *) q + sizeof (*q) + q->size + q->post_size == (grub_uint8_t *) addr) { + grub_dprintf ("regions", "Yes: extending a region: (%p -> %p) -> (%p -> %p)\n", + q, (grub_uint8_t *) q + sizeof (*q) + q->size, + q, (grub_uint8_t *) addr + size); /* * Yes! Follow a similar pattern to above, but simpler. * Our header starts at address - post_size, which should align us @@ -213,6 +224,8 @@ grub_mm_init_region (void *addr, grub_size_t size) } } + grub_dprintf ("regions", "No: considering a new region at %p of size %" PRIxGRUB_SIZE "\n", + addr, size); /* Allocate a region from the head. */ r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); |