xref: /linux/Documentation/arch/arm/swp_emulation.rst (revision d56b699d76d1b352f7a3d3a0a3e91c79b8612d94)
164d2dc38SLeif LindholmSoftware emulation of deprecated SWP instruction (CONFIG_SWP_EMULATE)
264d2dc38SLeif Lindholm---------------------------------------------------------------------
364d2dc38SLeif Lindholm
4*d56b699dSBjorn HelgaasARMv6 architecture deprecates use of the SWP/SWPB instructions, and recommends
564d2dc38SLeif Lindholmmoving to the load-locked/store-conditional instructions LDREX and STREX.
664d2dc38SLeif Lindholm
764d2dc38SLeif LindholmARMv7 multiprocessing extensions introduce the ability to disable these
864d2dc38SLeif Lindholminstructions, triggering an undefined instruction exception when executed.
964d2dc38SLeif LindholmTrapped instructions are emulated using an LDREX/STREX or LDREXB/STREXB
1064d2dc38SLeif Lindholmsequence. If a memory access fault (an abort) occurs, a segmentation fault is
1164d2dc38SLeif Lindholmsignalled to the triggering process.
1264d2dc38SLeif Lindholm
1364d2dc38SLeif Lindholm/proc/cpu/swp_emulation holds some statistics/information, including the PID of
14dc7a12bdSMauro Carvalho Chehabthe last process to trigger the emulation to be invocated. For example::
15dc7a12bdSMauro Carvalho Chehab
1664d2dc38SLeif Lindholm  Emulated SWP:		12
1764d2dc38SLeif Lindholm  Emulated SWPB:		0
1864d2dc38SLeif Lindholm  Aborted SWP{B}:		1
1964d2dc38SLeif Lindholm  Last process:		314
2064d2dc38SLeif Lindholm
21dc7a12bdSMauro Carvalho Chehab
22dc7a12bdSMauro Carvalho ChehabNOTE:
23dc7a12bdSMauro Carvalho Chehab  when accessing uncached shared regions, LDREX/STREX rely on an external
2464d2dc38SLeif Lindholm  transaction monitoring block called a global monitor to maintain update
2564d2dc38SLeif Lindholm  atomicity. If your system does not implement a global monitor, this option can
2664d2dc38SLeif Lindholm  cause programs that perform SWP operations to uncached memory to deadlock, as
2764d2dc38SLeif Lindholm  the STREX operation will always fail.
28