[RFC PATCH] x86: mmiotrace - trace memory mapped IO

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Pekka Paalanen
Date: Sunday, January 27, 2008 - 10:55 am

Hello,

the patch itself is slightly bigger than recommended for LKML, so
it is available at:
http://jumi.lut.fi/~paalanen/scratch/mmio24/0002-x86-mmiotrace-trace-memory-mapped-IO....

This seems to work fine on UP machine, I have not tested yet with
with an SMP machine. Originally mmio-trace was UP-only, so there
probably still are SMP issues. Mmio-trace has existed with its current
purpose for about a year now.

The following is a copy of the patch description:

Mmiotrace is a tool for trapping memory mapped IO (MMIO) accesses within
the kernel. It is used for debugging and especially for reverse
engineering evil binary drivers.

Mmiotrace works by wrapping the ioremap family of kernel functions and
marking the returned pages as not present. Access to the IO memory
triggers a page fault, which will be handled by mmiotrace's custom page
fault handler. This will single-step the faulted instruction with the
MMIO page marked as present. Access logs are directed to user space via
relay and debug_fs.

This page fault approach is necessary, because binary drivers have
readl/writel etc. calls inlined and therefore extremely difficult to
trap with with e.g. kprobes.

This patch depends on the custom page fault handlers patch.

---

More information on mmio-trace can be found at
http://nouveau.freedesktop.org/wiki/MmioTrace
and the out-of-three module with user space parts is at
http://gitweb.freedesktop.org/?p=users/pq/mmio-trace.git;a=summary

The out-of-tree git does not include all changes I made for the
in-tree version.

Mmiotrace does not appear to procude excruciating slowness when used.
Starting X with traced nvidia binary drivers takes a couple of seconds
longer than normally. Starting X, running glxgears for a moment and
shutting down X results in an mmio-trace log of roughly 1.5 million
events. Replace glxgears by running Quake3-demo's first demo play
twice and end up with 3.5 million events. Quake3-demo framerate with
mmio-traced driver goes down to 59 fps, compared to the normal 83 fps.

I know of one bad failure case with mmio-trace. It may trigger a
complete system freeze when tracing a certain nvidia driver version
on a machine with an 8000-series (nv50) graphics chip. Netconsole,
serial console and NMI watchdog have so far been useless, and I
am starting to believe that it is the nvidia driver that does
something bad to make mmio-trace fall over. I have heard that more
recent nvidia drivers do not make it crash anymore.

I'm hoping mmiotrace could be included in 2.6.25. It would help
FOSS driver projects (Nouveau, maybe madwifi, too) to gather the
information they need. Very often the information comes from
ordinary users, for whom going through kernel patching would be
a major struggle.


Thanks,
Pekka
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] x86: Add a list for custom page fault handlers., Pekka Paalanen, (Sun Jan 27, 9:52 am)
[RFC PATCH] x86: mmiotrace - trace memory mapped IO, Pekka Paalanen, (Sun Jan 27, 10:55 am)
Re: [PATCH] x86: Add a list for custom page fault handlers., Harvey Harrison, (Tue Jan 29, 7:28 pm)
Re: [PATCH] x86: Add a list for custom page fault handlers., Harvey Harrison, (Tue Jan 29, 7:34 pm)
Re: [PATCH] x86: Add a list for custom page fault handlers., Pekka Paalanen, (Wed Jan 30, 11:08 am)
Re: [PATCH] x86: Add a list for custom page fault handlers., Arjan van de Ven, (Wed Jan 30, 11:20 am)
Re: [RFC PATCH] x86: mmiotrace - trace memory mapped IO, Pekka Paalanen, (Wed Jan 30, 3:39 pm)
[PATCH v2] x86: Add a list for custom page fault handlers., Pekka Paalanen, (Thu Jan 31, 9:02 am)
[RFC PATCH v2] x86: mmiotrace - trace memory mapped IO, Pekka Paalanen, (Thu Jan 31, 9:16 am)
Re: [RFC PATCH v2] x86: mmiotrace - trace memory mapped IO, Arjan van de Ven, (Thu Jan 31, 9:29 am)
Re: [RFC PATCH v2] x86: mmiotrace - trace memory mapped IO, Pekka Paalanen, (Sun Feb 3, 12:21 am)
[PATCH 1/4] x86 mmiotrace: use lookup_address(), Pekka Paalanen, (Tue Feb 5, 1:28 pm)
[PATCH 3/4] x86 mmiotrace: comment about user space ABI, Pekka Paalanen, (Tue Feb 5, 1:31 pm)
[PATCH 4/4] x86 mmiotrace: move files into arch/x86/mm/, Pekka Paalanen, (Tue Feb 5, 1:39 pm)
Re: [PATCH 1/4] x86 mmiotrace: use lookup_address(), Christoph Hellwig, (Tue Feb 5, 10:00 pm)
Re: [PATCH 1/4] x86 mmiotrace: use lookup_address(), Ingo Molnar, (Thu Feb 7, 5:52 am)
Re: [PATCH 4/4] x86 mmiotrace: move files into arch/x86/mm/, Christoph Hellwig, (Thu Feb 7, 5:56 am)
[PATCH] x86 mmiotrace: Use percpu instead of arrays., Pekka Paalanen, (Sat Feb 9, 10:53 am)