[PATCH] x86/pvh: print dom0 memory map

Roger Pau Monne posted 1 patch 2 years, 3 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20220124155141.37495-1-roger.pau@citrix.com
There is a newer version of this series
xen/arch/x86/e820.c             | 2 +-
xen/arch/x86/hvm/dom0_build.c   | 6 ++++++
xen/arch/x86/include/asm/e820.h | 1 +
3 files changed, 8 insertions(+), 1 deletion(-)
[PATCH] x86/pvh: print dom0 memory map
Posted by Roger Pau Monne 2 years, 3 months ago
I find it useful for debugging certain issues to have the memory map
dom0 is using, so print it when using `dom0=verbose` on the command
line.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/e820.c             | 2 +-
 xen/arch/x86/hvm/dom0_build.c   | 6 ++++++
 xen/arch/x86/include/asm/e820.h | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c
index aa602773bb..82e9ac46a0 100644
--- a/xen/arch/x86/e820.c
+++ b/xen/arch/x86/e820.c
@@ -88,7 +88,7 @@ static void __init add_memory_region(unsigned long long start,
     e820.nr_map++;
 }
 
-static void __init print_e820_memory_map(struct e820entry *map, unsigned int entries)
+void __init print_e820_memory_map(struct e820entry *map, unsigned int entries)
 {
     unsigned int i;
 
diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index 739bb8adb6..93ebe4f404 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -1271,6 +1271,12 @@ int __init dom0_construct_pvh(struct domain *d, const module_t *image,
         return rc;
     }
 
+    if ( opt_dom0_verbose )
+    {
+        printk("Dom%u memory map:\n", d->domain_id);
+        print_e820_memory_map(d->arch.e820, d->arch.nr_e820);
+    }
+
     printk("WARNING: PVH is an experimental mode with limited functionality\n");
     return 0;
 }
diff --git a/xen/arch/x86/include/asm/e820.h b/xen/arch/x86/include/asm/e820.h
index 9d8f1ba960..7fcfde3b66 100644
--- a/xen/arch/x86/include/asm/e820.h
+++ b/xen/arch/x86/include/asm/e820.h
@@ -32,6 +32,7 @@ extern int e820_change_range_type(
 extern int e820_add_range(
     struct e820map *, uint64_t s, uint64_t e, uint32_t type);
 extern unsigned long init_e820(const char *, struct e820map *);
+extern void print_e820_memory_map(struct e820entry *map, unsigned int entries);
 extern struct e820map e820;
 extern struct e820map e820_raw;
 
-- 
2.34.1


Re: [PATCH] x86/pvh: print dom0 memory map
Posted by Jan Beulich 2 years, 3 months ago
On 24.01.2022 16:51, Roger Pau Monne wrote:
> I find it useful for debugging certain issues to have the memory map
> dom0 is using, so print it when using `dom0=verbose` on the command
> line.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
with one further request:

> --- a/xen/arch/x86/e820.c
> +++ b/xen/arch/x86/e820.c
> @@ -88,7 +88,7 @@ static void __init add_memory_region(unsigned long long start,
>      e820.nr_map++;
>  }
>  
> -static void __init print_e820_memory_map(struct e820entry *map, unsigned int entries)
> +void __init print_e820_memory_map(struct e820entry *map, unsigned int entries)

While making this accessible from the outside, could you please
make "map" pointer-to-const?

Jan