Skip to content

Commit 8ec1442

Browse files
guoren83palmer-dabbelt
authored andcommitted
riscv: 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. Signed-off-by: Guo Ren <[email protected]> Signed-off-by: Guo Ren <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Reviewed-by: Masami Hiramatsu <[email protected]> Fixes: 043cb41 ("riscv: introduce interfaces to patch kernel code") Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent bf9bac4 commit 8ec1442

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/riscv/kernel/patch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static int patch_text_cb(void *data)
104104
struct patch_insn *patch = data;
105105
int ret = 0;
106106

107-
if (atomic_inc_return(&patch->cpu_count) == 1) {
107+
if (atomic_inc_return(&patch->cpu_count) == num_online_cpus()) {
108108
ret =
109109
patch_text_nosync(patch->addr, &patch->insn,
110110
GET_INSN_LENGTH(patch->insn));

0 commit comments

Comments
 (0)