From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Karol Herbst <karolherbst@gmail.com>,
Pekka Paalanen <ppaalanen@gmail.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org
Subject: [PATCH 0/2] x86/mm/kmmio: Have mmiotracer play nice with lockdep
Date: Tue, 06 Dec 2022 14:12:01 -0500 [thread overview]
Message-ID: <20221206191201.217838841@goodmis.org> (raw)
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(-)
next reply other threads:[~2022-12-06 19:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-06 19:12 Steven Rostedt [this message]
2022-12-06 19:12 ` [PATCH 1/2] x86/mm/kmmio: Switch to arch_spin_lock() Steven Rostedt
2022-12-06 19:12 ` [PATCH 2/2] x86/mm/kmmio: Remove rcu_read_lock() Steven Rostedt
2022-12-07 17:36 ` Paul E. McKenney
2022-12-09 18:03 ` Steven Rostedt
2022-12-09 18:09 ` Steven Rostedt
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=20221206191201.217838841@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=karolherbst@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=ppaalanen@gmail.com \
--cc=tglx@linutronix.de \
--cc=x86@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