[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 1/2] plat/*: Add memory region names



Add configuration option that enables a name field in
struct ukplat_memregion_desc (inlucde/uk/plat/memory.h).
This option might be useful for debugging.

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
 include/uk/plat/memory.h |  4 ++++
 lib/ukboot/boot.c        | 14 ++++++++++++++
 plat/Config.uk           |  6 ++++++
 plat/kvm/memory.c        | 18 ++++++++++++++++++
 plat/linuxu/memory.c     |  6 ++++++
 plat/xen/arm/setup.c     |  6 ++++++
 plat/xen/memory.c        | 18 ++++++++++++++++++
 plat/xen/x86/setup.c     |  3 +++
 8 files changed, 75 insertions(+)

diff --git a/include/uk/plat/memory.h b/include/uk/plat/memory.h
index 46e3679..eadb088 100644
--- a/include/uk/plat/memory.h
+++ b/include/uk/plat/memory.h
@@ -37,6 +37,7 @@
 #define __UKPLAT_MEMORY_H__
 
 #include <uk/arch/types.h>
+#include <uk/config.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -57,6 +58,9 @@ struct ukplat_memregion_desc {
        void *base;
        __sz len;
        int flags;
+#if UKPLAT_MEMRNAME
+       const char *name;
+#endif
 };
 
 /**
diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
index 5158f32..acbae6e 100644
--- a/lib/ukboot/boot.c
+++ b/lib/ukboot/boot.c
@@ -142,17 +142,31 @@ void ukplat_entry(int argc, char *argv[])
 
                        if ((md.flags & UKPLAT_MEMRF_ALLOCATABLE)
                            != UKPLAT_MEMRF_ALLOCATABLE) {
+#if UKPLAT_MEMRNAME
+                               uk_printd(DLVL_EXTRA, "Skip memory region %d: 
%p - %p (flags: 0x%02x, name: %s)\n",
+                                         i, md.base, (void *)((size_t)md.base
+                                                              + md.len),
+                                         md.flags, md.name);
+#else
                                uk_printd(DLVL_EXTRA, "Skip memory region %d: 
%p - %p (flags: 0x%02x)\n",
                                          i, md.base, (void *)((size_t)md.base
                                                               + md.len),
                                          md.flags);
+#endif
                                continue;
                        }
 
+#if UKPLAT_MEMRNAME
+                       uk_printd(DLVL_EXTRA, "Try  memory region %d: %p - %p 
(flags: 0x%02x, name: %s)...\n",
+                                 i, md.base, (void *)((size_t)md.base
+                                                      + md.len),
+                                 md.flags, md.name);
+#else
                        uk_printd(DLVL_EXTRA, "Try  memory region %d: %p - %p 
(flags: 0x%02x)...\n",
                                  i, md.base, (void *)((size_t)md.base
                                                       + md.len),
                                  md.flags);
+#endif
                        /* try to use memory region to initialize allocator
                         * if it fails, we will try  again with the next region.
                         * As soon we have an allocator, we simply add every
diff --git a/plat/Config.uk b/plat/Config.uk
index fd251dd..e14cc85 100644
--- a/plat/Config.uk
+++ b/plat/Config.uk
@@ -1,3 +1,9 @@
 source "plat/xen/Config.uk"
 source "plat/kvm/Config.uk"
 source "plat/linuxu/Config.uk"
+
+config UKPLAT_MEMRNAME
+       bool "Memory region names"
+       default n
+       help
+               Enable name field in memory region descriptors
diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
index 20f6bd2..cfb15a6 100644
--- a/plat/kvm/memory.c
+++ b/plat/kvm/memory.c
@@ -48,6 +48,9 @@ int ukplat_memregion_get(int i, struct ukplat_memregion_desc 
*m)
                m->len   = (size_t) &_etext - (size_t) &_stext;
                m->flags = (UKPLAT_MEMRF_RESERVED
                            | UKPLAT_MEMRF_READABLE);
+#if UKPLAT_MEMRNAME
+               m->name  = "text";
+#endif
                ret = 0;
                break;
        case 1: /* rodata */
@@ -55,6 +58,9 @@ int ukplat_memregion_get(int i, struct ukplat_memregion_desc 
*m)
                m->len   = (size_t) &_erodata - (size_t) &_etext;
                m->flags = (UKPLAT_MEMRF_RESERVED
                            | UKPLAT_MEMRF_READABLE);
+#if UKPLAT_MEMRNAME
+               m->name  = "rodata";
+#endif
                ret = 0;
                break;
        case 2: /* data */
@@ -63,6 +69,9 @@ int ukplat_memregion_get(int i, struct ukplat_memregion_desc 
*m)
                m->flags = (UKPLAT_MEMRF_RESERVED
                            | UKPLAT_MEMRF_READABLE
                            | UKPLAT_MEMRF_WRITABLE);
+#if UKPLAT_MEMRNAME
+               m->name  = "data";
+#endif
                ret = 0;
                break;
        case 3: /* heap */
@@ -70,6 +79,9 @@ int ukplat_memregion_get(int i, struct ukplat_memregion_desc 
*m)
                m->len   = (size_t) _libkvmplat_stack_top
                           - (size_t) _libkvmplat_heap_start;
                m->flags = UKPLAT_MEMRF_ALLOCATABLE;
+#if UKPLAT_MEMRNAME
+               m->name  = "heap";
+#endif
                ret = 0;
                break;
        case 4: /* stack */
@@ -80,11 +92,17 @@ int ukplat_memregion_get(int i, struct 
ukplat_memregion_desc *m)
                            | UKPLAT_MEMRF_READABLE
                            | UKPLAT_MEMRF_WRITABLE);
                ret = 0;
+#if UKPLAT_MEMRNAME
+               m->name  = "bstack";
+#endif
                break;
        default:
                m->base  = __NULL;
                m->len   = 0;
                m->flags = 0x0;
+#if UKPLAT_MEMRNAME
+               m->name  = __NULL;
+#endif
                ret = -1;
                break;
        }
diff --git a/plat/linuxu/memory.c b/plat/linuxu/memory.c
index 4d674c1..f0f3d7e 100644
--- a/plat/linuxu/memory.c
+++ b/plat/linuxu/memory.c
@@ -52,12 +52,18 @@ int ukplat_memregion_get(int i, struct 
ukplat_memregion_desc *m)
                m->base  = _liblinuxuplat_opts.heap.base;
                m->len   = _liblinuxuplat_opts.heap.len;
                m->flags = UKPLAT_MEMRF_ALLOCATABLE;
+#if UKPLAT_MEMRNAME
+               m->name  = "heap";
+#endif
                ret = 0;
        } else {
                /* invalid memory region index or no heap allocated */
                m->base  = __NULL;
                m->len   = 0;
                m->flags = 0x0;
+#if UKPLAT_MEMRNAME
+               m->name  = __NULL;
+#endif
                ret = -1;
        }
 
diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
index 1f9aa83..c247db5 100644
--- a/plat/xen/arm/setup.c
+++ b/plat/xen/arm/setup.c
@@ -172,11 +172,17 @@ static inline void _dtb_init_mem(uint32_t physical_offset)
        _libxenplat_mrd[0].len   = (size_t) to_virt(max_pfn_p << __PAGE_SHIFT)
                - (size_t) to_virt(start_pfn_p << __PAGE_SHIFT);
        _libxenplat_mrd[0].flags = (UKPLAT_MEMRF_ALLOCATABLE);
+#if UKPLAT_MEMRNAME
+       _libxenplat_mrd[0].name  = "heap";
+#endif
        /* dtb */
        _libxenplat_mrd[1].base  = HYPERVISOR_dtb;
        _libxenplat_mrd[1].len   = fdt_size;
        _libxenplat_mrd[1].flags = (UKPLAT_MEMRF_RESERVED
                                    | UKPLAT_MEMRF_READABLE);
+#if UKPLAT_MEMRNAME
+       _libxenplat_mrd[1].name  = "dtb";
+#endif
        _libxenplat_mrd_num = 2;
 }
 
diff --git a/plat/xen/memory.c b/plat/xen/memory.c
index 2fafdcd..c40ea3d 100644
--- a/plat/xen/memory.c
+++ b/plat/xen/memory.c
@@ -60,18 +60,27 @@ int ukplat_memregion_get(int i, struct 
ukplat_memregion_desc *m)
                m->len   = (size_t) &_etext - (size_t) &_text;
                m->flags = (UKPLAT_MEMRF_RESERVED
                            | UKPLAT_MEMRF_READABLE);
+#if UKPLAT_MEMRNAME
+               m->name  = "text";
+#endif
                break;
        case 1: /* ro data */
                m->base  = &_rodata;
                m->len   = (size_t) &_erodata - (size_t) &_rodata;
                m->flags = (UKPLAT_MEMRF_RESERVED
                               | UKPLAT_MEMRF_READABLE);
+#if UKPLAT_MEMRNAME
+               m->name  = "rodata";
+#endif
                break;
        case 2: /* ctors, dtors */
                m->base  = &_erodata;
                m->len   = (size_t) &_data - (size_t) &_erodata;
                m->flags = (UKPLAT_MEMRF_RESERVED
                            | UKPLAT_MEMRF_READABLE);
+#if UKPLAT_MEMRNAME
+               m->name  = "ctors+dtors";
+#endif
                break;
        case 3: /* data */
                m->base  = &_data;
@@ -79,6 +88,9 @@ int ukplat_memregion_get(int i, struct ukplat_memregion_desc 
*m)
                m->flags = (UKPLAT_MEMRF_RESERVED
                            | UKPLAT_MEMRF_READABLE
                            | UKPLAT_MEMRF_WRITABLE);
+#if UKPLAT_MEMRNAME
+               m->name  = "data";
+#endif
                break;
        case 4: /* bss */
                m->base  = &__bss_start;
@@ -86,12 +98,18 @@ int ukplat_memregion_get(int i, struct 
ukplat_memregion_desc *m)
                m->flags = (UKPLAT_MEMRF_RESERVED
                            | UKPLAT_MEMRF_READABLE
                            | UKPLAT_MEMRF_WRITABLE);
+#if UKPLAT_MEMRNAME
+               m->name  = "bss";
+#endif
                break;
        default:
                if (i < 0 || i >= ukplat_memregion_count()) {
                        m->base  = __NULL;
                        m->len   = 0;
                        m->flags = 0x0;
+#if UKPLAT_MEMRNAME
+                       m->name  = __NULL;
+#endif
                        return -1;
                } else {
                        memcpy(m, &_libxenplat_mrd[i - 5], sizeof(*m));
diff --git a/plat/xen/x86/setup.c b/plat/xen/x86/setup.c
index cf8bad2..3392841 100644
--- a/plat/xen/x86/setup.c
+++ b/plat/xen/x86/setup.c
@@ -165,6 +165,9 @@ static inline void _init_mem(void)
        _libxenplat_mrd[0].len   = (size_t) to_virt(max_pfn << __PAGE_SHIFT)
                - (size_t) to_virt(start_pfn << __PAGE_SHIFT);
        _libxenplat_mrd[0].flags = (UKPLAT_MEMRF_ALLOCATABLE);
+#if UKPLAT_MEMRNAME
+       _libxenplat_mrd[0].name  = "heap";
+#endif
        _libxenplat_mrd_num = 1;
 }
 
-- 
2.7.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.