linux/arch/powerpc
Mark Rutland 0c1cf578a8 powerpc: Avoid discarding flags in system_call_exception()
[ Upstream commit 08b0af5b2a ]

Some thread flags can be set remotely, and so even when IRQs are disabled,
the flags can change under our feet. Thus, when setting flags we must use
an atomic operation rather than a plain read-modify-write sequence, as a
plain read-modify-write may discard flags which are concurrently set by a
remote thread, e.g.

	// task A			// task B
	tmp = A->thread_info.flags;
					set_tsk_thread_flag(A, NEWFLAG_B);
	tmp |= NEWFLAG_A;
	A->thread_info.flags = tmp;

arch/powerpc/kernel/interrupt.c's system_call_exception() sets
_TIF_RESTOREALL in the thread info flags with a read-modify-write, which
may result in other flags being discarded.

Elsewhere in the file it uses clear_bits() to atomically remove flag bits,
so use set_bits() here for consistency with those.

There may be reasons (e.g. instrumentation) that prevent the use of
set_thread_flag() and clear_thread_flag() here, which would otherwise be
preferable.

Fixes: ae7aaecc3f ("powerpc/64s: system call rfscv workaround for TM bugs")
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Eirik Fuller <efuller@redhat.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Link: https://lore.kernel.org/r/20211129130653.2037928-10-mark.rutland@arm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-27 11:03:22 +01:00
..
boot powerpc/5200: dts: fix memory node unit name 2021-11-25 09:48:30 +01:00
configs powerpc/configs/microwatt: Enable options for systemd 2021-08-27 00:56:53 +10:00
crypto
include powerpc/book3e: Fix set_memory_x() and set_memory_nx() 2021-11-18 19:16:57 +01:00
kernel powerpc: Avoid discarding flags in system_call_exception() 2022-01-27 11:03:22 +01:00
kexec powerpc updates for 5.15 2021-09-03 11:22:50 -07:00
kvm KVM: PPC: Book3S HV: Prevent POWER7/8 TLB flush flushing SLB 2021-12-01 09:04:43 +01:00
lib powerpc/security: Use a mutex for interrupt exit code patching 2021-11-18 19:17:19 +01:00
math-emu powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
mm powerpc/ptdump: Fix DEBUG_WX since generic ptdump conversion 2022-01-05 12:42:33 +01:00
net powerpc/bpf: Fix write protecting JIT code 2021-11-18 19:17:19 +01:00
perf powerpc/perf: Fix cycles/instructions as PM_CYC/PM_INST_CMPL in power10 2021-11-18 19:16:52 +01:00
platforms powerpc/85xx: Fix oops when CONFIG_FSL_PMC=n 2021-12-22 09:32:45 +01:00
purgatory powerpc/kexec: Don't use .machine ppc64 in trampoline_64.S 2021-04-08 21:17:43 +10:00
sysdev powerpc/xive: Change IRQ domain to a tree domain 2021-11-25 09:48:44 +01:00
tools powerpc/head_check: Fix shellcheck errors 2021-08-17 22:52:02 +10:00
xmon powerpc/xmon: fix task state output 2021-11-18 19:16:57 +01:00
Kbuild
Kconfig powerpc/booke: Disable STRICT_KERNEL_RWX, DEBUG_PAGEALLOC and KFENCE 2021-11-18 19:16:54 +01:00
Kconfig.debug powerpc/ptdump: Convert powerpc to GENERIC_PTDUMP 2021-08-25 13:35:48 +10:00
Makefile powerpc: Add "-z notext" flag to disable diagnostic 2021-08-15 13:49:39 +10:00
Makefile.postlink