Skip to content

Commit 74726fd

Browse files
chleroympe
authored andcommitted
powerpc/code-patching: Perform hwsync in __patch_instruction() in case of failure
Commit c28c15b ("powerpc/code-patching: Use temporary mm for Radix MMU") added a hwsync for when __patch_instruction() fails, we results in a quite odd unbalanced logic. Instead of calling mb() when __patch_instruction() returns an error, call mb() in the __patch_instruction()'s error path directly. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/e88b154eaf2efd9ff177d472d3411dcdec8ff4f5.1696675567.git.christophe.leroy@csgroup.eu
1 parent 89f1701 commit 74726fd

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

arch/powerpc/lib/code-patching.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static int __patch_instruction(u32 *exec_addr, ppc_inst_t instr, u32 *patch_addr
3838
return 0;
3939

4040
failed:
41+
mb(); /* sync */
4142
return -EPERM;
4243
}
4344

@@ -309,10 +310,6 @@ static int __do_patch_instruction_mm(u32 *addr, ppc_inst_t instr)
309310

310311
err = __patch_instruction(addr, instr, patch_addr);
311312

312-
/* hwsync performed by __patch_instruction (sync) if successful */
313-
if (err)
314-
mb(); /* sync */
315-
316313
/* context synchronisation performed by __patch_instruction (isync or exception) */
317314
stop_using_temp_mm(patching_mm, orig_mm);
318315

0 commit comments

Comments
 (0)