Skip to content

Commit 49f3ef5

Browse files
guoren83gregkh
authored andcommitted
csky: patch_text: Fixup last cpu should be master
commit 8c4d164 upstream. 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: 33e53ae ("csky: Add kprobes supported") Signed-off-by: Guo Ren <[email protected]> Signed-off-by: Guo Ren <[email protected]> Reviewed-by: Masami Hiramatsu <[email protected]> Cc: <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1314d7a commit 49f3ef5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/csky/kernel/probes/kprobes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static int __kprobes patch_text_cb(void *priv)
3030
struct csky_insn_patch *param = priv;
3131
unsigned int addr = (unsigned int)param->addr;
3232

33-
if (atomic_inc_return(&param->cpu_count) == 1) {
33+
if (atomic_inc_return(&param->cpu_count) == num_online_cpus()) {
3434
*(u16 *) addr = cpu_to_le16(param->opcode);
3535
dcache_wb_range(addr, addr + 2);
3636
atomic_inc(&param->cpu_count);

0 commit comments

Comments
 (0)