Felix Daners writes "The gettimeofday call can go backwards on coldfire
Coldfire do_gettimeofday system call calls the function
coldfire_timer_offset()
to get the accurate actual pit timer value.
The issue is probably compiler dependant. The 20030314
m68k-elf-gcc splits the
pcntr = tp->pcntr;
statement into two movb instructions
.stabn 68,0,113,.LM21-coldfire_timer_offset
.LM21:
move.b 1075118084,%d2
and.l #0xFF,%d2
lsl.l #8,%d2
move.b 1075118085,%d0
and.l #0xFF,%d0
or.l %d2,%d0
This is not safe because there might be an overflow in the low byte
of the counter. It leads to a value in pcntr not representing the
offset.
Below I have a patch that resolves this problem.
It replaces the compiler dependant code by inline assembler that
reads the 16 bit counter with a movew instruction."
The patch and some more comments on it's implementation follow.
|