diff mbox series

[v5,02/44] x86/boot: move boot loader name to boot info

Message ID 20241006214956.24339-3-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
Transition the incoming boot loader name to be held in struct boot_info.

No functional change intended.

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

Comments

Jason Andryuk Oct. 7, 2024, 5:58 p.m. UTC | #1
On 2024-10-06 17:49, Daniel P. Smith wrote:
> Transition the incoming boot loader name to be held in struct boot_info.
> 
> No functional change intended.
> 
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Jan Beulich Oct. 9, 2024, 3:07 p.m. UTC | #2
On 06.10.2024 23:49, Daniel P. Smith wrote:
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -285,6 +285,9 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p)
>  
>      bi->nr_modules = (mbi->flags & MBI_MODULES) ? mbi->mods_count : 0;
>  
> +    bi->loader = (mbi->flags & MBI_LOADERNAME) ?
> +                            __va(mbi->boot_loader_name) : "unknown";

Either (noting that generally we exempt ?: from the operator-on-earlier-line
rule)

    bi->loader = (mbi->flags & MBI_LOADERNAME) ? __va(mbi->boot_loader_name)
                                               : "unknown";

or 

    bi->loader = (mbi->flags & MBI_LOADERNAME)
                 ? __va(mbi->boot_loader_name) : "unknown";

or

    bi->loader = (mbi->flags & MBI_LOADERNAME)
        ? __va(mbi->boot_loader_name) : "unknown";

(in the order of my personal preference).

Jan
Daniel P. Smith Oct. 10, 2024, 12:55 a.m. UTC | #3
On 10/9/24 11:07, Jan Beulich wrote:
> On 06.10.2024 23:49, Daniel P. Smith wrote:
>> --- a/xen/arch/x86/setup.c
>> +++ b/xen/arch/x86/setup.c
>> @@ -285,6 +285,9 @@ static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p)
>>   
>>       bi->nr_modules = (mbi->flags & MBI_MODULES) ? mbi->mods_count : 0;
>>   
>> +    bi->loader = (mbi->flags & MBI_LOADERNAME) ?
>> +                            __va(mbi->boot_loader_name) : "unknown";
> 
> Either (noting that generally we exempt ?: from the operator-on-earlier-line
> rule)
> 
>      bi->loader = (mbi->flags & MBI_LOADERNAME) ? __va(mbi->boot_loader_name)
>                                                 : "unknown";
> 
> or
> 
>      bi->loader = (mbi->flags & MBI_LOADERNAME)
>                   ? __va(mbi->boot_loader_name) : "unknown";
> 
> or
> 
>      bi->loader = (mbi->flags & MBI_LOADERNAME)
>          ? __va(mbi->boot_loader_name) : "unknown";
> 
> (in the order of my personal preference).

I would prefer the first as well. Will adjust.

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 a649500ee3a2..98ba773c9bc5 100644
--- a/xen/arch/x86/include/asm/bootinfo.h
+++ b/xen/arch/x86/include/asm/bootinfo.h
@@ -14,6 +14,8 @@ 
  */
 struct boot_info {
     unsigned int nr_modules;
+
+    const char *loader;
 };
 
 #endif /* __XEN_X86_BOOTINFO_H__ */
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index b75deb4fe4ee..aafc098ca268 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -285,6 +285,9 @@  static struct boot_info __init *multiboot_fill_boot_info(unsigned long mbi_p)
 
     bi->nr_modules = (mbi->flags & MBI_MODULES) ? mbi->mods_count : 0;
 
+    bi->loader = (mbi->flags & MBI_LOADERNAME) ?
+                            __va(mbi->boot_loader_name) : "unknown";
+
     return bi;
 }
 
@@ -978,7 +981,7 @@  static struct domain *__init create_dom0(const module_t *image,
 
 void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
 {
-    const char *memmap_type = NULL, *loader, *cmdline = "";
+    const char *memmap_type = NULL, *cmdline = "";
     char *kextra;
     void *bsp_stack;
     struct cpu_info *info = get_cpu_info(), *bsp_info;
@@ -1032,12 +1035,9 @@  void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
 
     bi = multiboot_fill_boot_info(mbi_p);
 
-    loader = (mbi->flags & MBI_LOADERNAME) ? __va(mbi->boot_loader_name)
-                                           : "unknown";
-
     /* Parse the command-line options. */
     if ( mbi->flags & MBI_CMDLINE )
-        cmdline = cmdline_cook(__va(mbi->cmdline), loader);
+        cmdline = cmdline_cook(__va(mbi->cmdline), bi->loader);
 
     if ( (kextra = strstr(cmdline, " -- ")) != NULL )
     {
@@ -1078,7 +1078,7 @@  void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
     if ( pvh_boot )
         pvh_print_info();
 
-    printk("Bootloader: %s\n", loader);
+    printk("Bootloader: %s\n", bi->loader);
 
     printk("Command line: %s\n", cmdline);
 
@@ -1171,7 +1171,7 @@  void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
         l3_bootmap[l3_table_offset(BOOTSTRAP_MAP_BASE)] =
             l3e_from_paddr(__pa(l2_bootmap), __PAGE_HYPERVISOR);
 
-        memmap_type = loader;
+        memmap_type = bi->loader;
     }
     else if ( efi_enabled(EFI_BOOT) )
         memmap_type = "EFI";
@@ -2039,7 +2039,7 @@  void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
      */
     dom0 = create_dom0(mod, modules_headroom,
                        initrdidx < bi->nr_modules ? mod + initrdidx : NULL,
-                       kextra, loader);
+                       kextra, bi->loader);
     if ( !dom0 )
         panic("Could not set up DOM0 guest OS\n");