xtensa: add missing exclusive access state management
authorMax Filippov <jcmvbkbc@gmail.com>
Fri, 31 Jul 2020 19:38:05 +0000 (12:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:07:23 +0000 (13:07 +0200)
commit84affd7847d66644944989aadf7ea3fc2534b291
treed8de9cbd0579b0960f095c8319cba15cbca4216d
parentd7ccfcd8445971bd2fce1ee2b8ba4e566e76754a
xtensa: add missing exclusive access state management

commit a0fc1436f1f4f84e93144480bf30e0c958d135b6 upstream.

The result of the s32ex opcode is recorded in the ATOMCTL special
register and must be retrieved with the getex opcode. Context switch
between s32ex and getex may trash the ATOMCTL register and result in
duplicate update or missing update of the atomic variable.
Add atomctl8 field to the struct thread_info and use getex to swap
ATOMCTL bit 8 as a part of context switch.
Clear exclusive access monitor on kernel entry.

Cc: stable@vger.kernel.org
Fixes: f7c34874f04a ("xtensa: add exclusive atomics support")
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/xtensa/include/asm/thread_info.h
arch/xtensa/kernel/asm-offsets.c
arch/xtensa/kernel/entry.S