All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: Grab text_mutex before patching jump-labels
@ 2020-07-23 16:36 ` Emil Renner Berthing
  0 siblings, 0 replies; 4+ messages in thread
From: Emil Renner Berthing @ 2020-07-23 16:36 UTC (permalink / raw)
  To: linux-riscv, Palmer Dabbelt
  Cc: Emil Renner Berthing, Paul Walmsley, Björn Töpel, linux-kernel

Like other arch's we use patch_text_nosync or equivalent
to patch the jump-labels, but also like other arch's we
need to hold the text_mutex before calling that.

Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
---

Fixes: b6e0878a4ec8 ("riscv: Add jump-label implementation")
..that is already in riscv/for-next.

Palmer: Sorry, I didn't notice this before. Feel free to
squash this into the commit above if you like.
---
 arch/riscv/kernel/jump_label.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/jump_label.c b/arch/riscv/kernel/jump_label.c
index 1bab1abc1aa5..20e09056d141 100644
--- a/arch/riscv/kernel/jump_label.c
+++ b/arch/riscv/kernel/jump_label.c
@@ -4,8 +4,10 @@
  *
  * Based on arch/arm64/kernel/jump_label.c
  */
-#include <linux/kernel.h>
 #include <linux/jump_label.h>
+#include <linux/kernel.h>
+#include <linux/memory.h>
+#include <linux/mutex.h>
 #include <asm/bug.h>
 #include <asm/patch.h>
 
@@ -33,7 +35,9 @@ void arch_jump_label_transform(struct jump_entry *entry,
 		insn = RISCV_INSN_NOP;
 	}
 
+	mutex_lock(&text_mutex);
 	patch_text_nosync(addr, &insn, sizeof(insn));
+	mutex_unlock(&text_mutex);
 }
 
 void arch_jump_label_transform_static(struct jump_entry *entry,
-- 
2.27.0


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

* [PATCH] riscv: Grab text_mutex before patching jump-labels
@ 2020-07-23 16:36 ` Emil Renner Berthing
  0 siblings, 0 replies; 4+ messages in thread
From: Emil Renner Berthing @ 2020-07-23 16:36 UTC (permalink / raw)
  To: linux-riscv, Palmer Dabbelt
  Cc: Björn Töpel, Emil Renner Berthing, linux-kernel, Paul Walmsley

Like other arch's we use patch_text_nosync or equivalent
to patch the jump-labels, but also like other arch's we
need to hold the text_mutex before calling that.

Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
---

Fixes: b6e0878a4ec8 ("riscv: Add jump-label implementation")
..that is already in riscv/for-next.

Palmer: Sorry, I didn't notice this before. Feel free to
squash this into the commit above if you like.
---
 arch/riscv/kernel/jump_label.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/jump_label.c b/arch/riscv/kernel/jump_label.c
index 1bab1abc1aa5..20e09056d141 100644
--- a/arch/riscv/kernel/jump_label.c
+++ b/arch/riscv/kernel/jump_label.c
@@ -4,8 +4,10 @@
  *
  * Based on arch/arm64/kernel/jump_label.c
  */
-#include <linux/kernel.h>
 #include <linux/jump_label.h>
+#include <linux/kernel.h>
+#include <linux/memory.h>
+#include <linux/mutex.h>
 #include <asm/bug.h>
 #include <asm/patch.h>
 
@@ -33,7 +35,9 @@ void arch_jump_label_transform(struct jump_entry *entry,
 		insn = RISCV_INSN_NOP;
 	}
 
+	mutex_lock(&text_mutex);
 	patch_text_nosync(addr, &insn, sizeof(insn));
+	mutex_unlock(&text_mutex);
 }
 
 void arch_jump_label_transform_static(struct jump_entry *entry,
-- 
2.27.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv: Grab text_mutex before patching jump-labels
  2020-07-23 16:36 ` Emil Renner Berthing
@ 2020-07-27 20:19   ` Palmer Dabbelt
  -1 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2020-07-27 20:19 UTC (permalink / raw)
  To: kernel; +Cc: linux-riscv, kernel, Paul Walmsley, Bjorn Topel, linux-kernel

On Thu, 23 Jul 2020 09:36:28 PDT (-0700), kernel@esmil.dk wrote:
> Like other arch's we use patch_text_nosync or equivalent
> to patch the jump-labels, but also like other arch's we
> need to hold the text_mutex before calling that.
>
> Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
> ---
>
> Fixes: b6e0878a4ec8 ("riscv: Add jump-label implementation")
> ..that is already in riscv/for-next.
>
> Palmer: Sorry, I didn't notice this before. Feel free to
> squash this into the commit above if you like.
> ---
>  arch/riscv/kernel/jump_label.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/jump_label.c b/arch/riscv/kernel/jump_label.c
> index 1bab1abc1aa5..20e09056d141 100644
> --- a/arch/riscv/kernel/jump_label.c
> +++ b/arch/riscv/kernel/jump_label.c
> @@ -4,8 +4,10 @@
>   *
>   * Based on arch/arm64/kernel/jump_label.c
>   */
> -#include <linux/kernel.h>
>  #include <linux/jump_label.h>
> +#include <linux/kernel.h>
> +#include <linux/memory.h>
> +#include <linux/mutex.h>
>  #include <asm/bug.h>
>  #include <asm/patch.h>
>
> @@ -33,7 +35,9 @@ void arch_jump_label_transform(struct jump_entry *entry,
>  		insn = RISCV_INSN_NOP;
>  	}
>
> +	mutex_lock(&text_mutex);
>  	patch_text_nosync(addr, &insn, sizeof(insn));
> +	mutex_unlock(&text_mutex);
>  }
>
>  void arch_jump_label_transform_static(struct jump_entry *entry,

I've just put this on for-next as is.  I generally try to avoid rebasing stuff,
but I think I saw a message today about a patch I put there prematurely so I
might have to rewrite history anyway.  If I do I'll squash it and a few other
small fixes.

Thanks!

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

* Re: [PATCH] riscv: Grab text_mutex before patching jump-labels
@ 2020-07-27 20:19   ` Palmer Dabbelt
  0 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2020-07-27 20:19 UTC (permalink / raw)
  To: kernel; +Cc: Bjorn Topel, linux-riscv, kernel, linux-kernel, Paul Walmsley

On Thu, 23 Jul 2020 09:36:28 PDT (-0700), kernel@esmil.dk wrote:
> Like other arch's we use patch_text_nosync or equivalent
> to patch the jump-labels, but also like other arch's we
> need to hold the text_mutex before calling that.
>
> Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
> ---
>
> Fixes: b6e0878a4ec8 ("riscv: Add jump-label implementation")
> ..that is already in riscv/for-next.
>
> Palmer: Sorry, I didn't notice this before. Feel free to
> squash this into the commit above if you like.
> ---
>  arch/riscv/kernel/jump_label.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/jump_label.c b/arch/riscv/kernel/jump_label.c
> index 1bab1abc1aa5..20e09056d141 100644
> --- a/arch/riscv/kernel/jump_label.c
> +++ b/arch/riscv/kernel/jump_label.c
> @@ -4,8 +4,10 @@
>   *
>   * Based on arch/arm64/kernel/jump_label.c
>   */
> -#include <linux/kernel.h>
>  #include <linux/jump_label.h>
> +#include <linux/kernel.h>
> +#include <linux/memory.h>
> +#include <linux/mutex.h>
>  #include <asm/bug.h>
>  #include <asm/patch.h>
>
> @@ -33,7 +35,9 @@ void arch_jump_label_transform(struct jump_entry *entry,
>  		insn = RISCV_INSN_NOP;
>  	}
>
> +	mutex_lock(&text_mutex);
>  	patch_text_nosync(addr, &insn, sizeof(insn));
> +	mutex_unlock(&text_mutex);
>  }
>
>  void arch_jump_label_transform_static(struct jump_entry *entry,

I've just put this on for-next as is.  I generally try to avoid rebasing stuff,
but I think I saw a message today about a patch I put there prematurely so I
might have to rewrite history anyway.  If I do I'll squash it and a few other
small fixes.

Thanks!

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2020-07-27 20:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 16:36 [PATCH] riscv: Grab text_mutex before patching jump-labels Emil Renner Berthing
2020-07-23 16:36 ` Emil Renner Berthing
2020-07-27 20:19 ` Palmer Dabbelt
2020-07-27 20:19   ` Palmer Dabbelt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.