ARM U-Boot BSS zeroing
PATCH 1/1 ARM U-Boot BSS zeroing
The import into the collaborative branch discarded the call to get_real_bss_start before starting the BSS zeroing operation.
While get_real_bss_start might have been a bit of an ugly hack, simply discarding it means that we now end up doing unaligned STR operations, and any platform with MMU disabled fails to boot.
The attached patch prepends a bytewise zeroing loop until word-aligned, and then continue as before.
/
Leif
=== modified file 'grub-core/kern/arm/uboot/startup.S'
kern/arm/uboot/startup.S +7 -1
@@ -100,7 +100,13 @@ @ Since we _are_ the C run-time, we need to manually zero the BSS @ region before continuing ldr r0, =EXT_C(__bss_start) @ zero from here - ldr r1, =EXT_C(_end) @ to here + @ If unaligned, bytewise zero until base address aligned. + mov r1, #0 +1: tst r0, #3 + beq 2f + strb r1, [r0], #1 + b 1b +2: ldr r1, =EXT_C(_end) @ to here mov r2, #0 1: str r2, [r0], #4 cmp r0, r1
Could you request savannah membership so you have commit rights to this branch?
Will you be at LinuxTag?
Quoted 19 lines · Leif Lindholm
The import into the collaborative branch discarded the call to
get_real_bss_startbefore starting the BSS zeroing operation.While
get_real_bss_startmight have been a bit of an ugly hack, simply discarding it means that we now end up doing unaligned STR operations, and any platform with MMU disabled fails to boot.The attached patch prepends a bytewise zeroing loop until word-aligned, and then continue as before.
/
Leif_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 21 lines · Leif Lindholm
The import into the collaborative branch discarded the call to
get_real_bss_startbefore starting the BSS zeroing operation.While
get_real_bss_startmight have been a bit of an ugly hack, simply discarding it means that we now end up doing unaligned STR operations, and any platform with MMU disabled fails to boot.The attached patch prepends a bytewise zeroing loop until word-aligned, and then continue as before.
/
Leif=== modified file '
grub-core/kern/arm/uboot/startup.S'kern/arm/uboot/startup.S +0
-1@@ -100,7 +100,13 @@ @ Since we _are_ the C run-time, we need to manually zero the BSS @ region before continuing ldr r0, =EXT_C(__bss_start) @ zero from here - ldr r1, =EXT_C(_end) @ to here
kern/arm/uboot/startup.S line 112
Quoted 10 lines
kern/arm/uboot/startup.S +7
-0+ @ If unaligned, bytewise zero until base address aligned. + mov r1, #0 +1: tst r0, #3 + beq 2f + strb r1, [r0], #1 + b 1b +2: ldr r1, =EXT_C(_end) @ to here mov r2, #0 1: str r2, [r0], #4 cmp r0, r1
What if I have a 1 byte BSS aligned at 1 byte? You would zero 3 bytes and overshoot _end and then what happens after the cmp in the last line?
MfG
Goswin
Quoted 28 lines · Goswin von Brederlow
Quoted 26 lines · Leif Lindholm
The import into the collaborative branch discarded the call to
get_real_bss_startbefore starting the BSS zeroing operation.While
get_real_bss_startmight have been a bit of an ugly hack, simply discarding it means that we now end up doing unaligned STR operations, and any platform with MMU disabled fails to boot.The attached patch prepends a bytewise zeroing loop until word-aligned, and then continue as before.
/
Leif=== modified file '
grub-core/kern/arm/uboot/startup.S'kern/arm/uboot/startup.S 2013-05-13 14:59:43 +0000 renamed from kern/arm/uboot/startup.S 2013-05-03 13:07:39 +0000 +5
-1@@ -100,7 +100,13 @@ @ Since we _are_ the C run-time, we need to manually zero the BSS @ region before continuing ldr r0, =EXT_C(__bss_start) @ zero from here - ldr r1, =EXT_C(_end) @ to here + @ If unaligned, bytewise zero until base address aligned. + mov r1, #0 +1: tst r0, #3 + beq 2f + strb r1, [r0], #1
Quoted 9 lines
kern/arm/uboot/startup.S 2013-05-13 14:59:43 +0000 line 112
Quoted 5 lines
kern/arm/uboot/startup.S 2013-05-13 14:59:43 +0000 renamed from kern/arm/uboot/startup.S 2013-05-03 13:07:39 +0000 +2
-0+ b 1b +2: ldr r1, =EXT_C(_end) @ to here mov r2, #0 1: str r2, [r0], #4 cmp r0, r1What if I have a 1 byte BSS aligned at 1 byte? You would zero 3 bytes and overshoot
_endand then what happens after the cmp in the last line?
Abaolutely irrelevant. our BSS isn't that small
Quoted 7 lines
MfG
Goswin_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel