diff mbox series

[v2,1/5] xen/arm: Rename assign_static_memory_11() for consistency

Message ID 20240308015435.4044339-2-xin.wang2@amd.com (mailing list archive)
State New
Headers show
Series DOMCTL-based guest magic regions allocation for dom0less | expand

Commit Message

Henry Wang March 8, 2024, 1:54 a.m. UTC
Currently on Arm there are 4 functions to allocate memory as domain
RAM at boot time for different types of domains:
(1) allocate_memory(): To allocate memory for Dom0less DomUs that
    do not use static memory.
(2) allocate_static_memory(): To allocate memory for Dom0less DomUs
    that use static memory.
(3) allocate_memory_11(): To allocate memory for Dom0.
(4) assign_static_memory_11(): To allocate memory for Dom0less DomUs
    that use static memory and directmapped.

To keep consistency between the names and the in-code comment on top
of the functions, rename assign_static_memory_11() to
allocate_static_memory_11(). No functional change intended.

Signed-off-by: Henry Wang <xin.wang2@amd.com>
---
v2:
- New patch
---
 xen/arch/arm/dom0less-build.c            | 2 +-
 xen/arch/arm/include/asm/static-memory.h | 8 ++++----
 xen/arch/arm/static-memory.c             | 5 +++--
 3 files changed, 8 insertions(+), 7 deletions(-)

Comments

Michal Orzel March 8, 2024, 8:18 a.m. UTC | #1
Hi Henry,

On 08/03/2024 02:54, Henry Wang wrote:
> Currently on Arm there are 4 functions to allocate memory as domain
> RAM at boot time for different types of domains:
> (1) allocate_memory(): To allocate memory for Dom0less DomUs that
>     do not use static memory.
> (2) allocate_static_memory(): To allocate memory for Dom0less DomUs
>     that use static memory.
> (3) allocate_memory_11(): To allocate memory for Dom0.
> (4) assign_static_memory_11(): To allocate memory for Dom0less DomUs
>     that use static memory and directmapped.
> 
> To keep consistency between the names and the in-code comment on top
> of the functions, rename assign_static_memory_11() to
> allocate_static_memory_11(). No functional change intended.
There was a reason for this naming. The function is called assign_ and not allocate_ because
there is no allocation done inside. The function maps specified host regions to guest regions.
Refer:
https://lore.kernel.org/xen-devel/20220214031956.3726764-6-penny.zheng@arm.com/

~Michal
Henry Wang March 8, 2024, 8:22 a.m. UTC | #2
Hi Michal,

On 3/8/2024 4:18 PM, Michal Orzel wrote:
> Hi Henry,
>
> On 08/03/2024 02:54, Henry Wang wrote:
>> Currently on Arm there are 4 functions to allocate memory as domain
>> RAM at boot time for different types of domains:
>> (1) allocate_memory(): To allocate memory for Dom0less DomUs that
>>      do not use static memory.
>> (2) allocate_static_memory(): To allocate memory for Dom0less DomUs
>>      that use static memory.
>> (3) allocate_memory_11(): To allocate memory for Dom0.
>> (4) assign_static_memory_11(): To allocate memory for Dom0less DomUs
>>      that use static memory and directmapped.
>>
>> To keep consistency between the names and the in-code comment on top
>> of the functions, rename assign_static_memory_11() to
>> allocate_static_memory_11(). No functional change intended.
> There was a reason for this naming. The function is called assign_ and not allocate_ because
> there is no allocation done inside. The function maps specified host regions to guest regions.
> Refer:
> https://lore.kernel.org/xen-devel/20220214031956.3726764-6-penny.zheng@arm.com/

Emmm I indeed had the same idea and thought there should be a reason 
about the naming, but at the same time still misguided by the in-code 
comment on top of the function saying "Allocate static memory as RAM for 
one specific domain d." :/

I guess I will either simply drop this patch or correct the above 
in-code comment (which I am not sure if it is worthwhile for an 
independent patch). Anyway, thanks for the info!

Kind regards,
Henry

> ~Michal
diff mbox series

Patch

diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index fb63ec6fd1..1e1c8d83ae 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -806,7 +806,7 @@  static int __init construct_domU(struct domain *d,
     else if ( !is_domain_direct_mapped(d) )
         allocate_static_memory(d, &kinfo, node);
     else
-        assign_static_memory_11(d, &kinfo, node);
+        allocate_static_memory_11(d, &kinfo, node);
 
     rc = process_shm(d, &kinfo, node);
     if ( rc < 0 )
diff --git a/xen/arch/arm/include/asm/static-memory.h b/xen/arch/arm/include/asm/static-memory.h
index 3e3efd70c3..667e6d3804 100644
--- a/xen/arch/arm/include/asm/static-memory.h
+++ b/xen/arch/arm/include/asm/static-memory.h
@@ -9,7 +9,7 @@ 
 
 void allocate_static_memory(struct domain *d, struct kernel_info *kinfo,
                             const struct dt_device_node *node);
-void assign_static_memory_11(struct domain *d, struct kernel_info *kinfo,
+void allocate_static_memory_11(struct domain *d, struct kernel_info *kinfo,
                              const struct dt_device_node *node);
 void init_staticmem_pages(void);
 
@@ -22,9 +22,9 @@  static inline void allocate_static_memory(struct domain *d,
     ASSERT_UNREACHABLE();
 }
 
-static inline void assign_static_memory_11(struct domain *d,
-                                           struct kernel_info *kinfo,
-                                           const struct dt_device_node *node)
+static inline void allocate_static_memory_11(struct domain *d,
+                                             struct kernel_info *kinfo,
+                                             const struct dt_device_node *node)
 {
     ASSERT_UNREACHABLE();
 }
diff --git a/xen/arch/arm/static-memory.c b/xen/arch/arm/static-memory.c
index cffbab7241..20333a7f94 100644
--- a/xen/arch/arm/static-memory.c
+++ b/xen/arch/arm/static-memory.c
@@ -187,8 +187,9 @@  void __init allocate_static_memory(struct domain *d, struct kernel_info *kinfo,
  * The static memory will be directly mapped in the guest(Guest Physical
  * Address == Physical Address).
  */
-void __init assign_static_memory_11(struct domain *d, struct kernel_info *kinfo,
-                                    const struct dt_device_node *node)
+void __init allocate_static_memory_11(struct domain *d,
+                                      struct kernel_info *kinfo,
+                                      const struct dt_device_node *node)
 {
     u32 addr_cells, size_cells, reg_cells;
     unsigned int nr_banks, bank = 0;