diff mbox series

[v5,12/44] x86/boot: add start and size fields to struct boot_module

Message ID 20241006214956.24339-13-dpsmith@apertussolutions.com (mailing list archive)
State Superseded
Headers show
Series Boot modules for Hyperlaunch | expand

Commit Message

Daniel P. Smith Oct. 6, 2024, 9:49 p.m. UTC
This commit introduces the start and size fields to struct boot_module and adds
a corresponding bootstrap mapping function, bootstrap_map_bm.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/x86/include/asm/bootinfo.h |  2 ++
 xen/arch/x86/include/asm/setup.h    |  2 ++
 xen/arch/x86/setup.c                | 13 +++++++++++++
 3 files changed, 17 insertions(+)

Comments

Jason Andryuk Oct. 7, 2024, 8:06 p.m. UTC | #1
On 2024-10-06 17:49, Daniel P. Smith wrote:
> This commit introduces the start and size fields to struct boot_module and adds
> a corresponding bootstrap mapping function, bootstrap_map_bm.
> 
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Jan Beulich Oct. 9, 2024, 3:39 p.m. UTC | #2
On 06.10.2024 23:49, Daniel P. Smith wrote:
> This commit introduces the start and size fields to struct boot_module and adds
> a corresponding bootstrap mapping function, bootstrap_map_bm.

Which then is left with no caller. Misra doesn't like unreachable code.

Jan
Daniel P. Smith Oct. 10, 2024, 1:23 a.m. UTC | #3
On 10/9/24 11:39, Jan Beulich wrote:
> On 06.10.2024 23:49, Daniel P. Smith wrote:
>> This commit introduces the start and size fields to struct boot_module and adds
>> a corresponding bootstrap mapping function, bootstrap_map_bm.
> 
> Which then is left with no caller. Misra doesn't like unreachable code.

Only until the upcoming commit makes use, but yes these should be 
standalone and thus complaint. I will rework to ensure there is a use of 
the function when it is introduced.

v/r,
dps
diff mbox series

Patch

diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h
index 021ff0d93643..2ee0d5ad6d72 100644
--- a/xen/arch/x86/include/asm/bootinfo.h
+++ b/xen/arch/x86/include/asm/bootinfo.h
@@ -35,6 +35,8 @@  struct boot_module {
     uint32_t flags;
 #define BOOTMOD_FLAG_X86_RELOCATED     (1U << 0)
 
+    paddr_t start;
+    size_t size;
 };
 
 /*
diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index 213584b05fb2..bb7e73258a21 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -2,6 +2,7 @@ 
 #define __X86_SETUP_H_
 
 #include <xen/multiboot.h>
+#include <asm/bootinfo.h>
 #include <asm/numa.h>
 
 extern const char __2M_text_start[], __2M_text_end[];
@@ -38,6 +39,7 @@  unsigned long initial_images_nrpages(nodeid_t node);
 void discard_initial_images(void);
 void *bootstrap_map_addr(paddr_t start, paddr_t end);
 void *bootstrap_map(const module_t *mod);
+void *bootstrap_map_bm(const struct boot_module *bm);
 
 int remove_xen_ranges(struct rangeset *r);
 
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 1cc7fcba094b..093a4f5380d1 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -309,8 +309,13 @@  static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p)
      * should have been reserved to hold an entry for Xen.
      */
     for ( i = 0; i <= bi->nr_modules; i++ )
+    {
         bi->mods[i].mod = &mods[i];
 
+        bi->mods[i].start = (paddr_t)mods[i].mod_start;
+        bi->mods[i].size = mods[i].mod_end - mods[i].mod_start;
+    }
+
     /* map the last mb module for xen entry */
     bi->mods[bi->nr_modules].type = BOOTMOD_XEN;
     bi->mods[bi->nr_modules].mod = &mods[bi->nr_modules];
@@ -477,6 +482,14 @@  void *__init bootstrap_map(const module_t *mod)
                               pfn_to_paddr(mod->mod_start) + mod->mod_end);
 }
 
+void *__init bootstrap_map_bm(const struct boot_module *bm)
+{
+    if ( !bm )
+        return bootstrap_map_addr(0, 0);
+
+    return bootstrap_map_addr(bm->start, bm->start + bm->size);
+}
+
 static void __init move_memory(
     uint64_t dst, uint64_t src, unsigned int size)
 {