[Bug 1768] New: i368 direction flag handling
bugzilla-daemon at rtems.org
bugzilla-daemon at rtems.org
Thu Mar 17 12:56:05 UTC 2011
https://www.rtems.org/bugzilla/show_bug.cgi?id=1768
Summary: i368 direction flag handling
Product: RTEMS
Version: 4.9
Platform: All
OS/Version: RTEMS
Status: NEW
Severity: normal
Priority: P3
Component: cpukit
AssignedTo: joel.sherrill at oarcorp.com
ReportedBy: joel.sherrill at oarcorp.com
Created an attachment (id=1136)
--> (https://www.rtems.org/bugzilla/attachment.cgi?id=1136)
Byte nbench with RTEMS main.c and Makefile
The Byte nbench benchmark has a test which is very heavy on string operations.
When the stack checker. This highlighted the fact that we do not perform a
"cld" before calling C code in the ISR. This was historically not a problem
but gcc 4.3 changed the behavior. From http://gcc.gnu.org/gcc-4.3/changes.html
"GCC no longer places the cld instruction before string operations. Both i386
and x86-64 ABI documents mandate the direction flag to be clear at the entry of
a function. It is now invalid to set the flag in asm statement without reseting
it afterward."
RTEMS 4.8 uses gcc 4.2.x. RTEMS 4.9 uses gcc 4.3 so it and newer are impacted.
The nbench program ran fine on pc386 until it was run from a second task (not
Init). At some point, the memcmp in the stack checker extension would fail.
Debugging showed this was always in the case of a dispatch at the end of an
ISR. It failed because the direction flag was set wrong.
The attached program can produce the failure during the "DoStringSort" case.
The attached patch fixes the problem by ensuring the direction flag is cleared
before calling C code in an ISR. The "iret" restores eflags and restores
whatever state it was in.
--
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
More information about the bugs
mailing list