[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220406140221.727300-1-guoren@kernel.org>
Date: Wed, 6 Apr 2022 22:02:21 +0800
From: guoren@...nel.org
To: guoren@...nel.org, arnd@...db.de
Cc: linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Guo Ren <guoren@...ux.alibaba.com>,
Catalin Marinas <catalin.marinas@....com>,
Max Filippov <jcmvbkbc@...il.com>,
Masami Hiramatsu <mhiramat@...nel.org>, stable@...r.kernel.org
Subject: [PATCH V3] arm64: patch_text: Fixup last cpu should be master
From: Guo Ren <guoren@...ux.alibaba.com>
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.
Signed-off-by: Guo Ren <guoren@...ux.alibaba.com>
Signed-off-by: Guo Ren <guoren@...nel.org>
Reviewed-by: Catalin Marinas <catalin.marinas@....com>
Reviewed-by: Max Filippov <jcmvbkbc@...il.com>
Reviewed-by: Masami Hiramatsu <mhiramat@...nel.org>
Cc: <stable@...r.kernel.org>
---
arch/arm64/kernel/patching.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/patching.c b/arch/arm64/kernel/patching.c
index 771f543464e0..33e0fabc0b79 100644
--- a/arch/arm64/kernel/patching.c
+++ b/arch/arm64/kernel/patching.c
@@ -117,8 +117,8 @@ static int __kprobes aarch64_insn_patch_text_cb(void *arg)
int i, ret = 0;
struct aarch64_insn_patch *pp = arg;
- /* The first CPU becomes master */
- if (atomic_inc_return(&pp->cpu_count) == 1) {
+ /* The last CPU becomes master */
+ if (atomic_inc_return(&pp->cpu_count) == num_online_cpus()) {
for (i = 0; ret == 0 && i < pp->insn_cnt; i++)
ret = aarch64_insn_patch_text_nosync(pp->text_addrs[i],
pp->new_insns[i]);
--
2.25.1
Powered by blists - more mailing lists