Skip to content

Commit 20fb6c9

Browse files
committed
x86/mm/kmmio: Use rcu_read_lock_sched_notrace()
The mmiotrace tracer is "special". The purpose is to help reverse engineer binary drivers by removing the memory allocated by the driver and when the driver goes to access it, a fault occurs, the mmiotracer will record what the driver was doing and then do the work on its behalf by single stepping through the process. But to achieve this ability, it must do some special things. One is to take the rcu_read_lock() when the fault occurs, and then release it in the breakpoint that is single stepping. This makes lockdep unhappy, as it changes the state of RCU from within an exception that is not contained in that exception, and we get a nasty splat from lockdep. Instead, switch to rcu_read_lock_sched_notrace() as the RCU sched variant has the same grace period as normal RCU. This is basically the same as rcu_read_lock() but does not make lockdep complain about it. Note, the preempt_disable() is still needed as it uses preempt_enable_no_resched(). Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Karol Herbst <[email protected]> Cc: Pekka Paalanen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Acked-by: Paul E. McKenney <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 4994e38 commit 20fb6c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/x86/mm/kmmio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
254254
* again.
255255
*/
256256
preempt_disable();
257-
rcu_read_lock();
257+
rcu_read_lock_sched_notrace();
258258

259259
faultpage = get_kmmio_fault_page(page_base);
260260
if (!faultpage) {
@@ -323,7 +323,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
323323
return 1; /* fault handled */
324324

325325
no_kmmio:
326-
rcu_read_unlock();
326+
rcu_read_unlock_sched_notrace();
327327
preempt_enable_no_resched();
328328
return ret;
329329
}
@@ -363,7 +363,7 @@ static int post_kmmio_handler(unsigned long condition, struct pt_regs *regs)
363363
/* These were acquired in kmmio_handler(). */
364364
ctx->active--;
365365
BUG_ON(ctx->active);
366-
rcu_read_unlock();
366+
rcu_read_unlock_sched_notrace();
367367
preempt_enable_no_resched();
368368

369369
/*

0 commit comments

Comments
 (0)