2008-05-12 12:20:56 -07:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Copyright (C) IBM Corporation, 2005
|
|
|
|
* Jeff Muizelaar, 2006, 2007
|
|
|
|
* Pekka Paalanen, 2008 <pq@iki.fi>
|
|
|
|
*
|
|
|
|
* Derived from the read-mod example from relay-examples by Tom Zanussi.
|
|
|
|
*/
|
2008-05-12 12:20:57 -07:00
|
|
|
#define DEBUG 1
|
|
|
|
|
2008-05-12 12:20:56 -07:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/debugfs.h>
|
2008-05-12 12:20:57 -07:00
|
|
|
#include <linux/uaccess.h>
|
2008-05-12 12:21:03 -07:00
|
|
|
#include <linux/io.h>
|
2008-05-12 12:20:56 -07:00
|
|
|
#include <linux/version.h>
|
|
|
|
#include <linux/kallsyms.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <linux/mmiotrace.h>
|
|
|
|
#include <asm/e820.h> /* for ISA_START_ADDRESS */
|
2008-05-12 12:20:56 -07:00
|
|
|
#include <asm/atomic.h>
|
2008-05-12 12:20:57 -07:00
|
|
|
#include <linux/percpu.h>
|
2008-05-12 12:21:02 -07:00
|
|
|
#include <linux/cpu.h>
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
#include "pf_in.h"
|
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
#define NAME "mmiotrace: "
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
struct trap_reason {
|
|
|
|
unsigned long addr;
|
|
|
|
unsigned long ip;
|
|
|
|
enum reason_type type;
|
|
|
|
int active_traces;
|
|
|
|
};
|
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
struct remap_trace {
|
|
|
|
struct list_head list;
|
|
|
|
struct kmmio_probe probe;
|
2008-05-12 12:21:03 -07:00
|
|
|
resource_size_t phys;
|
2008-05-12 12:20:57 -07:00
|
|
|
unsigned long id;
|
|
|
|
};
|
|
|
|
|
2008-05-12 12:20:56 -07:00
|
|
|
/* Accessed per-cpu. */
|
2008-05-12 12:20:57 -07:00
|
|
|
static DEFINE_PER_CPU(struct trap_reason, pf_reason);
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
static DEFINE_PER_CPU(struct mmiotrace_rw, cpu_trace);
|
2008-05-12 12:20:56 -07:00
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
static DEFINE_MUTEX(mmiotrace_mutex);
|
|
|
|
static DEFINE_SPINLOCK(trace_lock);
|
|
|
|
static atomic_t mmiotrace_enabled;
|
|
|
|
static LIST_HEAD(trace_list); /* struct remap_trace */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locking in this file:
|
|
|
|
* - mmiotrace_mutex enforces enable/disable_mmiotrace() critical sections.
|
|
|
|
* - mmiotrace_enabled may be modified only when holding mmiotrace_mutex
|
|
|
|
* and trace_lock.
|
|
|
|
* - Routines depending on is_enabled() must take trace_lock.
|
|
|
|
* - trace_list users must hold trace_lock.
|
2008-09-16 12:00:34 -07:00
|
|
|
* - is_enabled() guarantees that mmio_trace_{rw,mapping} are allowed.
|
2008-05-12 12:20:57 -07:00
|
|
|
* - pre/post callbacks assume the effect of is_enabled() being true.
|
|
|
|
*/
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
/* module parameters */
|
2008-05-12 12:20:57 -07:00
|
|
|
static unsigned long filter_offset;
|
|
|
|
static int nommiotrace;
|
|
|
|
static int trace_pc;
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
module_param(filter_offset, ulong, 0);
|
|
|
|
module_param(nommiotrace, bool, 0);
|
|
|
|
module_param(trace_pc, bool, 0);
|
|
|
|
|
|
|
|
MODULE_PARM_DESC(filter_offset, "Start address of traced mappings.");
|
|
|
|
MODULE_PARM_DESC(nommiotrace, "Disable actual MMIO tracing.");
|
|
|
|
MODULE_PARM_DESC(trace_pc, "Record address of faulting instructions.");
|
2008-05-12 12:20:57 -07:00
|
|
|
|
|
|
|
static bool is_enabled(void)
|
|
|
|
{
|
|
|
|
return atomic_read(&mmiotrace_enabled);
|
|
|
|
}
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
static void print_pte(unsigned long address)
|
|
|
|
{
|
2008-05-12 12:21:14 -07:00
|
|
|
unsigned int level;
|
2008-05-12 12:20:56 -07:00
|
|
|
pte_t *pte = lookup_address(address, &level);
|
|
|
|
|
|
|
|
if (!pte) {
|
2008-05-12 12:20:57 -07:00
|
|
|
pr_err(NAME "Error in %s: no pte for page 0x%08lx\n",
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
__func__, address);
|
2008-05-12 12:20:56 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level == PG_LEVEL_2M) {
|
2008-05-12 12:20:57 -07:00
|
|
|
pr_emerg(NAME "4MB pages are not currently supported: "
|
|
|
|
"0x%08lx\n", address);
|
2008-05-12 12:20:56 -07:00
|
|
|
BUG();
|
|
|
|
}
|
2008-05-12 12:20:59 -07:00
|
|
|
pr_info(NAME "pte for 0x%lx: 0x%llx 0x%llx\n", address,
|
|
|
|
(unsigned long long)pte_val(*pte),
|
|
|
|
(unsigned long long)pte_val(*pte) & _PAGE_PRESENT);
|
2008-05-12 12:20:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For some reason the pre/post pairs have been called in an
|
|
|
|
* unmatched order. Report and die.
|
|
|
|
*/
|
|
|
|
static void die_kmmio_nesting_error(struct pt_regs *regs, unsigned long addr)
|
|
|
|
{
|
2008-05-12 12:20:57 -07:00
|
|
|
const struct trap_reason *my_reason = &get_cpu_var(pf_reason);
|
2008-05-12 12:20:57 -07:00
|
|
|
pr_emerg(NAME "unexpected fault for address: 0x%08lx, "
|
|
|
|
"last fault for address: 0x%08lx\n",
|
2008-05-12 12:20:57 -07:00
|
|
|
addr, my_reason->addr);
|
2008-05-12 12:20:56 -07:00
|
|
|
print_pte(addr);
|
2008-05-12 12:20:57 -07:00
|
|
|
print_symbol(KERN_EMERG "faulting IP is at %s\n", regs->ip);
|
|
|
|
print_symbol(KERN_EMERG "last faulting IP was at %s\n", my_reason->ip);
|
2008-05-12 12:20:56 -07:00
|
|
|
#ifdef __i386__
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
pr_emerg("eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n",
|
2008-05-12 12:20:56 -07:00
|
|
|
regs->ax, regs->bx, regs->cx, regs->dx);
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
pr_emerg("esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n",
|
2008-05-12 12:20:56 -07:00
|
|
|
regs->si, regs->di, regs->bp, regs->sp);
|
|
|
|
#else
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
pr_emerg("rax: %016lx rcx: %016lx rdx: %016lx\n",
|
2008-05-12 12:20:56 -07:00
|
|
|
regs->ax, regs->cx, regs->dx);
|
x86: mmiotrace full patch, preview 1
kmmio.c handles the list of mmio probes with callbacks, list of traced
pages, and attaching into the page fault handler and die notifier. It
arms, traps and disarms the given pages, this is the core of mmiotrace.
mmio-mod.c is a user interface, hooking into ioremap functions and
registering the mmio probes. It also decodes the required information
from trapped mmio accesses via the pre and post callbacks in each probe.
Currently, hooking into ioremap functions works by redefining the symbols
of the target (binary) kernel module, so that it calls the traced
versions of the functions.
The most notable changes done since the last discussion are:
- kmmio.c is a built-in, not part of the module
- direct call from fault.c to kmmio.c, removing all dynamic hooks
- prepare for unregistering probes at any time
- make kmmio re-initializable and accessible to more than one user
- rewrite kmmio locking to remove all spinlocks from page fault path
Can I abuse call_rcu() like I do in kmmio.c:unregister_kmmio_probe()
or is there a better way?
The function called via call_rcu() itself calls call_rcu() again,
will this work or break? There I need a second grace period for RCU
after the first grace period for page faults.
Mmiotrace itself (mmio-mod.c) is still a module, I am going to attack
that next. At some point I will start looking into how to make mmiotrace
a tracer component of ftrace (thanks for the hint, Ingo). Ftrace should
make the user space part of mmiotracing as simple as
'cat /debug/trace/mmio > dump.txt'.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
pr_emerg("rsi: %016lx rdi: %016lx rbp: %016lx rsp: %016lx\n",
|
2008-05-12 12:20:56 -07:00
|
|
|
regs->si, regs->di, regs->bp, regs->sp);
|
|
|
|
#endif
|
2008-05-12 12:20:57 -07:00
|
|
|
put_cpu_var(pf_reason);
|
2008-05-12 12:20:56 -07:00
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pre(struct kmmio_probe *p, struct pt_regs *regs,
|
|
|
|
unsigned long addr)
|
|
|
|
{
|
2008-05-12 12:20:57 -07:00
|
|
|
struct trap_reason *my_reason = &get_cpu_var(pf_reason);
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
struct mmiotrace_rw *my_trace = &get_cpu_var(cpu_trace);
|
2008-05-12 12:20:56 -07:00
|
|
|
const unsigned long instptr = instruction_pointer(regs);
|
|
|
|
const enum reason_type type = get_ins_type(instptr);
|
2008-05-12 12:21:03 -07:00
|
|
|
struct remap_trace *trace = p->private;
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
/* it doesn't make sense to have more than one active trace per cpu */
|
2008-05-12 12:20:57 -07:00
|
|
|
if (my_reason->active_traces)
|
2008-05-12 12:20:56 -07:00
|
|
|
die_kmmio_nesting_error(regs, addr);
|
|
|
|
else
|
2008-05-12 12:20:57 -07:00
|
|
|
my_reason->active_traces++;
|
2008-05-12 12:20:56 -07:00
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
my_reason->type = type;
|
|
|
|
my_reason->addr = addr;
|
|
|
|
my_reason->ip = instptr;
|
2008-05-12 12:20:56 -07:00
|
|
|
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
my_trace->phys = addr - trace->probe.addr + trace->phys;
|
|
|
|
my_trace->map_id = trace->id;
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Only record the program counter when requested.
|
|
|
|
* It may taint clean-room reverse engineering.
|
|
|
|
*/
|
|
|
|
if (trace_pc)
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
my_trace->pc = instptr;
|
2008-05-12 12:20:56 -07:00
|
|
|
else
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
my_trace->pc = 0;
|
2008-05-12 12:20:56 -07:00
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
/*
|
|
|
|
* XXX: the timestamp recorded will be *after* the tracing has been
|
|
|
|
* done, not at the time we hit the instruction. SMP implications
|
|
|
|
* on event ordering?
|
|
|
|
*/
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case REG_READ:
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
my_trace->opcode = MMIO_READ;
|
|
|
|
my_trace->width = get_ins_mem_width(instptr);
|
2008-05-12 12:20:56 -07:00
|
|
|
break;
|
|
|
|
case REG_WRITE:
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
my_trace->opcode = MMIO_WRITE;
|
|
|
|
my_trace->width = get_ins_mem_width(instptr);
|
|
|
|
my_trace->value = get_ins_reg_val(instptr, regs);
|
2008-05-12 12:20:56 -07:00
|
|
|
break;
|
|
|
|
case IMM_WRITE:
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
my_trace->opcode = MMIO_WRITE;
|
|
|
|
my_trace->width = get_ins_mem_width(instptr);
|
|
|
|
my_trace->value = get_ins_imm_val(instptr);
|
2008-05-12 12:20:56 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
unsigned char *ip = (unsigned char *)instptr;
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
my_trace->opcode = MMIO_UNKNOWN_OP;
|
|
|
|
my_trace->width = 0;
|
|
|
|
my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
|
2008-05-12 12:20:57 -07:00
|
|
|
*(ip + 2);
|
2008-05-12 12:20:56 -07:00
|
|
|
}
|
|
|
|
}
|
2008-05-12 12:20:57 -07:00
|
|
|
put_cpu_var(cpu_trace);
|
|
|
|
put_cpu_var(pf_reason);
|
2008-05-12 12:20:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void post(struct kmmio_probe *p, unsigned long condition,
|
|
|
|
struct pt_regs *regs)
|
|
|
|
{
|
2008-05-12 12:20:57 -07:00
|
|
|
struct trap_reason *my_reason = &get_cpu_var(pf_reason);
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
struct mmiotrace_rw *my_trace = &get_cpu_var(cpu_trace);
|
2008-05-12 12:20:56 -07:00
|
|
|
|
|
|
|
/* this should always return the active_trace count to 0 */
|
2008-05-12 12:20:57 -07:00
|
|
|
my_reason->active_traces--;
|
|
|
|
if (my_reason->active_traces) {
|
2008-05-12 12:20:57 -07:00
|
|
|
pr_emerg(NAME "unexpected post handler");
|
2008-05-12 12:20:56 -07:00
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
switch (my_reason->type) {
|
2008-05-12 12:20:56 -07:00
|
|
|
case REG_READ:
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
my_trace->value = get_ins_reg_val(my_reason->ip, regs);
|
2008-05-12 12:20:56 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-05-12 12:20:57 -07:00
|
|
|
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
mmio_trace_rw(my_trace);
|
2008-05-12 12:20:57 -07:00
|
|
|
put_cpu_var(cpu_trace);
|
|
|
|
put_cpu_var(pf_reason);
|
2008-05-12 12:20:56 -07:00
|
|
|
}
|
|
|
|
|
2008-05-12 12:21:03 -07:00
|
|
|
static void ioremap_trace_core(resource_size_t offset, unsigned long size,
|
2008-05-12 12:20:56 -07:00
|
|
|
void __iomem *addr)
|
|
|
|
{
|
2008-05-12 12:20:57 -07:00
|
|
|
static atomic_t next_id;
|
2008-05-12 12:20:56 -07:00
|
|
|
struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
|
2008-05-12 12:21:03 -07:00
|
|
|
/* These are page-unaligned. */
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
struct mmiotrace_map map = {
|
|
|
|
.phys = offset,
|
|
|
|
.virt = (unsigned long)addr,
|
|
|
|
.len = size,
|
|
|
|
.opcode = MMIO_PROBE
|
2008-05-12 12:20:56 -07:00
|
|
|
};
|
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
if (!trace) {
|
|
|
|
pr_err(NAME "kmalloc failed in ioremap\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-12 12:20:56 -07:00
|
|
|
*trace = (struct remap_trace) {
|
|
|
|
.probe = {
|
|
|
|
.addr = (unsigned long)addr,
|
|
|
|
.len = size,
|
|
|
|
.pre_handler = pre,
|
|
|
|
.post_handler = post,
|
2008-05-12 12:21:03 -07:00
|
|
|
.private = trace
|
2008-05-12 12:20:57 -07:00
|
|
|
},
|
|
|
|
.phys = offset,
|
|
|
|
.id = atomic_inc_return(&next_id)
|
2008-05-12 12:20:56 -07:00
|
|
|
};
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
map.map_id = trace->id;
|
2008-05-12 12:20:56 -07:00
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
spin_lock_irq(&trace_lock);
|
2008-09-16 11:54:16 -07:00
|
|
|
if (!is_enabled()) {
|
|
|
|
kfree(trace);
|
2008-05-12 12:20:57 -07:00
|
|
|
goto not_enabled;
|
2008-09-16 11:54:16 -07:00
|
|
|
}
|
2008-05-12 12:20:57 -07:00
|
|
|
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
mmio_trace_mapping(&map);
|
2008-05-12 12:20:56 -07:00
|
|
|
list_add_tail(&trace->list, &trace_list);
|
|
|
|
if (!nommiotrace)
|
|
|
|
register_kmmio_probe(&trace->probe);
|
2008-05-12 12:20:57 -07:00
|
|
|
|
|
|
|
not_enabled:
|
|
|
|
spin_unlock_irq(&trace_lock);
|
2008-05-12 12:20:56 -07:00
|
|
|
}
|
|
|
|
|
2008-05-12 12:21:03 -07:00
|
|
|
void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
|
|
|
|
void __iomem *addr)
|
2008-05-12 12:20:56 -07:00
|
|
|
{
|
2008-05-12 12:20:57 -07:00
|
|
|
if (!is_enabled()) /* recheck and proper locking in *_core() */
|
2008-05-12 12:20:56 -07:00
|
|
|
return;
|
|
|
|
|
2008-05-12 12:21:03 -07:00
|
|
|
pr_debug(NAME "ioremap_*(0x%llx, 0x%lx) = %p\n",
|
|
|
|
(unsigned long long)offset, size, addr);
|
2008-05-12 12:20:57 -07:00
|
|
|
if ((filter_offset) && (offset != filter_offset))
|
2008-05-12 12:20:56 -07:00
|
|
|
return;
|
2008-05-12 12:20:57 -07:00
|
|
|
ioremap_trace_core(offset, size, addr);
|
2008-05-12 12:20:56 -07:00
|
|
|
}
|
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
static void iounmap_trace_core(volatile void __iomem *addr)
|
2008-05-12 12:20:56 -07:00
|
|
|
{
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
struct mmiotrace_map map = {
|
|
|
|
.phys = 0,
|
|
|
|
.virt = (unsigned long)addr,
|
|
|
|
.len = 0,
|
|
|
|
.opcode = MMIO_UNPROBE
|
2008-05-12 12:20:56 -07:00
|
|
|
};
|
|
|
|
struct remap_trace *trace;
|
|
|
|
struct remap_trace *tmp;
|
2008-05-12 12:20:57 -07:00
|
|
|
struct remap_trace *found_trace = NULL;
|
|
|
|
|
|
|
|
pr_debug(NAME "Unmapping %p.\n", addr);
|
2008-05-12 12:20:56 -07:00
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
spin_lock_irq(&trace_lock);
|
|
|
|
if (!is_enabled())
|
|
|
|
goto not_enabled;
|
|
|
|
|
2008-05-12 12:20:56 -07:00
|
|
|
list_for_each_entry_safe(trace, tmp, &trace_list, list) {
|
|
|
|
if ((unsigned long)addr == trace->probe.addr) {
|
|
|
|
if (!nommiotrace)
|
|
|
|
unregister_kmmio_probe(&trace->probe);
|
|
|
|
list_del(&trace->list);
|
2008-05-12 12:20:57 -07:00
|
|
|
found_trace = trace;
|
2008-05-12 12:20:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
ftrace: mmiotrace, updates
here is a patch that makes mmiotrace work almost well within the tracing
framework. The patch applies on top of my previous patch. I have my own
output formatting in place now.
Summary of changes:
- fix the NULL dereference that was due to not calling tracing_reset()
- add print_line() callback into struct tracer
- implement print_line() for mmiotrace, producing up-to-spec text
- add my output header, but that is not really called in the right place
- rewrote the main structs in mmiotrace
- added two new trace entry types: TRACE_MMIO_RW and TRACE_MMIO_MAP
- made some functions in trace.c non-static
- check current==NULL in tracing_generic_entry_update()
- fix(?) comparison in trace_seq_printf()
Things seem to work fine except a few issues. Markers (text lines injected
into mmiotrace log) are missing, I did not feel hacking them in before we
have variable length entries. My output header is printed only for 'trace'
file, but not 'trace_pipe'. For some reason, despite my quick fix,
iter->trace is NULL in print_trace_line() when called from 'trace_pipe'
file, which means I don't get proper output formatting.
I only tried by loading nouveau.ko, which just detects the card, and that
is traced fine. I didn't try further. Map, two reads and unmap. Works
perfectly.
I am missing the information about overflows, I'd prefer to have a
counter for lost events. I didn't try, but I guess currently there is no
way of knowning when it overflows?
So, not too far from being fully operational, it seems :-)
And looking at the diffstat, there also is some 700-900 lines of user space
code that just became obsolete.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 12:20:57 -07:00
|
|
|
map.map_id = (found_trace) ? found_trace->id : -1;
|
|
|
|
mmio_trace_mapping(&map);
|
2008-05-12 12:20:57 -07:00
|
|
|
|
|
|
|
not_enabled:
|
|
|
|
spin_unlock_irq(&trace_lock);
|
|
|
|
if (found_trace) {
|
|
|
|
synchronize_rcu(); /* unregister_kmmio_probe() requirement */
|
|
|
|
kfree(found_trace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmiotrace_iounmap(volatile void __iomem *addr)
|
|
|
|
{
|
|
|
|
might_sleep();
|
|
|
|
if (is_enabled()) /* recheck and proper locking in *_core() */
|
|
|
|
iounmap_trace_core(addr);
|
2008-05-12 12:20:56 -07:00
|
|
|
}
|
|
|
|
|
2008-09-16 12:00:34 -07:00
|
|
|
int mmiotrace_printk(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
va_list args;
|
|
|
|
unsigned long flags;
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&trace_lock, flags);
|
|
|
|
if (is_enabled())
|
|
|
|
ret = mmio_trace_printk(fmt, args);
|
|
|
|
spin_unlock_irqrestore(&trace_lock, flags);
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mmiotrace_printk);
|
|
|
|
|
2008-05-12 12:20:56 -07:00
|
|
|
static void clear_trace_list(void)
|
|
|
|
{
|
|
|
|
struct remap_trace *trace;
|
|
|
|
struct remap_trace *tmp;
|
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
/*
|
|
|
|
* No locking required, because the caller ensures we are in a
|
|
|
|
* critical section via mutex, and is_enabled() is false,
|
|
|
|
* i.e. nothing can traverse or modify this list.
|
|
|
|
* Caller also ensures is_enabled() cannot change.
|
|
|
|
*/
|
|
|
|
list_for_each_entry(trace, &trace_list, list) {
|
|
|
|
pr_notice(NAME "purging non-iounmapped "
|
2008-05-12 12:20:56 -07:00
|
|
|
"trace @0x%08lx, size 0x%lx.\n",
|
|
|
|
trace->probe.addr, trace->probe.len);
|
|
|
|
if (!nommiotrace)
|
|
|
|
unregister_kmmio_probe(&trace->probe);
|
2008-05-12 12:20:57 -07:00
|
|
|
}
|
|
|
|
synchronize_rcu(); /* unregister_kmmio_probe() requirement */
|
|
|
|
|
|
|
|
list_for_each_entry_safe(trace, tmp, &trace_list, list) {
|
2008-05-12 12:20:56 -07:00
|
|
|
list_del(&trace->list);
|
|
|
|
kfree(trace);
|
2008-05-12 12:20:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-12 12:21:02 -07:00
|
|
|
#ifdef CONFIG_HOTPLUG_CPU
|
|
|
|
static cpumask_t downed_cpus;
|
|
|
|
|
|
|
|
static void enter_uniprocessor(void)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
get_online_cpus();
|
|
|
|
downed_cpus = cpu_online_map;
|
|
|
|
cpu_clear(first_cpu(cpu_online_map), downed_cpus);
|
|
|
|
if (num_online_cpus() > 1)
|
|
|
|
pr_notice(NAME "Disabling non-boot CPUs...\n");
|
|
|
|
put_online_cpus();
|
|
|
|
|
|
|
|
for_each_cpu_mask(cpu, downed_cpus) {
|
|
|
|
err = cpu_down(cpu);
|
2008-05-12 12:21:03 -07:00
|
|
|
if (!err)
|
2008-05-12 12:21:02 -07:00
|
|
|
pr_info(NAME "CPU%d is down.\n", cpu);
|
2008-05-12 12:21:03 -07:00
|
|
|
else
|
2008-05-12 12:21:02 -07:00
|
|
|
pr_err(NAME "Error taking CPU%d down: %d\n", cpu, err);
|
|
|
|
}
|
|
|
|
if (num_online_cpus() > 1)
|
|
|
|
pr_warning(NAME "multiple CPUs still online, "
|
|
|
|
"may miss events.\n");
|
|
|
|
}
|
|
|
|
|
2008-08-20 12:07:47 -07:00
|
|
|
/* __ref because leave_uniprocessor calls cpu_up which is __cpuinit,
|
|
|
|
but this whole function is ifdefed CONFIG_HOTPLUG_CPU */
|
|
|
|
static void __ref leave_uniprocessor(void)
|
2008-05-12 12:21:02 -07:00
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (cpus_weight(downed_cpus) == 0)
|
|
|
|
return;
|
|
|
|
pr_notice(NAME "Re-enabling CPUs...\n");
|
|
|
|
for_each_cpu_mask(cpu, downed_cpus) {
|
|
|
|
err = cpu_up(cpu);
|
|
|
|
if (!err)
|
|
|
|
pr_info(NAME "enabled CPU%d.\n", cpu);
|
|
|
|
else
|
|
|
|
pr_err(NAME "cannot re-enable CPU%d: %d\n", cpu, err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* !CONFIG_HOTPLUG_CPU */
|
|
|
|
static void enter_uniprocessor(void)
|
|
|
|
{
|
|
|
|
if (num_online_cpus() > 1)
|
|
|
|
pr_warning(NAME "multiple CPUs are online, may miss events. "
|
|
|
|
"Suggest booting with maxcpus=1 kernel argument.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void leave_uniprocessor(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
void enable_mmiotrace(void)
|
2008-05-12 12:20:57 -07:00
|
|
|
{
|
|
|
|
mutex_lock(&mmiotrace_mutex);
|
|
|
|
if (is_enabled())
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (nommiotrace)
|
|
|
|
pr_info(NAME "MMIO tracing disabled.\n");
|
2008-05-12 12:21:02 -07:00
|
|
|
enter_uniprocessor();
|
2008-05-12 12:20:57 -07:00
|
|
|
spin_lock_irq(&trace_lock);
|
|
|
|
atomic_inc(&mmiotrace_enabled);
|
|
|
|
spin_unlock_irq(&trace_lock);
|
|
|
|
pr_info(NAME "enabled.\n");
|
|
|
|
out:
|
|
|
|
mutex_unlock(&mmiotrace_mutex);
|
|
|
|
}
|
|
|
|
|
2008-05-12 12:20:57 -07:00
|
|
|
void disable_mmiotrace(void)
|
2008-05-12 12:20:57 -07:00
|
|
|
{
|
|
|
|
mutex_lock(&mmiotrace_mutex);
|
|
|
|
if (!is_enabled())
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
spin_lock_irq(&trace_lock);
|
|
|
|
atomic_dec(&mmiotrace_enabled);
|
|
|
|
BUG_ON(is_enabled());
|
|
|
|
spin_unlock_irq(&trace_lock);
|
|
|
|
|
|
|
|
clear_trace_list(); /* guarantees: no more kmmio callbacks */
|
2008-05-12 12:21:02 -07:00
|
|
|
leave_uniprocessor();
|
2008-05-12 12:20:57 -07:00
|
|
|
pr_info(NAME "disabled.\n");
|
|
|
|
out:
|
|
|
|
mutex_unlock(&mmiotrace_mutex);
|
2008-05-12 12:20:56 -07:00
|
|
|
}
|