]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: Skip initializing the BSS section when it is empty
authorAyan Kumar Halder <ayan.kumar.halder@amd.com>
Mon, 28 Oct 2024 12:45:42 +0000 (12:45 +0000)
committerJulien Grall <jgrall@amazon.com>
Fri, 1 Nov 2024 13:59:23 +0000 (13:59 +0000)
If the BSS section is empty, then the function should return.
If one does not check whether the BSS section is empty or not, then there is a
risk of writing 0s outside of BSS section (which may contain critical data).

Fixes: dac84b66cc9a ("xen: arm64: initial build + config changes, start of day code")
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
xen/arch/arm/arm32/head.S
xen/arch/arm/arm64/head.S

index a96d5d35038f66a96e0ae810fc88b451f1062ddc..4ff5c220bccb7858250ea17cd1a200d808663c0b 100644 (file)
@@ -185,12 +185,15 @@ zero_bss:
         PRINT("- Zero BSS -\r\n")
         mov_w r0, __bss_start        /* r0 := vaddr(__bss_start) */
         mov_w r1, __bss_end          /* r1 := vaddr(__bss_end)   */
+        cmp   r1, r0
+        beq   skip_bss
 
         mov   r2, #0
 1:      str   r2, [r0], #4
         cmp   r0, r1
         blo   1b
 
+skip_bss:
         mov   pc, lr
 ENDPROC(zero_bss)
 
index 14c3720d80f8d910af01f6dfb8c9a3ac1ec00705..72c7b2449829a94bd34c4b47b5807e349e5c2070 100644 (file)
@@ -346,6 +346,8 @@ FUNC_LOCAL(zero_bss)
         PRINT("- Zero BSS -\r\n")
         ldr   x0, =__bss_start       /* x0 := vaddr(__bss_start) */
         ldr   x1, =__bss_end         /* x1 := vaddr(__bss_end)   */
+        cmp   x1, x0
+        beq   skip_bss
 
 1:      str   xzr, [x0], #8
         cmp   x0, x1