summaryrefslogtreecommitdiffstats
path: root/arch/m68k/mm/memory.c
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2023-01-05 15:44:20 +0100
committerHeiko Carstens <hca@linux.ibm.com>2023-01-11 15:28:34 +0100
commit82d3edb50a11bf3c5ef63294d5358ba230181413 (patch)
tree4555a4963d8ba17047613b4ec7ad7fd975184632 /arch/m68k/mm/memory.c
parentc2337a40e04dde1692b5b0a46ecc59f89aaba8a1 (diff)
downloadlinux-82d3edb50a11bf3c5ef63294d5358ba230181413.tar.bz2
s390/cpum_sf: add READ_ONCE() semantics to compare and swap loops
The current cmpxchg_double() loops within the perf hw sampling code do not have READ_ONCE() semantics to read the old value from memory. This allows the compiler to generate code which reads the "old" value several times from memory, which again allows for inconsistencies. For example: /* Reset trailer (using compare-double-and-swap) */ do { te_flags = te->flags & ~SDB_TE_BUFFER_FULL_MASK; te_flags |= SDB_TE_ALERT_REQ_MASK; } while (!cmpxchg_double(&te->flags, &te->overflow, te->flags, te->overflow, te_flags, 0ULL)); The compiler could generate code where te->flags used within the cmpxchg_double() call may be refetched from memory and which is not necessarily identical to the previous read version which was used to generate te_flags. Which in turn means that an incorrect update could happen. Fix this by adding READ_ONCE() semantics to all cmpxchg_double() loops. Given that READ_ONCE() cannot generate code on s390 which atomically reads 16 bytes, use a private compare-and-swap-double implementation to achieve that. Also replace cmpxchg_double() with the private implementation to be able to re-use the old value within the loops. As a side effect this converts the whole code to only use bit fields to read and modify bits within the hws trailer header. Reported-by: Alexander Gordeev <agordeev@linux.ibm.com> Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Acked-by: Hendrik Brueckner <brueckner@linux.ibm.com> Reviewed-by: Thomas Richter <tmricht@linux.ibm.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/linux-s390/Y71QJBhNTIatvxUT@osiris/T/#ma14e2a5f7aa8ed4b94b6f9576799b3ad9c60f333 Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/m68k/mm/memory.c')
0 files changed, 0 insertions, 0 deletions