Opened on Mar 17, 2011 at 11:56:05 AM
Closed on Apr 4, 2011 at 3:47:20 PM
#1768 closed defect (fixed)
i368 direction flag handling
Reported by: | Joel Sherrill | Owned by: | Joel Sherrill |
---|---|---|---|
Priority: | normal | Milestone: | 4.11 |
Component: | bsps | Version: | 4.9 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: |
Description
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.
Attachments (2)
Change History (3)
Changed on Mar 17, 2011 at 11:56:05 AM by Joel Sherrill
Attachment: | nbench_rtems_test.tar.bz2 added |
---|
comment:1 Changed on Apr 4, 2011 at 3:47:20 PM by Joel Sherrill
Component: | cpukit → bsps |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Patch committed to 4.9 branch and newer. 4.8 and older were not impacted.
Byte nbench with RTEMS main.c and Makefile