diff options
-rw-r--r-- | include/trace/events/nvsecurity.h | 152 | ||||
-rw-r--r-- | security/tf_driver/tf_comm_tz.c | 8 | ||||
-rw-r--r-- | security/tf_driver/tf_device.c | 7 | ||||
-rw-r--r-- | security/tf_driver/tf_util.c | 17 | ||||
-rw-r--r-- | security/tf_driver/tf_util.h | 9 |
5 files changed, 190 insertions, 3 deletions
diff --git a/include/trace/events/nvsecurity.h b/include/trace/events/nvsecurity.h new file mode 100644 index 000000000000..25e90a9f9387 --- /dev/null +++ b/include/trace/events/nvsecurity.h @@ -0,0 +1,152 @@ +/* + * include/trace/events/nvsecurity.h + * + * Security event logging to ftrace. + * + * Copyright (c) 2012, NVIDIA Corporation. + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM nvsecurity + +#if !defined(_TRACE_NVSECURITY_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_NVSECURITY_H + +#include <linux/ktime.h> +#include <linux/tracepoint.h> + +extern u32 notrace tegra_read_usec_raw(void); + +DECLARE_EVENT_CLASS(usec_profiling, + + TP_PROTO(unsigned long state), + + TP_ARGS(state), + + TP_STRUCT__entry( + __field(u32, counter) + __field(u32, state) + ), + + TP_fast_assign( + __entry->counter = tegra_read_usec_raw(); + __entry->state = state; + ), + + TP_printk("counter=%lu, state=%lu", + (unsigned long)__entry->counter, + (unsigned long)__entry->state + ) +); + +DEFINE_EVENT(usec_profiling, smc_sleep_cpu, + + TP_PROTO(unsigned long state), + + TP_ARGS(state) +); + +DEFINE_EVENT(usec_profiling, smc_sleep_core, + + TP_PROTO(unsigned long state), + + TP_ARGS(state) +); + +DEFINE_EVENT(usec_profiling, smc_init_cache, + + TP_PROTO(unsigned long state), + + TP_ARGS(state) +); + +DEFINE_EVENT(usec_profiling, smc_wake, + + TP_PROTO(unsigned long state), + + TP_ARGS(state) +); + +DEFINE_EVENT(usec_profiling, secureos_init, + + TP_PROTO(unsigned long state), + + TP_ARGS(state) +); + +extern u32 notrace tegra_read_cycle(void); + +DECLARE_EVENT_CLASS(cycle_profiling, + + TP_PROTO(unsigned long state), + + TP_ARGS(state), + + TP_STRUCT__entry( + __field(u32, counter) + __field(u32, state) + ), + + TP_fast_assign( + __entry->counter = tegra_read_cycle(); + __entry->state = state; + ), + + TP_printk("counter=%lu, state=%lu", + (unsigned long)__entry->counter, + (unsigned long)__entry->state + ) +); + +DEFINE_EVENT(cycle_profiling, invoke_client_command, + + TP_PROTO(unsigned long state), + + TP_ARGS(state) +); + +DEFINE_EVENT(cycle_profiling, smc_generic_call, + + TP_PROTO(unsigned long state), + + TP_ARGS(state) +); + +/* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */ +#ifndef _NVSEC_EVENT_AVOID_DOUBLE_DEFINING +#define _NVSEC_EVENT_AVOID_DOUBLE_DEFINING + +enum { + NVSEC_SMC_START, + NVSEC_SMC_DONE +}; + +enum { + NVSEC_INVOKE_CMD_START, + NVSEC_INVOKE_CMD_DONE +}; + +enum { + NVSEC_SUSPEND_EXIT_START, + NVSEC_SUSPEND_EXIT_DONE +}; + +#endif +#endif /* _TRACE_NVSECURITY_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h> diff --git a/security/tf_driver/tf_comm_tz.c b/security/tf_driver/tf_comm_tz.c index 4628f24f3cf2..a0e9941832f5 100644 --- a/security/tf_driver/tf_comm_tz.c +++ b/security/tf_driver/tf_comm_tz.c @@ -2,6 +2,8 @@ * Copyright (c) 2011 Trusted Logic S.A. * All Rights Reserved. * + * Copyright (C) 2011-2012 NVIDIA Corporation. + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. @@ -27,6 +29,8 @@ #include <linux/vmalloc.h> #include <linux/jiffies.h> +#include <trace/events/nvsecurity.h> + #include "tf_defs.h" #include "tf_comm.h" #include "tf_protocol.h" @@ -63,6 +67,8 @@ static inline void tf_smc_generic_call( dprintk(KERN_ERR "sched_setaffinity #1 -> 0x%lX", ret); #endif + trace_smc_generic_call(NVSEC_SMC_START); + __asm__ volatile( "mov r0, %2\n" "mov r1, %3\n" @@ -78,6 +84,8 @@ static inline void tf_smc_generic_call( "r" (generic_smc->reg4) : "r0", "r1", "r2", "r3", "r4"); + trace_smc_generic_call(NVSEC_SMC_DONE); + #ifdef CONFIG_SMP ret = sched_setaffinity(0, &saved_cpu_mask); if (ret != 0) diff --git a/security/tf_driver/tf_device.c b/security/tf_driver/tf_device.c index 1bdf5acb177d..51dbb37dbdec 100644 --- a/security/tf_driver/tf_device.c +++ b/security/tf_driver/tf_device.c @@ -2,6 +2,8 @@ * Copyright (c) 2011 Trusted Logic S.A. * All Rights Reserved. * + * Copyright (C) 2011-2012 NVIDIA Corporation. + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. @@ -46,6 +48,9 @@ #include "s_version.h" +#define CREATE_TRACE_POINTS +#include <trace/events/nvsecurity.h> + /*---------------------------------------------------------------------------- * Forward Declarations *----------------------------------------------------------------------------*/ @@ -733,8 +738,10 @@ static long tf_device_ioctl(struct file *file, unsigned int ioctl_num, break; case TF_MESSAGE_TYPE_INVOKE_CLIENT_COMMAND: + trace_invoke_client_command(NVSEC_INVOKE_CMD_START); result = tf_invoke_client_command(connection, &command, &answer); + trace_invoke_client_command(NVSEC_INVOKE_CMD_DONE); break; case TF_MESSAGE_TYPE_CANCEL_CLIENT_COMMAND: diff --git a/security/tf_driver/tf_util.c b/security/tf_driver/tf_util.c index 78f90bf677e0..936f8e16c247 100644 --- a/security/tf_driver/tf_util.c +++ b/security/tf_driver/tf_util.c @@ -2,6 +2,8 @@ * Copyright (c) 2011 Trusted Logic S.A. * All Rights Reserved. * + * Copyright (C) 2011-2012 NVIDIA Corporation. + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. @@ -21,6 +23,19 @@ #include "tf_util.h" /*---------------------------------------------------------------------------- + * Tegra-specific routines + *----------------------------------------------------------------------------*/ + +u32 notrace tegra_read_cycle(void) +{ + u32 cycle_count; + + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(cycle_count)); + + return cycle_count; +} + +/*---------------------------------------------------------------------------- * Debug printing routines *----------------------------------------------------------------------------*/ #ifdef CONFIG_TF_DRIVER_DEBUG_SUPPORT @@ -1139,5 +1154,3 @@ void internal_page_cache_release(struct page *page) page_cache_release(page); } - - diff --git a/security/tf_driver/tf_util.h b/security/tf_driver/tf_util.h index 14bc78952d86..2fabf0127a2f 100644 --- a/security/tf_driver/tf_util.h +++ b/security/tf_driver/tf_util.h @@ -2,6 +2,8 @@ * Copyright (c) 2011 Trusted Logic S.A. * All Rights Reserved. * + * Copyright (C) 2011-2012 NVIDIA Corporation. + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. @@ -35,6 +37,12 @@ #include "tf_defs.h" /*---------------------------------------------------------------------------- + * Tegra-specific routines + *----------------------------------------------------------------------------*/ + +u32 notrace tegra_read_cycle(void); + +/*---------------------------------------------------------------------------- * Debug printing routines *----------------------------------------------------------------------------*/ @@ -119,4 +127,3 @@ int internal_get_user_pages( void internal_get_page(struct page *page); void internal_page_cache_release(struct page *page); #endif /* __TF_UTIL_H__ */ - |