* ARM architecture HAL fix
@ 2009-02-09 15:35 Nick Garnett
2009-02-09 16:18 ` Jim Seymour
0 siblings, 1 reply; 3+ messages in thread
From: Nick Garnett @ 2009-02-09 15:35 UTC (permalink / raw)
To: ecos-patches
This fixes a very old bug in the ARM architecture HAL.
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/ChangeLog,v
retrieving revision 1.114
diff -u -5 -r1.114 ChangeLog
--- ChangeLog 2 Feb 2009 19:02:40 -0000 1.114
+++ ChangeLog 9 Feb 2009 15:31:31 -0000
@@ -1,5 +1,15 @@
+2009-02-09 Nick Garnett <nickg@ecoscentric.com>
+
+ * src/vectors.S (start): The loop to initialize BSS was using a
+ BLS to terminate. This caused an extra zero to be stored beyond
+ the end of __bss_end. Usually this is benign, but when __bss_end
+ is at the very top of RAM, and the hardware generates an exception
+ for illegal accesses, this can crash the program before it even
+ starts. The fix is to use a BLT instructions which will terminate
+ the loop 1 word earlier.
+
2009-02-02 Bart Veer <bartv@ecoscentric.com>
* cdl/hal_arm.cdl: add new architectural CFLAGS and LDFLAGS
options.
Index: src/vectors.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/src/vectors.S,v
retrieving revision 1.59
diff -u -5 -r1.59 vectors.S
--- src/vectors.S 29 Jan 2009 17:48:55 -0000 1.59
+++ src/vectors.S 9 Feb 2009 15:31:31 -0000
@@ -448,11 +448,11 @@
mov r0,#0
cmp r1,r2
beq 2f
1: str r0,[r1],#4
cmp r1,r2
- bls 1b
+ blt 1b
2:
// Run kernel + application in THUMB mode
THUMB_MODE(r1,10)
--
Nick Garnett eCos Kernel Architect
eCosCentric Limited http://www.eCosCentric.com The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No: 4422071
Besuchen Sie uns vom 3.-5.03.09 auf der Embedded World 2009, Stand 11-300
Visit us at Embedded World 2009, Nürnberg, Germany, 3-5 Mar, Stand 11-300
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ARM architecture HAL fix
2009-02-09 15:35 ARM architecture HAL fix Nick Garnett
@ 2009-02-09 16:18 ` Jim Seymour
2009-02-09 16:47 ` Nick Garnett
0 siblings, 1 reply; 3+ messages in thread
From: Jim Seymour @ 2009-02-09 16:18 UTC (permalink / raw)
To: ecos-patches
Nick Garnett wrote:
> This fixes a very old bug in the ARM architecture HAL.
> [... replace "bls" with "blt" in bss zero loop ...]
Won't this fail if the memory is located above 0x80000000?
I don't know how common this is, but I'm sure there's an implementation
out there *somewhere*...
--
Jim Seymour, Cipher Systems, Inc., 503-617-7447, http://www.cipher.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ARM architecture HAL fix
2009-02-09 16:18 ` Jim Seymour
@ 2009-02-09 16:47 ` Nick Garnett
0 siblings, 0 replies; 3+ messages in thread
From: Nick Garnett @ 2009-02-09 16:47 UTC (permalink / raw)
To: Jim Seymour; +Cc: ecos-patches
Jim Seymour <jim@cipher.com> writes:
> Nick Garnett wrote:
> > This fixes a very old bug in the ARM architecture HAL.
> > [... replace "bls" with "blt" in bss zero loop ...]
>
> Won't this fail if the memory is located above 0x80000000?
>
> I don't know how common this is, but I'm sure there's an
> implementation out there *somewhere*...
You're right! That's what comes of trying a quick fix, I forgot that
LT was a signed comparison. The following should fix it properly.
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/ChangeLog,v
retrieving revision 1.115
diff -u -5 -r1.115 ChangeLog
--- ChangeLog 9 Feb 2009 15:34:49 -0000 1.115
+++ ChangeLog 9 Feb 2009 16:42:36 -0000
@@ -3,12 +3,12 @@
* src/vectors.S (start): The loop to initialize BSS was using a
BLS to terminate. This caused an extra zero to be stored beyond
the end of __bss_end. Usually this is benign, but when __bss_end
is at the very top of RAM, and the hardware generates an exception
for illegal accesses, this can crash the program before it even
- starts. The fix is to use a BLT instructions which will terminate
- the loop 1 word earlier.
+ starts. The fix is to use a BHI instructions and reverse the
+ compare, which will terminate the loop 1 word earlier.
2009-02-02 Bart Veer <bartv@ecoscentric.com>
* cdl/hal_arm.cdl: add new architectural CFLAGS and LDFLAGS
options.
Index: src/vectors.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/arm/arch/current/src/vectors.S,v
retrieving revision 1.60
diff -u -5 -r1.60 vectors.S
--- src/vectors.S 9 Feb 2009 15:34:49 -0000 1.60
+++ src/vectors.S 9 Feb 2009 16:42:36 -0000
@@ -447,12 +447,12 @@
ldr r2,.__bss_end
mov r0,#0
cmp r1,r2
beq 2f
1: str r0,[r1],#4
- cmp r1,r2
- blt 1b
+ cmp r2,r1
+ bhi 1b
2:
// Run kernel + application in THUMB mode
THUMB_MODE(r1,10)
--
Nick Garnett eCos Kernel Architect
eCosCentric Limited http://www.eCosCentric.com The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No: 4422071
Besuchen Sie uns vom 3.-5.03.09 auf der Embedded World 2009, Stand 11-300
Visit us at Embedded World 2009, Nürnberg, Germany, 3-5 Mar, Stand 11-300
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-02-09 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-09 15:35 ARM architecture HAL fix Nick Garnett
2009-02-09 16:18 ` Jim Seymour
2009-02-09 16:47 ` Nick Garnett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).