[PATCH 5/5] x86/boot: Drop the mbi and mod pointers in __start_xen()

Andrew Cooper posted 5 patches 1 month, 1 week ago
[PATCH 5/5] x86/boot: Drop the mbi and mod pointers in __start_xen()
Posted by Andrew Cooper 1 month, 1 week ago
We can't drop them fully yet, but we can limit their scope to almost nothing,
which serves the same purpose.

This removes the ability to accidentally reintroduce buggy uses of
__va(mbi->mods_addr).

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>

v7.5:
 * New
---
 xen/arch/x86/setup.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 5413e1c71be6..511cf5b97909 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1026,8 +1026,6 @@ void asmlinkage __init noreturn __start_xen(void)
     struct cpu_info *info = get_cpu_info(), *bsp_info;
     unsigned int initrdidx, num_parked = 0;
     struct boot_info *bi;
-    multiboot_info_t *mbi;
-    module_t *mod;
     unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1];
     int i, j, e820_warn = 0, bytes = 0;
     unsigned long eb_start, eb_end;
@@ -1063,16 +1061,22 @@ void asmlinkage __init noreturn __start_xen(void)
 
     if ( pvh_boot )
     {
+        multiboot_info_t *mbi;
+        module_t *mod;
+
         pvh_init(&mbi, &mod);
         /*
          * mbi and mod are regular pointers to .initdata.  These remain valid
          * across move_xen().
          */
+
+        bi = multiboot_fill_boot_info(mbi, mod);
     }
     else
     {
-        mbi = __va(multiboot_ptr);
-        mod = __va(mbi->mods_addr);
+        multiboot_info_t *mbi = __va(multiboot_ptr);
+
+        bi = multiboot_fill_boot_info(mbi, __va(mbi->mods_addr));
 
         /*
          * For MB1/2, mbi and mod are directmap pointers into the trampoline.
@@ -1085,12 +1089,8 @@ void asmlinkage __init noreturn __start_xen(void)
         ASSERT(multiboot_ptr < MB(1) || xen_phys_start);
     }
 
-    bi = multiboot_fill_boot_info(mbi, mod);
     bi->module_map = module_map; /* Temporary */
 
-    /* Use bi-> instead */
-#define mbi DO_NOT_USE
-
     /* Parse the command-line options. */
     if ( (kextra = strstr(bi->cmdline, " -- ")) != NULL )
     {
-- 
2.39.5


Re: [PATCH 5/5] x86/boot: Drop the mbi and mod pointers in __start_xen()
Posted by Daniel P. Smith 1 month, 1 week ago
On 10/24/24 10:26, Andrew Cooper wrote:
> We can't drop them fully yet, but we can limit their scope to almost nothing,
> which serves the same purpose.
> 
> This removes the ability to accidentally reintroduce buggy uses of
> __va(mbi->mods_addr).
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> CC: Daniel P. Smith <dpsmith@apertussolutions.com>

Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>