static struct dentry *us_manager_dir = NULL;
+/**
+ * @brief Destroy debugfs for us_manager
+ *
+ * @return Void
+ */
void exit_debugfs_us_manager(void)
{
if (us_manager_dir)
us_manager_dir = NULL;
}
+/**
+ * @brief Create debugfs for us_manager
+ *
+ * @return Error code
+ */
int init_debugfs_us_manager(void)
{
struct dentry *swap_dir, *dentry;
#ifndef __DEBUGFS_US_MANAGER_H__
#define __DEBUGFS_US_MANAGER_H__
+/**
+ * @file us_manager/debugfs_us_manager.h
+ * @author Alexander Aksenov <a.aksenov@samsung.com>
+ *
+ * @section LICENSE
+ * 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.
+ *
+ * @section COPYRIGHT
+ * Copyright (C) Samsung Electronics, 2014
+ */
+
+/**
+ * @def US_MANAGER_DFS_DIR @hideinitializer
+ * Name in debugfs
+ */
#define US_MANAGER_DFS_DIR "us_manager"
+
+/**
+ * @def US_MANAGER_DFS_DIR @hideinitializer
+ * Name in debugfs
+ */
#define US_MANAGER_TASKS "tasks"
int init_debugfs_us_manager(void);
+/**
+ * @brief Registration of helper
+ *
+ * @return Error code
+ */
int register_helper(void)
{
int ret = 0;
return ret;
}
+/**
+ * @brief Unegistration of helper bottom
+ *
+ * @return Void
+ */
void unregister_helper_top(void)
{
#ifdef CONFIG_ARM
atomic_set(&stop_flag, 1);
}
+/**
+ * @brief Unegistration of helper top
+ *
+ * @return Void
+ */
void unregister_helper_bottom(void)
{
unregister_mmap();
unregister_comm();
}
+/**
+ * @brief Initialization of helper
+ *
+ * @return Error code
+ */
int init_helper(void)
{
unsigned long addr;
return 0;
}
+/**
+ * @brief Uninitialization of helper
+ *
+ * @return Void
+ */
void uninit_helper(void)
{
}
-/*
- * SWAP uprobe manager
- * modules/us_manager/helper.h
+/**
+ * @file us_manager/helper.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
#ifndef _HELPER_H
static void img_del_ip_by_list(struct img_ip *ip);
+/**
+ * @brief Create img_file struct
+ *
+ * @param dentry Dentry of file
+ * @return Pointer to the created img_file struct
+ */
struct img_file *create_img_file(struct dentry *dentry)
{
struct img_file *file;
return file;
}
+/**
+ * @brief Remove img_file struct
+ *
+ * @param file remove object
+ * @return Void
+ */
void free_img_file(struct img_file *file)
{
struct img_ip *ip, *tmp;
return NULL;
}
+/**
+ * @brief Add instrumentation pointer
+ *
+ * @param file Pointer to the img_file struct
+ * @param addr Function address
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Error code
+ */
int img_file_add_ip(struct img_file *file, unsigned long addr,
const char *args, char ret_type)
{
return 0;
}
+/**
+ * @brief Delete img_ip struct from img_file struct
+ *
+ * @param file Pointer to the img_file struct
+ * @param addr Function address
+ * @return Error code
+ */
int img_file_del_ip(struct img_file *file, unsigned long addr)
{
struct img_ip *ip;
return 0;
}
+/**
+ * @brief Check on absence img_ip structs in img_file struct
+ *
+ * @param file Pointer to the img_file struct
+ * @return
+ * - 0 - not empty
+ * - 1 - empty
+ */
int img_file_empty(struct img_file *file)
{
return list_empty(&file->ip_list);
}
+/**
+ * @brief For debug
+ *
+ * @param file Pointer to the img_file struct
+ * @return Void
+ */
+
/* debug */
void img_file_print(struct img_file *file)
{
-/*
- * SWAP uprobe manager
- * modules/us_manager/img/img_file.h
+/**
+ * @file us_manager/img/img_file.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
*
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
#include <linux/types.h>
+/**
+ * @struct img_file
+ * @breaf Image of file
+ */
struct img_file {
- struct list_head list; /* for img_proc */
- struct dentry *dentry;
- struct list_head ip_list; /* for img_ip */
+ struct list_head list; /**< For img_proc */
+ struct dentry *dentry; /**< Dentry of file */
+ struct list_head ip_list; /**< For img_ip */
};
struct img_file *create_img_file(struct dentry *dentry);
#include "img_ip.h"
#include <linux/slab.h>
+/**
+ * @brief Create img_ip struct
+ *
+ * @param addr Function address
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Pointer to the created img_ip struct
+ */
struct img_ip *create_img_ip(unsigned long addr, const char *args,
char ret_type)
{
return ip;
}
+/**
+ * @brief Remove img_ip struct
+ *
+ * @param ip remove object
+ * @return Void
+ */
void free_img_ip(struct img_ip *ip)
{
kfree(ip->args);
kfree(ip);
}
+/**
+ * @brief For debug
+ *
+ * @param ip Pointer to the img_ip struct
+ * @return Void
+ */
+
/* debug */
void img_ip_print(struct img_ip *ip)
{
-/*
- * SWAP uprobe manager
- * modules/us_manager/img/img_ip.h
+/**
+ * @file us_manager/img/img_ip.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
*
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
#include <linux/types.h>
+/**
+ * @struct img_ip
+ * @breaf Image of instrumentation pointer
+ */
struct img_ip {
- struct list_head list; /* for img_file */
- unsigned long addr;
- char *args;
- char ret_type;
+ struct list_head list; /**< For img_file */
+ unsigned long addr; /**< Function address */
+ char *args; /**< Function arguments */
+ char ret_type; /**< Return type */
};
struct img_ip *create_img_ip(unsigned long addr, const char *args,
static void img_del_file_by_list(struct img_file *file);
+/**
+ * @brief Create img_proc struct
+ *
+ * @return Pointer to the created img_proc struct
+ */
struct img_proc *create_img_proc(void)
{
struct img_proc *proc;
return proc;
}
+/**
+ * @brief Remove img_proc struct
+ *
+ * @param file remove object
+ * @return Void
+ */
void free_img_proc(struct img_proc *ip)
{
struct img_file *file, *tmp;
return NULL;
}
+/**
+ * @brief Add instrumentation pointer
+ *
+ * @param proc Pointer to the img_proc struct
+ * @param dentry Dentry of file
+ * @param addr Function address
+ * @param args Function address
+ * @param ret_type Return type
+ * @return Error code
+ */
int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry,
unsigned long addr, const char *args, char ret_type)
{
return ret;
}
+/**
+ * @brief Remove instrumentation pointer
+ *
+ * @param proc Pointer to the img_proc struct
+ * @param dentry Dentry of file
+ * @param args Function address
+ * @return Error code
+ */
int img_proc_del_ip(struct img_proc *proc, struct dentry *dentry, unsigned long addr)
{
int ret;
return ret;
}
+/**
+ * @brief For debug
+ *
+ * @param proc Pointer to the img_proc struct
+ * @return Void
+ */
+
/* debug */
void img_proc_print(struct img_proc *proc)
{
-/*
- * SWAP uprobe manager
- * modules/us_manager/img_proc.h
+/**
+ * @file us_manager/img/img_proc.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENCE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
struct dentry;
+/**
+ * @struct img_proc
+ * @breaf Image of process
+ */
struct img_proc {
- struct list_head file_list;
+ struct list_head file_list; /**< For img_file */
};
struct img_proc *create_img_proc(void);
list_del(&pfg->list);
}
+/**
+ * @brief Get pf_group struct by dentry
+ *
+ * @param dentry Dentry of file
+ * @param priv Private data
+ * @return Pointer on pf_group struct
+ */
struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv)
{
struct pf_group *pfg;
}
EXPORT_SYMBOL_GPL(get_pf_group_by_dentry);
+/**
+ * @brief Get pf_group struct by TGID
+ *
+ * @param tgid Thread group ID
+ * @param priv Private data
+ * @return Pointer on pf_group struct
+ */
struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv)
{
struct pf_group *pfg;
}
EXPORT_SYMBOL_GPL(get_pf_group_by_tgid);
+/**
+ * @brief Get pf_group struct for each process
+ *
+ * @param priv Private data
+ * @return Pointer on pf_group struct
+ */
struct pf_group *get_pf_group_dumb(void *priv)
{
struct pf_group *pfg;
}
EXPORT_SYMBOL_GPL(get_pf_group_dumb);
+/**
+ * @brief Put pf_group struct
+ *
+ * @param pfg Pointer to the pf_group struct
+ * @return Void
+ */
void put_pf_group(struct pf_group *pfg)
{
}
+/**
+ * @brief Register prober for pf_grpup struct
+ *
+ * @param pfg Pointer to the pf_group struct
+ * @param dentry Dentry of file
+ * @param offset Function offset
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Error code
+ */
int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
unsigned long offset, const char *args, char ret_type)
{
}
EXPORT_SYMBOL_GPL(pf_register_probe);
+/**
+ * @brief Unregister prober from pf_grpup struct
+ *
+ * @param pfg Pointer to the pf_group struct
+ * @param dentry Dentry of file
+ * @param offset Function offset
+ * @return Error code
+ */
int pf_unregister_probe(struct pf_group *pfg, struct dentry *dentry,
unsigned long offset)
{
}
EXPORT_SYMBOL_GPL(pf_unregister_probe);
+/**
+ * @brief Check the task, to meet the filter criteria
+ *
+ * @prarm task Pointer on the task_struct struct
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int check_task_on_filters(struct task_struct *task)
{
struct pf_group *pfg;
return 0;
}
+/**
+ * @brief Check task and install probes on demand
+ *
+ * @prarm task Pointer on the task_struct struct
+ * @param page_addr Page fault address
+ * @return Void
+ */
void call_page_fault(struct task_struct *task, unsigned long page_addr)
{
struct pf_group *pfg, *pfg_first = NULL;
}
}
+/**
+ * @brief Uninstall probes from the sspt_proc struct
+ *
+ * @prarm proc Pointer on the sspt_proc struct
+ * @return Void
+ */
+
/* called with sspt_proc_write_lock() */
void uninstall_proc(struct sspt_proc *proc)
{
sspt_proc_free(proc);
}
+/**
+ * @brief Remove probes from the task on demand
+ *
+ * @prarm task Pointer on the task_struct struct
+ * @return Void
+ */
void call_mm_release(struct task_struct *task)
{
struct sspt_proc *proc;
sspt_proc_write_unlock();
}
+/**
+ * @brief Legacy code, it is need remove
+ *
+ * @param addr Page address
+ * @return Void
+ */
void uninstall_page(unsigned long addr)
{
}
+/**
+ * @brief Install probes on running processes
+ *
+ * @return Void
+ */
void install_all(void)
{
#if !defined(CONFIG_ARM)
uninstall_proc(proc);
}
+/**
+ * @brief Uninstall probes from all processes
+ *
+ * @return Void
+ */
void uninstall_all(void)
{
sspt_proc_write_lock();
clean_pfg();
}
+/**
+ * @brief For debug
+ *
+ * @param pfg Pointer to the pf_group struct
+ * @return Void
+ */
+
/* debug */
void pfg_print(struct pf_group *pfg)
{
-/*
- * SWAP uprobe manager
- * modules/us_manager/pf/pf_group.h
+/**
+ * @file us_manager/pf/pf_group.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
return task;
}
+/**
+ * @brief Filling pf_group struct by dentry
+ *
+ * @param pf Pointer to the proc_filter struct
+ * @param dentry Dentry
+ * @param priv Private data
+ * @return Void
+ */
void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry, void *priv)
{
pf->call = &call_by_dentry;
pf->priv = priv;
}
+/**
+ * @brief Filling pf_group struct by TGID
+ *
+ * @param pf Pointer to the proc_filter struct
+ * @param tgid Thread group ID
+ * @param priv Private data
+ * @return Void
+ */
void set_pf_by_tgid(struct proc_filter *pf, pid_t tgid, void *priv)
{
pf->call = &call_by_tgid;
pf->priv = priv;
}
+/**
+ * @brief Filling pf_group struct for each process
+ *
+ * @param pf Pointer to the proc_filter struct
+ * @param priv Private data
+ * @return Void
+ */
void set_pf_dumb(struct proc_filter *pf, void *priv)
{
pf->call = &call_dumb;
pf->priv = priv;
}
+/**
+ * @brief Check pf_group struct by dentry
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @param dentry Dentry
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int check_pf_by_dentry(struct proc_filter *filter, struct dentry *dentry)
{
return filter->data == (void *)dentry &&
filter->call == &call_by_dentry;
}
+/**
+ * @brief Check pf_group struct by TGID
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @param tgid Thread group ID
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int check_pf_by_tgid(struct proc_filter *filter, pid_t tgid)
{
return filter->data == (void *)tgid && filter->call == &call_by_tgid;
}
+/**
+ * @brief Dumb check always true if filter is a dumb one
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int check_pf_dumb(struct proc_filter *filter)
{
return filter->call == &call_dumb;
}
+/**
+ * @brief Get dentry from pf_group struct if it filter by dentry
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @return Pointer to the dentry struct or NULL
+ */
struct dentry *get_dentry_by_pf(struct proc_filter *filter)
{
if (filter->call == &call_by_dentry)
-/*
- * SWAP uprobe manager
- * modules/us_manager/pf/proc_filters.h
+/**
+ * @file us_manager/pf/proc_filters.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
struct dentry;
struct task_struct;
+/**
+ * @struct proc_filter
+ * @breaf Filter for process
+ */
struct proc_filter {
+ /** Callback for filtering */
struct task_struct *(*call)(struct proc_filter *self,
struct task_struct *task);
- void *data;
- void *priv;
+ void *data; /**< Data of callback */
+ void *priv; /**< Private data */
};
+/**
+ * @def check_task_f @hideinitializer
+ * Call filter on the task
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @param task Pointer to the task_struct struct
+ */
#define check_task_f(filter, task) (filter)->call(filter, task)
void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry,
return 0;
}
+/**
+ * @brief Create us_ip struct
+ *
+ * @param offset Function offset from the beginning of the page
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Pointer to the created us_ip struct
+ */
struct us_ip *create_ip(unsigned long offset, const char *args, char ret_type)
{
size_t len = strlen(args) + 1;
return ip;
}
+/**
+ * @brief Remove us_ip struct
+ *
+ * @param ip remove object
+ * @return Void
+ */
void free_ip(struct us_ip *ip)
{
kfree(ip);
#ifndef __IP__
#define __IP__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/driver/sspt/ip.h
+/**
+ * @file us_manager/sspt/ip.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
#include <linux/list.h>
struct sspt_page;
+/**
+ * @struct us_ip
+ * @breaf Image of instrumentation pointer for specified process
+ */
struct us_ip {
- struct list_head list;
- struct sspt_page *page;
+ struct list_head list; /**< For sspt_page */
+ struct sspt_page *page; /**< Pointer on the page (parent) */
- struct uretprobe retprobe;
- char *args;
- char ret_type;
- unsigned long orig_addr;
+ struct uretprobe retprobe; /**< uretprobe */
+ char *args; /**< Function arguments */
+ char ret_type; /**< Return type */
+ unsigned long orig_addr; /**< Function address */
- unsigned long offset;
+ unsigned long offset; /**< Page offset */
};
kfree(fd);
}
+/**
+ * @brief Create sspt_feature struct
+ *
+ * @return Pointer to the created sspt_feature struct
+ */
struct sspt_feature *sspt_create_feature(void)
{
struct sspt_feature *f;
return f;
}
+/**
+ * @brief Destroy sspt_feature struct
+ *
+ * @param f remove object
+ * @return Void
+ */
void sspt_destroy_feature(struct sspt_feature *f)
{
struct sspt_feature_data *fd, *n;
del_feature_by_img(proc->feature, (struct sspt_feature_img *)data);
}
+/**
+ * @brief Get data for feature
+ *
+ * @param f Pointer to the sspt_feature struct
+ * @param id Feature ID
+ * @return Pointer to the data
+ */
void *sspt_get_feature_data(struct sspt_feature *f, sspt_feature_id_t id)
{
struct sspt_feature_img *img = (struct sspt_feature_img *)id;
}
EXPORT_SYMBOL_GPL(sspt_get_feature_data);
+/**
+ * @brief Register sspt feature
+ *
+ * @param alloc Callback for allocating data
+ * @param free Callback to release data
+ * @return Feature ID
+ */
sspt_feature_id_t sspt_register_feature(void *(*alloc)(void), void (*free)(void *data))
{
struct sspt_feature_img *fi;
}
EXPORT_SYMBOL_GPL(sspt_register_feature);
+/**
+ * @brief Unregister sspt feature
+ *
+ * @param id Feature ID
+ * @return Void
+ */
void sspt_unregister_feature(sspt_feature_id_t id)
{
struct sspt_feature_img *fi = (struct sspt_feature_img *)id;
#ifndef _SSPT_FEATUER_H
#define _SSPT_FEATUER_H
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/us_manager/sspt/sspt_feature.h
+/**
+ * @file us_manager/sspt/sspt_feature.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
struct sspt_feature;
-typedef void * sspt_feature_id_t;
-#define SSPT_FEATURE_ID_BAD NULL
+typedef void * sspt_feature_id_t; /**< @brief sspt feature ID type */
+#define SSPT_FEATURE_ID_BAD NULL /**< @def SSPT_FEATURE_ID_BAD */
struct sspt_feature *sspt_create_feature(void);
void sspt_destroy_feature(struct sspt_feature *f);
return bits;
}
+/**
+ * @brief Create sspt_file struct
+ *
+ * @param dentry Dentry of file
+ * @param page_cnt Size of hash-table
+ * @return Pointer to the created sspt_file struct
+ */
struct sspt_file *sspt_file_create(struct dentry *dentry, int page_cnt)
{
struct sspt_file *obj = kmalloc(sizeof(*obj), GFP_ATOMIC);
return obj;
}
+/**
+ * @brief Remove sspt_file struct
+ *
+ * @param file remove object
+ * @return Void
+ */
void sspt_file_free(struct sspt_file *file)
{
struct hlist_head *head;
return page;
}
+/**
+ * @brief Get sspt_page from sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param page Page address
+ * @return Pointer to the sspt_page struct
+ */
struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, unsigned long page)
{
unsigned long offset;
return sspt_find_page(file, offset);
}
+/**
+ * @brief Add instruction pointer to sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param offset File offset
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Void
+ */
void sspt_file_add_ip(struct sspt_file *file, unsigned long offset,
const char *args, char ret_type)
{
sspt_add_ip(page, ip);
}
+/**
+ * @brief Get sspt_page from sspt_file (look)
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param offset_addr File offset
+ * @return Pointer to the sspt_page struct
+ */
struct sspt_page *sspt_get_page(struct sspt_file *file, unsigned long offset_addr)
{
unsigned long offset = offset_addr & PAGE_MASK;
return page;
}
+/**
+ * @brief Put sspt_page (unlook)
+ *
+ * @param file Pointer to the sspt_page struct
+ * @return void
+ */
void sspt_put_page(struct sspt_page *page)
{
spin_unlock(&page->lock);
}
+/**
+ * @brief Check install sspt_file (legacy code, it is need remove)
+ *
+ * @param file Pointer to the sspt_file struct
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int sspt_file_check_install_pages(struct sspt_file *file)
{
int i, table_size;
return 0;
}
+/**
+ * @brief Install sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @return Void
+ */
void sspt_file_install(struct sspt_file *file)
{
struct sspt_page *page = NULL;
}
}
+/**
+ * @brief Uninstall sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param task Pointer to the task_stract struct
+ * @param flag Action for probes
+ * @return Void
+ */
int sspt_file_uninstall(struct sspt_file *file, struct task_struct *task, enum US_FLAGS flag)
{
int i, err = 0;
return err;
}
+/**
+ * @brief Set mapping for sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param vma Pointer to the vm_area_struct struct
+ * @return Void
+ */
void sspt_file_set_mapping(struct sspt_file *file, struct vm_area_struct *vma)
{
file->vm_start = vma->vm_start;
#ifndef __SSPT_FILE__
#define __SSPT_FILE__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/driver/sspt/sspt_file.h
+/**
+ * @file us_manager/sspt/sspt_file.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
#include "ip.h"
enum US_FLAGS;
struct vm_area_struct;
+/**
+ * @struct sspt_file
+ * @breaf Image of file for specified process
+ */
struct sspt_file {
- struct list_head list; // for proc_probes
- struct sspt_proc *proc;
- struct dentry *dentry;
- int loaded;
- unsigned long vm_start;
- unsigned long vm_end;
-
- unsigned long page_probes_hash_bits;
- struct hlist_head *page_probes_table; // for page_probes
+ struct list_head list; /**< For sspt_proc */
+ struct sspt_proc *proc; /**< Pointer to the proc (parent) */
+ struct dentry *dentry; /**< Dentry of file */
+ int loaded; /**< Flag of loading */
+ unsigned long vm_start; /**< VM start */
+ unsigned long vm_end; /**< VM end */
+
+ unsigned long page_probes_hash_bits; /**< Hash-table size */
+ struct hlist_head *page_probes_table; /**< Hash-table for pages */
};
#include <linux/slab.h>
#include <linux/list.h>
+/**
+ * @brief Create sspt_page struct
+ *
+ * @param offset File ofset
+ * @return Pointer to the created sspt_page struct
+ */
struct sspt_page *sspt_page_create(unsigned long offset)
{
struct sspt_page *obj = kmalloc(sizeof(*obj), GFP_ATOMIC);
return obj;
}
+/**
+ * @brief Remove sspt_page struct
+ *
+ * @param page remove object
+ * @return Void
+ */
void sspt_page_free(struct sspt_page *page)
{
struct us_ip *ip, *n;
list_del(&ip->list);
}
+/**
+ * @brief Add instruction pointer to sspt_page
+ *
+ * @param page Pointer to the sspt_page struct
+ * @param ip Pointer to the us_ip struct
+ * @return Void
+ */
void sspt_add_ip(struct sspt_page *page, struct us_ip *ip)
{
ip->offset &= ~PAGE_MASK;
sspt_list_add_ip(page, ip);
}
+/**
+ * @brief Del instruction pointer from sspt_page
+ *
+ * @param ip Pointer to the us_ip struct
+ * @return Void
+ */
void sspt_del_ip(struct us_ip *ip)
{
sspt_list_del_ip(ip);
free_ip(ip);
}
+/**
+ * @brief Check if probes are set on the page
+ *
+ * @param page Pointer to the sspt_page struct
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int sspt_page_is_installed(struct sspt_page *page)
{
int empty;
return !empty;
}
+/**
+ * @brief Install probes on the page
+ *
+ * @param page Pointer to the sspt_page struct
+ * @param file Pointer to the sspt_file struct
+ * @return Error code
+ */
int sspt_register_page(struct sspt_page *page, struct sspt_file *file)
{
int err = 0;
return 0;
}
+/**
+ * @brief Uninstall probes on the page
+ *
+ * @param page Pointer to the sspt_page struct
+ * @param flag Action for probes
+ * @param task Pointer to the task_struct struct
+ * @return Error code
+ */
int sspt_unregister_page(struct sspt_page *page,
enum US_FLAGS flag,
struct task_struct *task)
#ifndef __SSPT_PAGE__
#define __SSPT_PAGE__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/driver/sspt/sspt_page.h
+/**
+ * @file us_manager/sspt/sspt_page.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
#include <linux/types.h>
struct task_struct;
enum US_FLAGS;
+/**
+ * @struct sspt_page
+ * @breaf Image of page for specified process
+ */
struct sspt_page {
- struct list_head ip_list_inst;
- struct list_head ip_list_no_inst;
- unsigned long offset;
- spinlock_t lock;
+ struct list_head ip_list_inst; /**< For installed ip */
+ struct list_head ip_list_no_inst; /**< For don'tinstalled ip */
+ unsigned long offset; /**< File offset */
+ spinlock_t lock; /**< Lock page */
- struct sspt_file *file;
- struct hlist_node hlist; // for file_probes
+ struct sspt_file *file; /**< Ptr to the file(parent)=*/
+ struct hlist_node hlist; /**< For sspt_file */
};
struct sspt_page *sspt_page_create(unsigned long offset);
static LIST_HEAD(proc_probes_list);
static DEFINE_RWLOCK(sspt_proc_rwlock);
+/**
+ * @brief Global read lock for sspt_proc
+ *
+ * @return Void
+ */
void sspt_proc_read_lock(void)
{
read_lock(&sspt_proc_rwlock);
}
+/**
+ * @brief Global read unlock for sspt_proc
+ *
+ * @return Void
+ */
void sspt_proc_read_unlock(void)
{
read_unlock(&sspt_proc_rwlock);
}
+/**
+ * @brief Global write lock for sspt_proc
+ *
+ * @return Void
+ */
void sspt_proc_write_lock(void)
{
write_lock(&sspt_proc_rwlock);
}
+/**
+ * @brief Global write unlock for sspt_proc
+ *
+ * @return Void
+ */
void sspt_proc_write_unlock(void)
{
write_unlock(&sspt_proc_rwlock);
}
+/**
+ * @brief Create sspt_proc struct
+ *
+ * @param task Pointer to the task_struct struct
+ * @param priv Private data
+ * @return Pointer to the created sspt_proc struct
+ */
struct sspt_proc *sspt_proc_create(struct task_struct *task, void *priv)
{
struct sspt_proc *proc = kmalloc(sizeof(*proc), GFP_ATOMIC);
return proc;
}
+/**
+ * @brief Remove sspt_proc struct
+ *
+ * @param proc remove object
+ * @return Void
+ */
+
/* called with sspt_proc_write_lock() */
void sspt_proc_free(struct sspt_proc *proc)
{
kfree(proc);
}
+/**
+ * @brief Get sspt_proc by task
+ *
+ * @param task Pointer on the task_struct struct
+ * @return Pointer on the sspt_proc struct
+ */
struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task)
{
struct sspt_proc *proc, *tmp;
}
EXPORT_SYMBOL_GPL(sspt_proc_get_by_task);
+/**
+ * @brief Call func() on each proc (no lock)
+ *
+ * @param func Callback
+ * @param data Data for callback
+ * @return Void
+ */
void on_each_proc_no_lock(void (*func)(struct sspt_proc *, void *), void *data)
{
struct sspt_proc *proc, *tmp;
}
}
+/**
+ * @brief Call func() on each proc
+ *
+ * @param func Callback
+ * @param data Data for callback
+ * @return Void
+ */
void on_each_proc(void (*func)(struct sspt_proc *, void *), void *data)
{
sspt_proc_read_lock();
}
EXPORT_SYMBOL_GPL(on_each_proc);
+/**
+ * @brief Get sspt_proc by task or create sspt_proc
+ *
+ * @param task Pointer on the task_struct struct
+ * @param priv Private data
+ * @return Pointer on the sspt_proc struct
+ */
struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task,
void *priv)
{
return proc;
}
+/**
+ * @brief Free all sspt_proc
+ *
+ * @return Pointer on the sspt_proc struct
+ */
void sspt_proc_free_all(void)
{
struct sspt_proc *proc, *n;
file->proc = proc;
}
+/**
+ * @brief Get sspt_file from sspt_proc by dentry or new
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param dentry Dentry of file
+ * @return Pointer on the sspt_file struct
+ */
struct sspt_file *sspt_proc_find_file_or_new(struct sspt_proc *proc,
struct dentry *dentry)
{
return file;
}
+/**
+ * @brief Get sspt_file from sspt_proc by dentry
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param dentry Dentry of file
+ * @return Pointer on the sspt_file struct
+ */
struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, struct dentry *dentry)
{
struct sspt_file *file;
return NULL;
}
+/**
+ * @brief Install probes on the page to monitored process
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param page_addr Page address
+ * @return Void
+ */
void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr)
{
int lock, atomic;
mm_read_unlock(mm, atomic, lock);
}
+/**
+ * @brief Install probes to monitored process
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @return Void
+ */
void sspt_proc_install(struct sspt_proc *proc)
{
int lock, atomic;
mm_read_unlock(mm, atomic, lock);
}
+/**
+ * @brief Uninstall probes to monitored process
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param task Pointer on the task_struct struct
+ * @param flag Action for probes
+ * @return Error code
+ */
int sspt_proc_uninstall(struct sspt_proc *proc, struct task_struct *task, enum US_FLAGS flag)
{
int err = 0;
start_a < end_b;
}
+/**
+ * @brief Get sspt_file list by region (remove sspt_file from sspt_proc list)
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param head[out] Pointer on the head list
+ * @param start Region start
+ * @param len Region length
+ * @return Error code
+ */
int sspt_proc_get_files_by_region(struct sspt_proc *proc,
struct list_head *head,
unsigned long start, size_t len)
return ret;
}
+/**
+ * @brief Insert sspt_file to sspt_proc list
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param head Pointer on the head list
+ * @return Void
+ */
void sspt_proc_insert_files(struct sspt_proc *proc, struct list_head *head)
{
list_splice(head, &proc->file_list);
#ifndef __SSPT_PROC__
#define __SSPT_PROC__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/driver/sspt/sspt_proc.h
+/**
+ * @file us_manager/sspt/sspt_proc.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
#include <linux/types.h>
struct slot_manager;
struct task_struct;
+/** Flags for sspt_*_uninstall() */
enum US_FLAGS {
- US_UNREGS_PROBE, /* probes remove and disarm */
- US_DISARM, /* probes disarm */
- US_UNINSTALL /* probes remove from list install */
+ US_UNREGS_PROBE, /**< probes remove and disarm */
+ US_DISARM, /**< probes disarm */
+ US_UNINSTALL /**< probes remove from list install */
};
+/**
+ * @struct sspt_proc
+ * @breaf Image of process for specified process
+ */
struct sspt_proc {
- struct list_head list;
- pid_t tgid;
- struct task_struct *task;
- struct slot_manager *sm;
- struct list_head file_list;
- unsigned first_install:1;
- struct sspt_feature *feature;
+ struct list_head list; /**< For global process list */
+ pid_t tgid; /**< Thread group ID */
+ struct task_struct *task; /**< Ptr to the task */
+ struct slot_manager *sm; /**< Ptr to the manager slot */
+ struct list_head file_list; /**< For sspt_file */
+ unsigned first_install:1; /**< Install flag */
+ struct sspt_feature *feature; /**< Ptr to the feature */
};
return 0;
}
+/**
+ * @brief Get instrumentation status
+ *
+ * @return Instrumentation status
+ */
enum status_type usm_get_status(void)
{
mutex_lock(&mutex_inst);
}
EXPORT_SYMBOL_GPL(usm_get_status);
+/**
+ * @brief Put instrumentation status
+ *
+ * @param st Instrumentation status
+ * @return Void
+ */
void usm_put_status(enum status_type st)
{
status = st;
}
EXPORT_SYMBOL_GPL(usm_put_status);
+/**
+ * @brief Stop instrumentation
+ *
+ * @return Error code
+ */
int usm_stop(void)
{
int ret = 0;
}
EXPORT_SYMBOL_GPL(usm_stop);
+/**
+ * @brief Start instrumentation
+ *
+ * @return Error code
+ */
int usm_start(void)
{
int ret = -EINVAL;
*/
static enum quiet_type quiet = QT_ON;
+/**
+ * @brief Set quiet mode
+ *
+ * @param q Quiet mode
+ * @return Void
+ */
void set_quiet(enum quiet_type q)
{
quiet = q;
}
EXPORT_SYMBOL_GPL(set_quiet);
+/**
+ * @brief Get quiet mode
+ *
+ * @return Quiet mode
+ */
enum quiet_type get_quiet(void)
{
return quiet;
-/*
- * SWAP uprobe manager
- * modules/us_manager/us_manager.h
+/**
+ * @file us_manager/us_manager.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
#ifndef _US_MANAGER_H
#define _US_MANAGER_H
+/** Quiet mode */
enum quiet_type {
- QT_ON,
- QT_OFF
+ QT_ON, /**< Quiet mode - on */
+ QT_OFF /**< Quiet mode - off */
};
+/** Instrumentation status */
enum status_type {
- ST_OFF,
- ST_ON
+ ST_OFF, /**< Instrumentation status - off */
+ ST_ON /**< Instrumentation status - on */
};
void set_quiet(enum quiet_type q);
/* FIXME: implement the removal of memory for task */
}
+/**
+ * @brief Create slot_manager struct for US
+ *
+ * @param task Pointer to the task_struct struct
+ * @return Pointer to the created slot_manager struct
+ */
struct slot_manager *create_sm_us(struct task_struct *task)
{
struct slot_manager *sm = kmalloc(sizeof(*sm), GFP_ATOMIC);
return sm;
}
+/**
+ * @brief Remove slot_manager struct for US
+ *
+ * @param sm remove object
+ * @return Void
+ */
void free_sm_us(struct slot_manager *sm)
{
if (sm == NULL)
-/*
- * SWAP uprobe manager
- * modules/us_manager/us_slot_manager.h
+/**
+ * @file us_manager/us_slot_manager.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/