Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: stable@vger.kernel.org
Cc: conor@kernel.org, Conor Dooley <conor.dooley@microchip.com>,
	palmer@dabbelt.com, Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 6.1 v1] RISC-V: fix lock splat in riscv_cpufeature_patch_func()
Date: Tue,  9 May 2023 22:36:42 +0100	[thread overview]
Message-ID: <20230509-suspend-labrador-3eb6f0a8ac77@spud> (raw)

From: Conor Dooley <conor.dooley@microchip.com>

Guenter reported a lockdep splat that appears to have been present for a
while in v6.1.y & the backports of the riscv_patch_in_stop_machine dance
did nothing to help here, as the lock is not being taken when
patch_text_nosync() is called in riscv_cpufeature_patch_func().
Add the lock/unlock; elide the splat.

Fixes: c15ac4fd60d5 ("riscv/ftrace: Add dynamic function tracer support")
Reported-by: Guenter Roeck <linux@roeck-us.net>
cc: stable@vger.kernel.org
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
 arch/riscv/kernel/cpufeature.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 694267d1fe81..fd1238df6149 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -9,6 +9,7 @@
 #include <linux/bitmap.h>
 #include <linux/ctype.h>
 #include <linux/libfdt.h>
+#include <linux/memory.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <asm/alternative.h>
@@ -316,8 +317,11 @@ void __init_or_module riscv_cpufeature_patch_func(struct alt_entry *begin,
 		}
 
 		tmp = (1U << alt->errata_id);
-		if (cpu_req_feature & tmp)
+		if (cpu_req_feature & tmp) {
+			mutex_lock(&text_mutex);
 			patch_text_nosync(alt->old_ptr, alt->alt_ptr, alt->alt_len);
+			mutex_unlock(&text_mutex);
+		}
 	}
 }
 #endif
-- 
2.39.2


             reply	other threads:[~2023-05-09 21:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-09 21:36 Conor Dooley [this message]
2023-05-11 23:39 ` [PATCH 6.1 v1] RISC-V: fix lock splat in riscv_cpufeature_patch_func() Sasha Levin
2023-05-12  7:03   ` Conor Dooley
  -- strict thread matches above, loose matches on Subject: below --
2023-05-10 20:40 Guenter Roeck

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=20230509-suspend-labrador-3eb6f0a8ac77@spud \
    --to=conor@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=linux@roeck-us.net \
    --cc=palmer@dabbelt.com \
    --cc=stable@vger.kernel.org \
    /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