Skip to content

x86/mm/kmmio: Have mmiotracer play nice with lockdep

Steven Rostedt linux-trace-kernel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2x86/mm/kmmio: Switch to arch_spin_lock()arch/x86/mm/kmmio.c+22 -90 replies
2/2x86/mm/kmmio: Remove rcu_read_lock()arch/x86/mm/kmmio.c+0 -33 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchPaul E. McKenney
1/2
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] x86/mm/kmmio: Have mmiotracer play nice with lockdep

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 it needs to grab a lock while in the breakpoint handler. This is considered an NMI state, and then lockdep warns that the lock is being held in both an NMI state (really a breakpoint handler) and also in normal context.

As the breakpoint/NMI state only happens when the driver is accessing memory, there's no concern of a race condition against the setup and tear-down of mmiotracer.

To make lockdep and mmiotrace work together, convert the locks used in the breakpoint handler into arch_spin_lock().

It also takes the rcu_read_lock() at the fault, and releases it in the single step breakpoint. This makes lockdep sad. Luckily, it also disables preemption when taking the rcu_read_lock() and enables it when releasing the rcu_read_lock(). As now the sched RCU variant is basically the same as the "normal" RCU variant, there's no reason to take the rcu_read_lock(), so just remove it.

Steven Rostedt (2):
x86/mm/kmmio: Switch to arch_spin_lock()
x86/mm/kmmio: Remove rcu_read_lock()

----

 arch/x86/mm/kmmio.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)