[PATCH 2/5] arm/setup: Move MMU specific extern declarations to mmu/mm.h

Luca Fancellu posted 5 patches 2 months, 2 weeks ago
There is a newer version of this series
[PATCH 2/5] arm/setup: Move MMU specific extern declarations to mmu/mm.h
Posted by Luca Fancellu 2 months, 2 weeks ago
Move some extern declarations related to MMU structures and define
from asm/setup.h to asm/mm.h, in order to increase encapsulation and
allow the MPU part to build, since it has no clue about them.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/arch/arm/include/asm/mmu/mm.h | 11 +++++++++++
 xen/arch/arm/include/asm/setup.h  | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/include/asm/mmu/mm.h b/xen/arch/arm/include/asm/mmu/mm.h
index c5e03a66bf9e..69b72d671012 100644
--- a/xen/arch/arm/include/asm/mmu/mm.h
+++ b/xen/arch/arm/include/asm/mmu/mm.h
@@ -12,6 +12,17 @@ extern vaddr_t directmap_virt_start;
 extern unsigned long directmap_base_pdx;
 #endif
 
+extern lpae_t boot_pgtable[XEN_PT_LPAE_ENTRIES];
+
+#ifdef CONFIG_ARM_64
+extern lpae_t boot_first[XEN_PT_LPAE_ENTRIES];
+extern lpae_t boot_first_id[XEN_PT_LPAE_ENTRIES];
+#endif
+extern lpae_t boot_second[XEN_PT_LPAE_ENTRIES];
+extern lpae_t boot_second_id[XEN_PT_LPAE_ENTRIES];
+extern lpae_t boot_third[XEN_PT_LPAE_ENTRIES * XEN_NR_ENTRIES(2)];
+extern lpae_t boot_third_id[XEN_PT_LPAE_ENTRIES];
+
 #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
 
 /*
diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h
index 64c227d171fc..3f5c6cf9a08b 100644
--- a/xen/arch/arm/include/asm/setup.h
+++ b/xen/arch/arm/include/asm/setup.h
@@ -65,17 +65,6 @@ int map_irq_to_domain(struct domain *d, unsigned int irq,
 int map_range_to_domain(const struct dt_device_node *dev,
                         uint64_t addr, uint64_t len, void *data);
 
-extern lpae_t boot_pgtable[XEN_PT_LPAE_ENTRIES];
-
-#ifdef CONFIG_ARM_64
-extern lpae_t boot_first[XEN_PT_LPAE_ENTRIES];
-extern lpae_t boot_first_id[XEN_PT_LPAE_ENTRIES];
-#endif
-extern lpae_t boot_second[XEN_PT_LPAE_ENTRIES];
-extern lpae_t boot_second_id[XEN_PT_LPAE_ENTRIES];
-extern lpae_t boot_third[XEN_PT_LPAE_ENTRIES * XEN_NR_ENTRIES(2)];
-extern lpae_t boot_third_id[XEN_PT_LPAE_ENTRIES];
-
 /* Find where Xen will be residing at runtime and return a PT entry */
 lpae_t pte_of_xenaddr(vaddr_t va);
 
-- 
2.34.1
Re: [PATCH 2/5] arm/setup: Move MMU specific extern declarations to mmu/mm.h
Posted by Julien Grall 2 months, 1 week ago
Hi Luca,

On 15/11/2024 10:50, Luca Fancellu wrote:
> Move some extern declarations related to MMU structures and define
> from asm/setup.h to asm/mm.h, in order to increase encapsulation and

You are moving them to asm/mmu/mm.h. But I think I would prefer if they 
are moved to asm/mmu/setup.h because boot_* are not supposed to be used 
outside of boot. So it is clearer if they are still defined in a setup.h.

> allow the MPU part to build, since it has no clue about them.
> 
> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
> ---
>   xen/arch/arm/include/asm/mmu/mm.h | 11 +++++++++++
>   xen/arch/arm/include/asm/setup.h  | 11 -----------
>   2 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/xen/arch/arm/include/asm/mmu/mm.h b/xen/arch/arm/include/asm/mmu/mm.h
> index c5e03a66bf9e..69b72d671012 100644
> --- a/xen/arch/arm/include/asm/mmu/mm.h
> +++ b/xen/arch/arm/include/asm/mmu/mm.h
> @@ -12,6 +12,17 @@ extern vaddr_t directmap_virt_start;
>   extern unsigned long directmap_base_pdx;
>   #endif
>   
> +extern lpae_t boot_pgtable[XEN_PT_LPAE_ENTRIES];
> +
> +#ifdef CONFIG_ARM_64
> +extern lpae_t boot_first[XEN_PT_LPAE_ENTRIES];
> +extern lpae_t boot_first_id[XEN_PT_LPAE_ENTRIES];
> +#endif
> +extern lpae_t boot_second[XEN_PT_LPAE_ENTRIES];
> +extern lpae_t boot_second_id[XEN_PT_LPAE_ENTRIES];
> +extern lpae_t boot_third[XEN_PT_LPAE_ENTRIES * XEN_NR_ENTRIES(2)];
> +extern lpae_t boot_third_id[XEN_PT_LPAE_ENTRIES];
> +
>   #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START)
>   
>   /*
> diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h
> index 64c227d171fc..3f5c6cf9a08b 100644
> --- a/xen/arch/arm/include/asm/setup.h
> +++ b/xen/arch/arm/include/asm/setup.h
> @@ -65,17 +65,6 @@ int map_irq_to_domain(struct domain *d, unsigned int irq,
>   int map_range_to_domain(const struct dt_device_node *dev,
>                           uint64_t addr, uint64_t len, void *data);
>   
> -extern lpae_t boot_pgtable[XEN_PT_LPAE_ENTRIES];
> -
> -#ifdef CONFIG_ARM_64
> -extern lpae_t boot_first[XEN_PT_LPAE_ENTRIES];
> -extern lpae_t boot_first_id[XEN_PT_LPAE_ENTRIES];
> -#endif
> -extern lpae_t boot_second[XEN_PT_LPAE_ENTRIES];
> -extern lpae_t boot_second_id[XEN_PT_LPAE_ENTRIES];
> -extern lpae_t boot_third[XEN_PT_LPAE_ENTRIES * XEN_NR_ENTRIES(2)];
> -extern lpae_t boot_third_id[XEN_PT_LPAE_ENTRIES];
> -
>   /* Find where Xen will be residing at runtime and return a PT entry */
>   lpae_t pte_of_xenaddr(vaddr_t va);

Shouldn't we move this function as well?

Cheers,

-- 
Julien Grall
Re: [PATCH 2/5] arm/setup: Move MMU specific extern declarations to mmu/mm.h
Posted by Luca Fancellu 2 months, 1 week ago
Hi Julien,

> On 17 Nov 2024, at 17:46, Julien Grall <julien@xen.org> wrote:
> 
> Hi Luca,
> 
> On 15/11/2024 10:50, Luca Fancellu wrote:
>> Move some extern declarations related to MMU structures and define
>> from asm/setup.h to asm/mm.h, in order to increase encapsulation and
> 
> You are moving them to asm/mmu/mm.h. But I think I would prefer if they are moved to asm/mmu/setup.h because boot_* are not supposed to be used outside of boot. So it is clearer if they are still defined in a setup.h.

Sure I’ll move them to arm/mmu/setup.h

>> 
>> -
>>  /* Find where Xen will be residing at runtime and return a PT entry */
>>  lpae_t pte_of_xenaddr(vaddr_t va);
> 
> Shouldn't we move this function as well?

This one was not problematic, but I can move this one as well.

Cheers,
Luca