diff mbox series

[v5,11/44] x86/boot: split bootstrap_map_addr() out of bootstrap_map()

Message ID 20241006214956.24339-12-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
From: Andrew Cooper <andrew.cooper3@citrix.com>

Using an interface based on addresses directly, not modules.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/x86/include/asm/setup.h |  1 +
 xen/arch/x86/setup.c             | 19 +++++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

Comments

Jason Andryuk Oct. 7, 2024, 8:04 p.m. UTC | #1
On 2024-10-06 17:49, Daniel P. Smith wrote:
> From: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Using an interface based on addresses directly, not modules.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Jan Beulich Oct. 9, 2024, 3:38 p.m. UTC | #2
On 06.10.2024 23:49, Daniel P. Smith wrote:
> From: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Using an interface based on addresses directly, not modules.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> ---
>  xen/arch/x86/include/asm/setup.h |  1 +
>  xen/arch/x86/setup.c             | 19 +++++++++++++------
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
> index 3d189521189d..213584b05fb2 100644
> --- a/xen/arch/x86/include/asm/setup.h
> +++ b/xen/arch/x86/include/asm/setup.h
> @@ -36,6 +36,7 @@ extern struct boot_info xen_boot_info;
>  
>  unsigned long initial_images_nrpages(nodeid_t node);
>  void discard_initial_images(void);
> +void *bootstrap_map_addr(paddr_t start, paddr_t end);

Nothing is being said about why this function needs a declaration here
and ...

> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -437,24 +437,22 @@ static void __init normalise_cpu_order(void)
>   * Ensure a given physical memory range is present in the bootstrap mappings.
>   * Use superpage mappings to ensure that pagetable memory needn't be allocated.
>   */
> -void *__init bootstrap_map(const module_t *mod)
> +void *__init bootstrap_map_addr(paddr_t start, paddr_t end)

... isn't instead static here. Bugseng folks have put in quite a bit of
effort to remove such anomalies (which Misra doesn't like) from the code
base; I don't think we should introduce new ones. I didn't peek ahead
further than just the next patch, where the function gains a new use,
but could still be static, so it's possible I'm simply missing a
subsequent use from another CU. Yet then the function ought to become
non-static only there.

Jan
Daniel P. Smith Oct. 10, 2024, 1:16 a.m. UTC | #3
On 10/9/24 11:38, Jan Beulich wrote:
> On 06.10.2024 23:49, Daniel P. Smith wrote:
>> From: Andrew Cooper <andrew.cooper3@citrix.com>
>>
>> Using an interface based on addresses directly, not modules.
>>
>> No functional change.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
>> ---
>>   xen/arch/x86/include/asm/setup.h |  1 +
>>   xen/arch/x86/setup.c             | 19 +++++++++++++------
>>   2 files changed, 14 insertions(+), 6 deletions(-)
>>
>> diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
>> index 3d189521189d..213584b05fb2 100644
>> --- a/xen/arch/x86/include/asm/setup.h
>> +++ b/xen/arch/x86/include/asm/setup.h
>> @@ -36,6 +36,7 @@ extern struct boot_info xen_boot_info;
>>   
>>   unsigned long initial_images_nrpages(nodeid_t node);
>>   void discard_initial_images(void);
>> +void *bootstrap_map_addr(paddr_t start, paddr_t end);
> 
> Nothing is being said about why this function needs a declaration here
> and ...

You are correct, as far as this series is concerned, nothing external 
uses this. Will drop this declaration....

>> --- a/xen/arch/x86/setup.c
>> +++ b/xen/arch/x86/setup.c
>> @@ -437,24 +437,22 @@ static void __init normalise_cpu_order(void)
>>    * Ensure a given physical memory range is present in the bootstrap mappings.
>>    * Use superpage mappings to ensure that pagetable memory needn't be allocated.
>>    */
>> -void *__init bootstrap_map(const module_t *mod)
>> +void *__init bootstrap_map_addr(paddr_t start, paddr_t end)
> 
> ... isn't instead static here. Bugseng folks have put in quite a bit of
> effort to remove such anomalies (which Misra doesn't like) from the code
> base; I don't think we should introduce new ones. I didn't peek ahead
> further than just the next patch, where the function gains a new use,
> but could still be static, so it's possible I'm simply missing a
> subsequent use from another CU. Yet then the function ought to become
> non-static only there.

...and will make this static.

v/r,
dps
diff mbox series

Patch

diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index 3d189521189d..213584b05fb2 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -36,6 +36,7 @@  extern struct boot_info xen_boot_info;
 
 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);
 
 int remove_xen_ranges(struct rangeset *r);
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 161415a8e667..1cc7fcba094b 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -437,24 +437,22 @@  static void __init normalise_cpu_order(void)
  * Ensure a given physical memory range is present in the bootstrap mappings.
  * Use superpage mappings to ensure that pagetable memory needn't be allocated.
  */
-void *__init bootstrap_map(const module_t *mod)
+void *__init bootstrap_map_addr(paddr_t start, paddr_t end)
 {
     static unsigned long __initdata map_cur = BOOTSTRAP_MAP_BASE;
-    uint64_t start, end, mask = (1L << L2_PAGETABLE_SHIFT) - 1;
+    uint64_t mask = (1L << L2_PAGETABLE_SHIFT) - 1;
     void *ret;
 
     if ( system_state != SYS_STATE_early_boot )
-        return mod ? mfn_to_virt(mod->mod_start) : NULL;
+        return end ? maddr_to_virt(start) : NULL;
 
-    if ( !mod )
+    if ( !end )
     {
         destroy_xen_mappings(BOOTSTRAP_MAP_BASE, BOOTSTRAP_MAP_LIMIT);
         map_cur = BOOTSTRAP_MAP_BASE;
         return NULL;
     }
 
-    start = (uint64_t)mod->mod_start << PAGE_SHIFT;
-    end = start + mod->mod_end;
     if ( start >= end )
         return NULL;
 
@@ -470,6 +468,15 @@  void *__init bootstrap_map(const module_t *mod)
     return ret;
 }
 
+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);
+}
+
 static void __init move_memory(
     uint64_t dst, uint64_t src, unsigned int size)
 {