[PATCH 2/5] x86/boot: Introduce bootstrap_unmap()

Andrew Cooper posted 5 patches 1 month, 1 week ago
[PATCH 2/5] x86/boot: Introduce bootstrap_unmap()
Posted by Andrew Cooper 1 month, 1 week ago
We're about to introduce alternative mapping functions, and passing NULL was
always a slightly weird way to express unmap.  Make an explicit unmap
function, to avoid having two different valid ways of unmapping.

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/cpu/microcode/core.c |  6 +++---
 xen/arch/x86/include/asm/setup.h  |  2 ++
 xen/arch/x86/pv/dom0_build.c      |  2 +-
 xen/arch/x86/setup.c              | 10 ++++++----
 xen/xsm/xsm_core.c                |  4 ++--
 xen/xsm/xsm_policy.c              |  2 +-
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index 1d58cb0f3bc1..cf6517293375 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -198,7 +198,7 @@ static void __init microcode_scan_module(struct boot_info *bi)
             ucode_blob.data = cd.data;
             break;
         }
-        bootstrap_map(NULL);
+        bootstrap_unmap();
     }
 }
 
@@ -763,13 +763,13 @@ static int __init cf_check microcode_init(void)
      */
     if ( ucode_blob.size )
     {
-        bootstrap_map(NULL);
+        bootstrap_unmap();
         ucode_blob.size = 0;
         ucode_blob.data = NULL;
     }
     else if ( ucode_mod.mod_end )
     {
-        bootstrap_map(NULL);
+        bootstrap_unmap();
         ucode_mod.mod_end = 0;
     }
 
diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index 811855e57478..8b7843104ff7 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -37,7 +37,9 @@ extern struct boot_info xen_boot_info;
 
 unsigned long initial_images_nrpages(nodeid_t node);
 void discard_initial_images(void);
+
 void *bootstrap_map(const module_t *mod);
+void bootstrap_unmap(void);
 
 int remove_xen_ranges(struct rangeset *r);
 
diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
index ee9ecdc2abbf..cdae17b27654 100644
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -830,7 +830,7 @@ static int __init dom0_construct(struct domain *d,
         printk("Failed to load the kernel binary\n");
         goto out;
     }
-    bootstrap_map(NULL);
+    bootstrap_unmap();
 
     if ( UNSET_ADDR != parms.virt_hypercall )
     {
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 8c10fe51dfad..8e32d6c49c54 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -471,13 +471,15 @@ static void *__init bootstrap_map_addr(paddr_t start, paddr_t end)
 
 void *__init bootstrap_map(const module_t *mod)
 {
-    if ( !mod )
-        return bootstrap_map_addr(0, 0);
-
     return bootstrap_map_addr(pfn_to_paddr(mod->mod_start),
                               pfn_to_paddr(mod->mod_start) + mod->mod_end);
 }
 
+void __init bootstrap_unmap(void)
+{
+    bootstrap_map_addr(0, 0);
+}
+
 static void __init move_memory(
     uint64_t dst, uint64_t src, unsigned int size)
 {
@@ -1402,7 +1404,7 @@ void asmlinkage __init noreturn __start_xen(void)
     }
 
     modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end);
-    bootstrap_map(NULL);
+    bootstrap_unmap();
 
 #ifndef highmem_start
     /* Don't allow split below 4Gb. */
diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c
index 6e3fac68c057..f255fb63bf6f 100644
--- a/xen/xsm/xsm_core.c
+++ b/xen/xsm/xsm_core.c
@@ -153,14 +153,14 @@ int __init xsm_multiboot_init(struct boot_info *bi)
         ret = xsm_multiboot_policy_init(bi, &policy_buffer, &policy_size);
         if ( ret )
         {
-            bootstrap_map(NULL);
+            bootstrap_unmap();
             printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret);
             return -EINVAL;
         }
     }
 
     ret = xsm_core_init(policy_buffer, policy_size);
-    bootstrap_map(NULL);
+    bootstrap_unmap();
 
     return 0;
 }
diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c
index 6f799dd28f5b..35f36c6f2359 100644
--- a/xen/xsm/xsm_policy.c
+++ b/xen/xsm/xsm_policy.c
@@ -63,7 +63,7 @@ int __init xsm_multiboot_policy_init(
 
         }
 
-        bootstrap_map(NULL);
+        bootstrap_unmap();
     }
 
     return rc;
-- 
2.39.5


Re: [PATCH 2/5] x86/boot: Introduce bootstrap_unmap()
Posted by Daniel P. Smith 1 month, 1 week ago
On 10/24/24 10:26, Andrew Cooper wrote:
> We're about to introduce alternative mapping functions, and passing NULL was
> always a slightly weird way to express unmap.  Make an explicit unmap
> function, to avoid having two different valid ways of unmapping.
> 
> 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>