arm64: patch_text: Fixup last cpu should be master
authorGuo Ren <guoren@linux.alibaba.com>
Thu, 7 Apr 2022 07:33:20 +0000 (15:33 +0800)
committerWill Deacon <will@kernel.org>
Fri, 8 Apr 2022 10:43:46 +0000 (11:43 +0100)
commit31a099dbd91e69fcab55eef4be15ed7a8c984918
tree8822babc29f92bb2327da5bb31cf2286901fa73f
parent697a1d44af8ba0477ee729e632f4ade37999249a
arm64: patch_text: Fixup last cpu should be master

These patch_text implementations are using stop_machine_cpuslocked
infrastructure with atomic cpu_count. The original idea: When the
master CPU patch_text, the others should wait for it. But current
implementation is using the first CPU as master, which couldn't
guarantee the remaining CPUs are waiting. This patch changes the
last CPU as the master to solve the potential risk.

Fixes: ae16480785de ("arm64: introduce interfaces to hotpatch kernel and module code")
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220407073323.743224-2-guoren@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/patching.c