linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emil Renner Berthing <kernel@esmil.dk>
To: linux-riscv@lists.infradead.org, Palmer Dabbelt <palmer@dabbelt.com>
Cc: "Emil Renner Berthing" <kernel@esmil.dk>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Björn Töpel" <bjorn.topel@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] riscv: Grab text_mutex before patching jump-labels
Date: Thu, 23 Jul 2020 18:36:28 +0200	[thread overview]
Message-ID: <20200723163628.82794-1-kernel@esmil.dk> (raw)

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


             reply	other threads:[~2020-07-23 16:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 16:36 Emil Renner Berthing [this message]
2020-07-27 20:19 ` [PATCH] riscv: Grab text_mutex before patching jump-labels Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200723163628.82794-1-kernel@esmil.dk \
    --to=kernel@esmil.dk \
    --cc=bjorn.topel@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).