Skip to contentSkip to conversation

ARM+RISC-V: BSS handling improvements

PATCH In review Andrew Cooper 4 participants 5 messages Mar 24, 2023 – Apr 16, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM+RISC-V: BSS handling improvements

* Correct comments in arm{32,64}/head.S
* Provide Linker assertions to check the safety of the zeroing loops

---
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Bob Eshleman <[email protected]>
CC: Alistair Francis <[email protected]>
CC: Connor Davis <[email protected]>
CC: Oleksii Kurochko <[email protected]>

Pulled out of the very start of my work to try and unify the handling of xen_phys_addr across architectures.

---
 xen/arch/arm/arm32/head.S | 2 +-
 xen/arch/arm/arm64/head.S | 2 +-
 xen/arch/arm/xen.lds.S    | 2 ++
 xen/arch/riscv/xen.lds.S  | 4 ++++
 4 files changed, 8 insertions(+), 2 deletions(-)
xen/arch/arm/arm32/head.S +1 -1
index df51550baa8a..f9f7be9588b1 100644
@@ -301,7 +301,7 @@ ENDPROC(check_cpu_mode)
 zero_bss:
         PRINT("- Zero BSS -\r\n")
         mov_w r0, __bss_start        /* r0 := vaddr(__bss_start) */
-        mov_w r1, __bss_end          /* r1 := vaddr(__bss_start) */
+        mov_w r1, __bss_end          /* r1 := vaddr(__bss_end)   */
 
         mov   r2, #0
 1:      str   r2, [r0], #4
xen/arch/arm/arm64/head.S +1 -1
index 4a3f87117c83..8a4dd64c99ad 100644
@@ -437,7 +437,7 @@ zero_bss:
 
         PRINT("- Zero BSS -\r\n")
         ldr   x0, =__bss_start       /* x0 := vaddr(__bss_start) */
-        ldr   x1, =__bss_end         /* x1 := vaddr(__bss_start) */
+        ldr   x1, =__bss_end         /* x1 := vaddr(__bss_end)   */
 
 1:      str   xzr, [x0], #8
         cmp   x0, x1
xen/arch/arm/xen.lds.S +2 -0
index 1b392345bc3b..6ca3caefe607 100644
@@ -240,3 +240,5 @@ ASSERT(_idmap_end - _idmap_start <= PAGE_SIZE, "Identity mapped code is larger t
  */
 ASSERT(IS_ALIGNED(__init_begin,     4), "__init_begin is misaligned")
 ASSERT(IS_ALIGNED(__init_end,       4), "__init_end is misaligned")
+ASSERT(IS_ALIGNED(__bss_start,      POINTER_ALIGN), "__bss_start is misaligned")
+ASSERT(IS_ALIGNED(__bss_end,        POINTER_ALIGN), "__bss_end is misaligned")
xen/arch/riscv/xen.lds.S +4 -0
index ca57cce75cba..2ed70eccc62a 100644
@@ -1,3 +1,4 @@
+#include <xen/lib.h>
 #include <xen/xen.lds.h>
 
 #undef ENTRY
@@ -156,3 +157,6 @@ SECTIONS
 
     ELF_DETAILS_SECTIONS
 }
+
+ASSERT(IS_ALIGNED(__bss_start,      POINTER_ALIGN), "__bss_start is misaligned")
+ASSERT(IS_ALIGNED(__bss_end,        POINTER_ALIGN), "__bss_end is misaligned")
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#3 lore raw
In reply to Andrew Cooper
Quoted 5 lines · Andrew Cooper

* Correct comments in arm{32,64}/head.S
* Provide Linker assertions to check the safety of the zeroing loops

Alistair

Quoted 75 lines

---
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Bob Eshleman <[email protected]>
CC: Alistair Francis <[email protected]>
CC: Connor Davis <[email protected]>
CC: Oleksii Kurochko <[email protected]>

Pulled out of the very start of my work to try and unify the handling of xen_phys_addr across architectures.

---
 xen/arch/arm/arm32/head.S | 2 +-
 xen/arch/arm/arm64/head.S | 2 +-
 xen/arch/arm/xen.lds.S    | 2 ++
 xen/arch/riscv/xen.lds.S  | 4 ++++
 4 files changed, 8 insertions(+), 2 deletions(-)
xen/arch/arm/arm32/head.S +1 -1
index df51550baa8a..f9f7be9588b1 100644
@@ -301,7 +301,7 @@ ENDPROC(check_cpu_mode)
 zero_bss:
         PRINT("- Zero BSS -\r\n")
         mov_w r0, __bss_start        /* r0 := vaddr(__bss_start) */
-        mov_w r1, __bss_end          /* r1 := vaddr(__bss_start) */
+        mov_w r1, __bss_end          /* r1 := vaddr(__bss_end)   */
 
         mov   r2, #0
 1:      str   r2, [r0], #4
xen/arch/arm/arm64/head.S +1 -1
index 4a3f87117c83..8a4dd64c99ad 100644
@@ -437,7 +437,7 @@ zero_bss:
 
         PRINT("- Zero BSS -\r\n")
         ldr   x0, =__bss_start       /* x0 := vaddr(__bss_start) */
-        ldr   x1, =__bss_end         /* x1 := vaddr(__bss_start) */
+        ldr   x1, =__bss_end         /* x1 := vaddr(__bss_end)   */
 
 1:      str   xzr, [x0], #8
         cmp   x0, x1
xen/arch/arm/xen.lds.S +2 -0
index 1b392345bc3b..6ca3caefe607 100644
@@ -240,3 +240,5 @@ ASSERT(_idmap_end - _idmap_start <= PAGE_SIZE, "Identity mapped code is larger t
  */
 ASSERT(IS_ALIGNED(__init_begin,     4), "__init_begin is misaligned")
 ASSERT(IS_ALIGNED(__init_end,       4), "__init_end is misaligned")
+ASSERT(IS_ALIGNED(__bss_start,      POINTER_ALIGN), "__bss_start is misaligned")
+ASSERT(IS_ALIGNED(__bss_end,        POINTER_ALIGN), "__bss_end is misaligned")
xen/arch/riscv/xen.lds.S +4 -1
index ca57cce75cba..2ed70eccc62a 100644
@@ -1,3 +1,4 @@
+#include <xen/lib.h>
 #include <xen/xen.lds.h>
 
 #undef ENTRY
@@ -156,3 +157,6 @@ SECTIONS
 
     ELF_DETAILS_SECTIONS
 }
+
+ASSERT(IS_ALIGNED(__bss_start,      POINTER_ALIGN), "__bss_start is misaligned")
+ASSERT(IS_ALIGNED(__bss_end,        POINTER_ALIGN), "__bss_end is misaligned")
--

2.30.2

#4 lore raw
In reply to Andrew Cooper

Hi,

Quoted 4 lines · Andrew Cooper

* Correct comments in arm{32,64}/head.S
* Provide Linker assertions to check the safety of the zeroing loops

It is now fully acked. So I have committed the patch.

Cheers,

Quoted 71 lines

---
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Bob Eshleman <[email protected]>
CC: Alistair Francis <[email protected]>
CC: Connor Davis <[email protected]>
CC: Oleksii Kurochko <[email protected]>

Pulled out of the very start of my work to try and unify the handling of xen_phys_addr across architectures.

---
  xen/arch/arm/arm32/head.S | 2 +-
  xen/arch/arm/arm64/head.S | 2 +-
  xen/arch/arm/xen.lds.S    | 2 ++
  xen/arch/riscv/xen.lds.S  | 4 ++++
  4 files changed, 8 insertions(+), 2 deletions(-)
xen/arch/arm/arm32/head.S +1 -1
index df51550baa8a..f9f7be9588b1 100644
@@ -301,7 +301,7 @@ ENDPROC(check_cpu_mode)
  zero_bss:
          PRINT("- Zero BSS -\r\n")
          mov_w r0, __bss_start        /* r0 := vaddr(__bss_start) */
-        mov_w r1, __bss_end          /* r1 := vaddr(__bss_start) */
+        mov_w r1, __bss_end          /* r1 := vaddr(__bss_end)   */
 
          mov   r2, #0
  1:      str   r2, [r0], #4
xen/arch/arm/arm64/head.S +1 -1
index 4a3f87117c83..8a4dd64c99ad 100644
@@ -437,7 +437,7 @@ zero_bss:
 
          PRINT("- Zero BSS -\r\n")
          ldr   x0, =__bss_start       /* x0 := vaddr(__bss_start) */
-        ldr   x1, =__bss_end         /* x1 := vaddr(__bss_start) */
+        ldr   x1, =__bss_end         /* x1 := vaddr(__bss_end)   */
 
  1:      str   xzr, [x0], #8
          cmp   x0, x1
xen/arch/arm/xen.lds.S +2 -0
index 1b392345bc3b..6ca3caefe607 100644
@@ -240,3 +240,5 @@ ASSERT(_idmap_end - _idmap_start <= PAGE_SIZE, "Identity mapped code is larger t
   */
  ASSERT(IS_ALIGNED(__init_begin,     4), "__init_begin is misaligned")
  ASSERT(IS_ALIGNED(__init_end,       4), "__init_end is misaligned")
+ASSERT(IS_ALIGNED(__bss_start,      POINTER_ALIGN), "__bss_start is misaligned")
+ASSERT(IS_ALIGNED(__bss_end,        POINTER_ALIGN), "__bss_end is misaligned")
xen/arch/riscv/xen.lds.S +4 -0
index ca57cce75cba..2ed70eccc62a 100644
@@ -1,3 +1,4 @@
+#include <xen/lib.h>
  #include <xen/xen.lds.h>
 
  #undef ENTRY
@@ -156,3 +157,6 @@ SECTIONS
 
      ELF_DETAILS_SECTIONS
  }
+
+ASSERT(IS_ALIGNED(__bss_start,      POINTER_ALIGN), "__bss_start is misaligned")
+ASSERT(IS_ALIGNED(__bss_end,        POINTER_ALIGN), "__bss_end is misaligned")
Signature · 1 line
Julien Grall