[PATCH v7 08/11] Arm32: use new-style entry annotations for MMU code

Jan Beulich posted 11 patches 1 month, 3 weeks ago
[PATCH v7 08/11] Arm32: use new-style entry annotations for MMU code
Posted by Jan Beulich 1 month, 3 weeks ago
Locally override SYM_PUSH_SECTION() to retain the intended section
association.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v7: New.

--- a/xen/arch/arm/arm32/mmu/head.S
+++ b/xen/arch/arm/arm32/mmu/head.S
@@ -160,6 +160,13 @@
 .endm
 
 .section .text.idmap, "ax", %progbits
+/*
+ * Code below wants to all live in the section established above.  Annotations
+ * from xen/linkage.h therefore may not switch sections (honoring
+ * CONFIG_CC_SPLIT_SECTIONS).  Override the respective macro.
+ */
+#undef SYM_PUSH_SECTION
+#define SYM_PUSH_SECTION(name, attr)
 
 /*
  * Rebuild the boot pagetable's first-level entries. The structure
@@ -174,7 +181,7 @@
  *
  * Clobbers r0 - r5
  */
-create_page_tables:
+FUNC_LOCAL(create_page_tables)
         /* Prepare the page-tables for mapping Xen */
         mov_w r0, XEN_VIRT_START
 
@@ -263,7 +270,7 @@ use_temporary_mapping:
 
         mov   r12, #1                /* r12 := temporary mapping created */
         mov   pc, lr
-ENDPROC(create_page_tables)
+END(create_page_tables)
 
 /*
  * Turn on the Data Cache and the MMU. The function will return
@@ -276,7 +283,7 @@ ENDPROC(create_page_tables)
  *
  * Clobbers r0 - r5
  */
-enable_mmu:
+FUNC_LOCAL(enable_mmu)
         PRINT("- Turning on paging -\r\n")
 
         /*
@@ -346,7 +353,7 @@ enable_mmu:
         teq   r12, #0
         beq   remove_identity_mapping
         b     remove_temporary_mapping
-ENDPROC(enable_mmu)
+END(enable_mmu)
 
 /*
  * Switch to the runtime mapping. The logic depends on whether the
@@ -366,7 +373,7 @@ ENDPROC(enable_mmu)
  *
  * Clobbers r0 - r4
  */
-switch_to_runtime_mapping:
+FUNC_LOCAL(switch_to_runtime_mapping)
         /*
          * Jump to the runtime mapping if the virt and phys are not
          * clashing
@@ -411,7 +418,7 @@ ready_to_switch:
         PRINT_ID("- Jumping to runtime address -\r\n")
 
         mov   pc, lr
-ENDPROC(switch_to_runtime_mapping)
+END(switch_to_runtime_mapping)
 
 /*
  * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
@@ -428,7 +435,7 @@ ENDPROC(switch_to_runtime_mapping)
  *
  * Clobbers r0 - r6
  */
-ENTRY(enable_secondary_cpu_mm)
+FUNC(enable_secondary_cpu_mm)
         mov   r6, lr
 
         bl    create_page_tables
@@ -456,7 +463,7 @@ ENTRY(enable_secondary_cpu_mm)
 
         /* Return to the virtual address requested by the caller. */
         mov   pc, r6
-ENDPROC(enable_secondary_cpu_mm)
+END(enable_secondary_cpu_mm)
 
 /*
  * Enable mm (turn on the data cache and the MMU) for the boot CPU.
@@ -474,7 +481,7 @@ ENDPROC(enable_secondary_cpu_mm)
  *
  * Clobbers r0 - r6
  */
-ENTRY(enable_boot_cpu_mm)
+FUNC(enable_boot_cpu_mm)
         mov   r6, lr
 
 #ifdef CONFIG_EARLY_PRINTK
@@ -491,7 +498,7 @@ ENTRY(enable_boot_cpu_mm)
         /* Address in the runtime mapping to jump to after the MMU is enabled */
         mov   lr, r6
         b     enable_mmu
-ENDPROC(enable_boot_cpu_mm)
+END(enable_boot_cpu_mm)
 
 /*
  * Remove the 1:1 map from the page-tables. It is not easy to keep track
@@ -503,7 +510,7 @@ ENDPROC(enable_boot_cpu_mm)
  *
  * Clobbers r0 - r3
  */
-remove_identity_mapping:
+FUNC_LOCAL(remove_identity_mapping)
         PRINT("- Removing the identity mapping -\r\n")
 
         /* r2:r3 := invalid page-table entry */
@@ -518,14 +525,14 @@ remove_identity_mapping:
 
         flush_xen_tlb_local r0
         mov   pc, lr
-ENDPROC(remove_identity_mapping)
+END(remove_identity_mapping)
 
 /*
  * Remove the temporary mapping of Xen starting at TEMPORARY_XEN_VIRT_START.
  *
  * Clobbers r0 - r3
  */
-remove_temporary_mapping:
+FUNC_LOCAL(remove_temporary_mapping)
         PRINT("- Removing the temporary mapping -\r\n")
 
         /* r2:r3 := invalid page-table entry */
@@ -541,13 +548,14 @@ remove_temporary_mapping:
         flush_xen_tlb_local r0
 
         mov  pc, lr
-ENDPROC(remove_temporary_mapping)
+END(remove_temporary_mapping)
 
 /* Fail-stop */
-fail:   PRINT("- Boot failed -\r\n")
+FUNC_LOCAL(fail)
+        PRINT("- Boot failed -\r\n")
 1:      wfe
         b     1b
-ENDPROC(fail)
+END(fail)
 
 /*
  * Switch TTBR
@@ -555,7 +563,7 @@ ENDPROC(fail)
  *
  * TODO: This code does not comply with break-before-make.
  */
-ENTRY(switch_ttbr)
+FUNC(switch_ttbr)
         dsb                            /* Ensure the flushes happen before
                                         * continuing */
         isb                            /* Ensure synchronization with previous
@@ -579,4 +587,4 @@ ENTRY(switch_ttbr)
         isb
 
         mov pc, lr
-ENDPROC(switch_ttbr)
+END(switch_ttbr)
Re: [PATCH v7 08/11] Arm32: use new-style entry annotations for MMU code
Posted by Jan Beulich 1 month, 3 weeks ago
On 01.10.2024 17:16, Jan Beulich wrote:
> Locally override SYM_PUSH_SECTION() to retain the intended section
> association.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> v7: New.

I'm sorry, I failed to Cc maintainers here.

Jan

> --- a/xen/arch/arm/arm32/mmu/head.S
> +++ b/xen/arch/arm/arm32/mmu/head.S
> @@ -160,6 +160,13 @@
>  .endm
>  
>  .section .text.idmap, "ax", %progbits
> +/*
> + * Code below wants to all live in the section established above.  Annotations
> + * from xen/linkage.h therefore may not switch sections (honoring
> + * CONFIG_CC_SPLIT_SECTIONS).  Override the respective macro.
> + */
> +#undef SYM_PUSH_SECTION
> +#define SYM_PUSH_SECTION(name, attr)
>  
>  /*
>   * Rebuild the boot pagetable's first-level entries. The structure
> @@ -174,7 +181,7 @@
>   *
>   * Clobbers r0 - r5
>   */
> -create_page_tables:
> +FUNC_LOCAL(create_page_tables)
>          /* Prepare the page-tables for mapping Xen */
>          mov_w r0, XEN_VIRT_START
>  
> @@ -263,7 +270,7 @@ use_temporary_mapping:
>  
>          mov   r12, #1                /* r12 := temporary mapping created */
>          mov   pc, lr
> -ENDPROC(create_page_tables)
> +END(create_page_tables)
>  
>  /*
>   * Turn on the Data Cache and the MMU. The function will return
> @@ -276,7 +283,7 @@ ENDPROC(create_page_tables)
>   *
>   * Clobbers r0 - r5
>   */
> -enable_mmu:
> +FUNC_LOCAL(enable_mmu)
>          PRINT("- Turning on paging -\r\n")
>  
>          /*
> @@ -346,7 +353,7 @@ enable_mmu:
>          teq   r12, #0
>          beq   remove_identity_mapping
>          b     remove_temporary_mapping
> -ENDPROC(enable_mmu)
> +END(enable_mmu)
>  
>  /*
>   * Switch to the runtime mapping. The logic depends on whether the
> @@ -366,7 +373,7 @@ ENDPROC(enable_mmu)
>   *
>   * Clobbers r0 - r4
>   */
> -switch_to_runtime_mapping:
> +FUNC_LOCAL(switch_to_runtime_mapping)
>          /*
>           * Jump to the runtime mapping if the virt and phys are not
>           * clashing
> @@ -411,7 +418,7 @@ ready_to_switch:
>          PRINT_ID("- Jumping to runtime address -\r\n")
>  
>          mov   pc, lr
> -ENDPROC(switch_to_runtime_mapping)
> +END(switch_to_runtime_mapping)
>  
>  /*
>   * Enable mm (turn on the data cache and the MMU) for secondary CPUs.
> @@ -428,7 +435,7 @@ ENDPROC(switch_to_runtime_mapping)
>   *
>   * Clobbers r0 - r6
>   */
> -ENTRY(enable_secondary_cpu_mm)
> +FUNC(enable_secondary_cpu_mm)
>          mov   r6, lr
>  
>          bl    create_page_tables
> @@ -456,7 +463,7 @@ ENTRY(enable_secondary_cpu_mm)
>  
>          /* Return to the virtual address requested by the caller. */
>          mov   pc, r6
> -ENDPROC(enable_secondary_cpu_mm)
> +END(enable_secondary_cpu_mm)
>  
>  /*
>   * Enable mm (turn on the data cache and the MMU) for the boot CPU.
> @@ -474,7 +481,7 @@ ENDPROC(enable_secondary_cpu_mm)
>   *
>   * Clobbers r0 - r6
>   */
> -ENTRY(enable_boot_cpu_mm)
> +FUNC(enable_boot_cpu_mm)
>          mov   r6, lr
>  
>  #ifdef CONFIG_EARLY_PRINTK
> @@ -491,7 +498,7 @@ ENTRY(enable_boot_cpu_mm)
>          /* Address in the runtime mapping to jump to after the MMU is enabled */
>          mov   lr, r6
>          b     enable_mmu
> -ENDPROC(enable_boot_cpu_mm)
> +END(enable_boot_cpu_mm)
>  
>  /*
>   * Remove the 1:1 map from the page-tables. It is not easy to keep track
> @@ -503,7 +510,7 @@ ENDPROC(enable_boot_cpu_mm)
>   *
>   * Clobbers r0 - r3
>   */
> -remove_identity_mapping:
> +FUNC_LOCAL(remove_identity_mapping)
>          PRINT("- Removing the identity mapping -\r\n")
>  
>          /* r2:r3 := invalid page-table entry */
> @@ -518,14 +525,14 @@ remove_identity_mapping:
>  
>          flush_xen_tlb_local r0
>          mov   pc, lr
> -ENDPROC(remove_identity_mapping)
> +END(remove_identity_mapping)
>  
>  /*
>   * Remove the temporary mapping of Xen starting at TEMPORARY_XEN_VIRT_START.
>   *
>   * Clobbers r0 - r3
>   */
> -remove_temporary_mapping:
> +FUNC_LOCAL(remove_temporary_mapping)
>          PRINT("- Removing the temporary mapping -\r\n")
>  
>          /* r2:r3 := invalid page-table entry */
> @@ -541,13 +548,14 @@ remove_temporary_mapping:
>          flush_xen_tlb_local r0
>  
>          mov  pc, lr
> -ENDPROC(remove_temporary_mapping)
> +END(remove_temporary_mapping)
>  
>  /* Fail-stop */
> -fail:   PRINT("- Boot failed -\r\n")
> +FUNC_LOCAL(fail)
> +        PRINT("- Boot failed -\r\n")
>  1:      wfe
>          b     1b
> -ENDPROC(fail)
> +END(fail)
>  
>  /*
>   * Switch TTBR
> @@ -555,7 +563,7 @@ ENDPROC(fail)
>   *
>   * TODO: This code does not comply with break-before-make.
>   */
> -ENTRY(switch_ttbr)
> +FUNC(switch_ttbr)
>          dsb                            /* Ensure the flushes happen before
>                                          * continuing */
>          isb                            /* Ensure synchronization with previous
> @@ -579,4 +587,4 @@ ENTRY(switch_ttbr)
>          isb
>  
>          mov pc, lr
> -ENDPROC(switch_ttbr)
> +END(switch_ttbr)
>