linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/code-patching: Perform hwsync in __patch_instruction() in case of failure
@ 2023-10-07 10:46 Christophe Leroy
  2023-10-27  9:59 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2023-10-07 10:46 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin
  Cc: Hari Bathini, Christopher M . Riedl, linuxppc-dev, linux-kernel

Commit c28c15b6d28a ("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 <christophe.leroy@csgroup.eu>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Christopher M. Riedl <cmr@bluescreens.de>
---
 arch/powerpc/lib/code-patching.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index b00112d7ad46..7a47a871e6b8 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -38,6 +38,7 @@ static int __patch_instruction(u32 *exec_addr, ppc_inst_t instr, u32 *patch_addr
 	return 0;
 
 failed:
+	mb();  /* sync */
 	return -EPERM;
 }
 
@@ -309,10 +310,6 @@ static int __do_patch_instruction_mm(u32 *addr, ppc_inst_t instr)
 
 	err = __patch_instruction(addr, instr, patch_addr);
 
-	/* hwsync performed by __patch_instruction (sync) if successful */
-	if (err)
-		mb();  /* sync */
-
 	/* context synchronisation performed by __patch_instruction (isync or exception) */
 	stop_using_temp_mm(patching_mm, orig_mm);
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] powerpc/code-patching: Perform hwsync in __patch_instruction() in case of failure
  2023-10-07 10:46 [PATCH] powerpc/code-patching: Perform hwsync in __patch_instruction() in case of failure Christophe Leroy
@ 2023-10-27  9:59 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2023-10-27  9:59 UTC (permalink / raw)
  To: Nicholas Piggin, Christophe Leroy
  Cc: Christopher M . Riedl, linuxppc-dev, linux-kernel, Hari Bathini

On Sat, 07 Oct 2023 12:46:19 +0200, Christophe Leroy wrote:
> Commit c28c15b6d28a ("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.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/code-patching: Perform hwsync in __patch_instruction() in case of failure
      https://git.kernel.org/powerpc/c/74726fda9fe306f848088ef73ec266cae0470d5b

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-27 10:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-07 10:46 [PATCH] powerpc/code-patching: Perform hwsync in __patch_instruction() in case of failure Christophe Leroy
2023-10-27  9:59 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).