[U-Boot] [PATCH] armv7: Fix to mistake clean the memory space

Zhong Hongbo bocui107 at gmail.com
Fri Jul 6 13:30:17 CEST 2012


Hi Andreas,

On 07/05/2012 11:38 PM, Andreas Bießmann wrote:
> Dear Zhong Hongbo,
> 
> this is arm related and should therefore apply to all the different
> arch/arm/cpu/*/start.S (as long as they have SPL support).
Ok, I will do it. Thanks for your advise.

> 
> On 05.07.2012 16:35, Zhong Hongbo wrote:
>> From: Zhong Hongbo <bocui107 at gmail.com>
>>
>> In currently, when __bss_start is equal to __bss_end__,
>> The bss loop will clear all the things in memory space.
> 
> I ask myself why there is no bss at all. Have you just initialized data
> in your spl code?

Yes
> 
>>
>> But just only when __bss_end__ greater than __bss_start__,
>> we do the clear bss section operation.
>>
>> Signed-off-by: Hongbo Zhong <bocui107 at gmail.com>
>> ---
>>  arch/arm/cpu/armv7/start.S |    9 ++++++---
>>  1 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
>> index 22a3ced..2e583ee 100644
>> --- a/arch/arm/cpu/armv7/start.S
>> +++ b/arch/arm/cpu/armv7/start.S
>> @@ -259,10 +259,13 @@ clear_bss:
>>  #endif
>>  	mov	r2, #0x00000000		/* clear			    */
>>  
>> -clbss_l:str	r2, [r0]		/* clear loop...		    */
>> +clbss_l:
>> +	cmp	r1, r0
>> +	bls	clbss_end
>> +	str	r2, [r0]		/* clear loop...		    */
>>  	add	r0, r0, #4
>> -	cmp	r0, r1
>> -	bne	clbss_l
>> +	b	clbss_l
>> +clbss_end:
> 
> Looks sane, I maybe had checked before clbss_l, jumped over clear loop
> if r0 and r1 equal (to emphasize the fact that this is a check for entry
> correctness) and wouldn't change the loop at all. To be more precise we
> could also check if end is after start.
I check the starts of arm92ejs, I found the issue display in other arm
platform. As following:

commit 8f1da53508c78789ebeea98a92a3f55c3f84dc5d
Author: Christian Riesch <christian.riesch at omicron.at>
Date:   Wed Nov 30 22:27:37 2011 +0000

    arm, arm926ejs: Fix clear bss loop for zero length bss

    This patch fixes the clear bss loop for bss sections that have
    zero length, i.e., where __bss_start == __bss_end__.

    Signed-off-by: Christian Riesch <christian.riesch at omicron.at>
    Cc: Albert Aribaud <albert.u.boot at aribaud.net>

diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S
index 339c5ed..bb4d00b 100644
--- a/arch/arm/cpu/arm926ejs/start.S
+++ b/arch/arm/cpu/arm926ejs/start.S
@@ -301,10 +301,12 @@ clear_bss:
 #endif
        mov     r2, #0x00000000         /* clear
    */

-clbss_l:str    r2, [r0]                /* clear loop...
    */
+clbss_l:cmp    r0, r1                  /* clear loop... */
+       bhs     clbss_e                 /* if reached end of bss, exit */
+       str     r2, [r0]
        add     r0, r0, #4
-       cmp     r0, r1
-       bne     clbss_l
+       b       clbss_l
+clbss_e:


Thanks,
hongbo
> 
>>  
>>  /*
>>   * We are done. Do not return, instead branch to second part of board
>>
> 
> Best regards
> 
> Andreas Bießmann
> 




More information about the U-Boot mailing list