Reimplement cmpxchg with LR/SC for SMP safety

* Introduce architecture-specific <asm/cmpxchg.h> header.
* Replace some atomic and atomic64 functions with optimized assembly.