coresight: A DLKM to abort trace on userspace abort

A DLKM to abort tracing on an user space data, prefetch or
undefined instruction abort.

Change-Id: Iaba14628601ea6d3649e05423f8570131eea39f7
Signed-off-by: Pushkar Joshi <pushkarj@codeaurora.org>
This commit is contained in:
Pushkar Joshi 2012-09-12 14:29:23 -07:00 committed by Iliyan Malchev
parent 92bb1ac92f
commit 73c0e502b6
3 changed files with 79 additions and 0 deletions

View file

@ -116,4 +116,11 @@ config CORESIGHT_ETM_DEFAULT_ENABLE
endif
config CORESIGHT_EVENT
tristate "CoreSight Event driver"
help
This driver provides support for registering with various events
and performing CoreSight actions like aborting trace on their
occurrence.
endif

View file

@ -11,3 +11,4 @@ obj-$(CONFIG_CORESIGHT_FUNNEL) += coresight-funnel.o
obj-$(CONFIG_CORESIGHT_REPLICATOR) += coresight-replicator.o
obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o
obj-$(CONFIG_CORESIGHT_ETM) += coresight-etm.o
obj-$(CONFIG_CORESIGHT_EVENT) += control_trace.o

View file

@ -0,0 +1,71 @@
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* 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.
*/
/*
* DLKM to register a callback with a ftrace event
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/tracepoint.h>
#include <linux/coresight.h>
#include <trace/events/exception.h>
static void abort_coresight_tracing(void *ignore, struct task_struct *task,\
unsigned long addr, unsigned int fsr)
{
coresight_abort();
pr_debug("control_trace: task_name: %s, addr: %lu, fsr:%u",\
(char *)task->comm, addr, fsr);
}
static void abort_tracing_undef_instr(void *ignore, struct pt_regs *regs,\
void *pc)
{
if (user_mode(regs)) {
coresight_abort();
pr_debug("control_trace: pc: %p", pc);
}
}
static int __init control_trace_init(void)
{
int ret_user_fault, ret_undef_instr;
ret_user_fault = register_trace_user_fault(abort_coresight_tracing,\
NULL);
ret_undef_instr = register_trace_undef_instr(abort_tracing_undef_instr,\
NULL);
if (ret_user_fault != 0 || ret_undef_instr != 0) {
pr_info("control_trace: Module Not Registered\n");
return (ret_user_fault < 0 ?\
ret_user_fault : ret_undef_instr);
}
pr_info("control_trace: Module Registered\n");
return 0;
}
module_init(control_trace_init);
static void __exit control_trace_exit(void)
{
unregister_trace_user_fault(abort_coresight_tracing, NULL);
unregister_trace_undef_instr(abort_tracing_undef_instr, NULL);
pr_info("control_trace: Module Removed\n");
}
module_exit(control_trace_exit);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("Kernel Module to abort tracing");