freebsd-skq/sys/arm
Olivier Houchard b21a1da537 Close a race.
The RAS implementation would set the end address, then the start
address.  These were used by the kernel to restart a RAS sequence if
it was interrupted.  When the thread switching code ran, it would
check these values and adjust the PC and clear them if it did.

However, there's a small flaw in this scheme.  Thread T1, sets the end
address and gets preempted.  Thread T2 runs and also does a RAS
operation.  This resets end to zero.  Thread T1 now runs again and
sets start and then begins the RAS sequence, but is preempted before
the RAS sequence executes its last instruction.  The kernel code that
would ordinarily restart the RAS sequence doesn't because the PC isn't
between start and 0, so the PC isn't set to the start of the sequence.
So when T1 is resumed again, it is at the wrong location for RAS to
produce the correct results.  This causes the wrong results for the
atomic sequence.

The window for the first race is 3 instructions.  The window for the
second race is 5-10 instructions depending on the atomic operation.
This makes this failure fairly rare and hard to reproduce.

Mutexs are implemented in libthr using atomic operations.  When the
above race would occur, a lock could get stuck locked, causing many
downstream problems, as you might expect.

Also, make sure to reset the start and end address when doing a syscall, or
a malicious process could set them before doing a syscall.

Reviewed by: imp, ups (thanks guys)
Pointy hat to:	cognet
MFC After:	3 days
2007-12-02 12:49:28 +00:00
..
arm Fixes for ARM9/ARM10 : 2007-11-28 22:55:55 +00:00
at91 Fix for the panic("vm_thread_new: kstack allocation failed") and 2007-11-05 11:36:16 +00:00
compile
conf Add a kernel config file for the Hot-e HL200 (AT91RM92 based). 2007-11-17 17:25:22 +00:00
include Close a race. 2007-12-02 12:49:28 +00:00
sa11x0 Fix for the panic("vm_thread_new: kstack allocation failed") and 2007-11-05 11:36:16 +00:00
xscale Fix for the panic("vm_thread_new: kstack allocation failed") and 2007-11-05 11:36:16 +00:00