-/*
- * SWAP kernel features
- * modules/ks_features/features_data.c
+/**
+ * ks_features/features_data.c
+ * @author Vyacheslav Cherkashin: SWAP ks_features implement
+ *
+ * @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
* 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 ks_features implement
+ * @section DESCRIPTION
*
+ * SWAP kernel features
*/
#include "syscall_list.h"
#include <linux/mutex.h>
+/**
+ * @struct feature
+ * Feature description.
+ * @var feature::cnt
+ * Syscalls count.
+ * @var feature::feature_list
+ * Pointer to feature's syscall list.
+ * @var feature::sub_type
+ * Featue subtype.
+ * @var feature::enable
+ * Is feature enable.
+ */
struct feature {
size_t cnt;
enum syscall_id *feature_list;
unsigned enable:1;
};
+/**
+ * @def X
+ * X-macros for syscall list.
+ */
#define X(name, args) id_##name
+/**
+ * @enum syscall_id
+ * Syscall list
+ */
enum syscall_id {
SYSCALL_LIST
};
id_sys_setns
};
+/**
+ * @def CREATE_FEATURE
+ * Feature initialization.
+ */
#define CREATE_FEATURE(x, subtype) \
{ \
.cnt = sizeof(x) / sizeof(enum syscall_id), \
CREATE_FEATURE(id_desc, PST_KS_DESC)
};
+/**
+ * @enum
+ * Defines feature_cnt.
+ */
enum {
feature_cnt = sizeof(features) / sizeof(struct feature)
};
-/*
- * SWAP kernel features
- * modules/ks_features/ks_features.c
+/**
+ * ks_features/ks_features.c
+ * @author Vyacheslav Cherkashin: SWAP ks_features implement
+ *
+ * @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
* 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 ks_features implement
+ * @section DESCRIPTION
*
+ * SWAP kernel features
*/
#include "syscall_list.h"
#include "features_data.c"
+/**
+ * @struct ks_probe
+ * @brief Kernel-space probe. Struct used as a container of syscall probes.
+ * @var ks_probe::rp
+ * Pointer to kretprobe.
+ * @var ks_probe::counter
+ * Installed probes counter.
+ * @var ks_probe::args
+ * Pointer to args format string.
+ * @var ks_probe::sub_type
+ * Probe sub type.
+ */
struct ks_probe {
struct kretprobe rp;
int counter;
};
#undef X
+/**
+ * @enum
+ * Syscall name count defenition
+ */
enum {
syscall_name_cnt = sizeof(syscall_name) / sizeof(char *)
};
return 0;
}
+/**
+ * @var switch_rp
+ * Kretprobe for scheduler.
+ */
struct kretprobe switch_rp = {
.entry_handler = switch_entry_handler,
.handler = switch_ret_handler
static DEFINE_MUTEX(mutex_sc_enable);
static int sc_enable = 0;
+/**
+ * @brief Get scheduler address.
+ *
+ * @return 0 on success, negative error code on error.
+ */
int init_switch_context(void)
{
unsigned long addr;
return 0;
}
+/**
+ * @brief Unregisters probe on context switching.
+ *
+ * @return Void.
+ */
void exit_switch_context(void)
{
if (sc_enable)
return &features[id];
}
+/**
+ * @brief Sets probes related to specified feature.
+ *
+ * @param id Feature id.
+ * @return 0 on success, negative error code on error.
+ */
int set_feature(enum feature_id id)
{
struct feature *f;
}
EXPORT_SYMBOL_GPL(set_feature);
+/**
+ * @brief Unsets probes related to specified feature.
+ *
+ * @param id Feature id.
+ * @return 0 on success, negative error code on error.
+ */
int unset_feature(enum feature_id id)
{
struct feature *f;
}
}
+/**
+ * @brief Prints features.
+ *
+ * @return Void.
+ */
void print_features(void)
{
int i;
}
}
+/**
+ * @brief Prints all syscalls.
+ *
+ * @return Void.
+ */
void print_all_syscall(void)
{
int i;
-/*
- * SWAP kernel features
- * modules/ks_features/ks_features.h
+/**
+ * @file ks_features/ks_features.h
+ * @author Vyacheslav Cherkashin: SWAP ks_features implement
+ *
+ * @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
* 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 ks_features implement
+ * @section DESCRIPTION
*
+ * SWAP kernel features interface declaration.
*/
#ifndef _KS_FEATURES_H
#define _KS_FEATURES_H
+/**
+ * @enum feature_id
+ * Features ids
+ */
enum feature_id {
- FID_FILE = 1,
- FID_IPC = 2,
- FID_PROCESS = 3,
- FID_SIGNAL = 4,
- FID_NET = 5,
- FID_DESC = 6,
- FID_SWITCH = 7
+ FID_FILE = 1, /**< File probes */
+ FID_IPC = 2, /**< Hz probes */
+ FID_PROCESS = 3, /**< Process probes */
+ FID_SIGNAL = 4, /**< Signal probes */
+ FID_NET = 5, /**< Network probes */
+ FID_DESC = 6, /**< Description probes */
+ FID_SWITCH = 7 /**< Switch context probes */
};
int set_feature(enum feature_id id);
-/*
- * SWAP kernel features
- * modules/ks_features/syscall_list.h
+/**
+ * @file ks_features/syscall_list.h
+ * @author Vyacheslav Cherkashin: SWAP ks_features implement
+ *
+ * @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
* 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 ks_features implement
+ * @section DESCRIPTION
*
+ * Syscalls list.
*/
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/ksyms/ksyms.c
+/**
+ * @file ksyms/ksyms.c
+ * @author Alexander Aksenov <a.aksenov@samsung.com>
+ * @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
* 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
*
- * 2014 Alexander Aksenov <a.aksenov@samsung.com>
+ * @section DESCRIPTION
*
+ * SWAP ksyms module.
*/
#include <linux/module.h>
#include <linux/percpu.h>
+/**
+ * @struct symbol_data
+ * @brief Stores symbols data.
+ * @var symbol_data::name
+ * Pointer to symbol name string.
+ * @var symbol_data::len
+ * Symbol name length.
+ * @var symbol_data::addr
+ * Symbol address.
+ */
struct symbol_data {
const char *name;
size_t len;
return 0;
}
+/**
+ * @brief Search of symbol address based on substring.
+ *
+ * @param name Pointer to the substring.
+ * @return Symbol address.
+ */
unsigned long swap_ksyms_substr(const char *name)
{
struct symbol_data sym_data = {
-#ifndef __KSYMS_H__
-#define __KSYMS_H__
-
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/ksyms/ksyms.h
+/**
+ * @file ksyms/ksyms.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
* 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>
+ * @sectoin DESCRIPTION
*
+ * SWAP symbols searching module.
*/
+#ifndef __KSYMS_H__
+#define __KSYMS_H__
+
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
#include <linux/autoconf.h>
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/ksyms/ksyms_init.h
+/**
+ * @file ksyms/ksyms_init.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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section LICENSE
+ *
* Copyright (C) Samsung Electronics, 2014
*
- * 2014 Alexander Aksenov <a.aksenov@samsung.com>
+ * @section DESCRIPTION
*
+ * SWAP symbols searching module initialization interface.
*/
#ifndef __KSYMS_INIT_H__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/ksyms/ksyms_module.c
+/**
+ * @file ksyms/ksyms_module.c
+ * @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
* 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
*
- * 2014 Alexander Aksenov <a.aksenov@samsung.com>
+ * @section DESCRIPTION
*
+ * SWAP symbols searching module initialization implementation.
*/
#include "ksyms_init.h"
#include <linux/module.h>
+/**
+ * @brief Init ksyms module.
+ *
+ * @return 0 on success.
+ */
int __init swap_ksyms_init(void)
{
int ret = ksyms_init();
return ret;
}
+/**
+ * @brief Exit ksyms module.
+ *
+ * @return Void.
+ */
void __exit swap_ksyms_exit(void)
{
ksyms_exit();
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/ksyms/no_ksyms.c
+/**
+ * @file ksyms/no_ksyms.c
+ * @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
* 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>
+ * @section DESCRIPTION
*
+ * SWAP symbols searching implementation.
*/
#include "ksyms.h"
#include <linux/slab.h>
#include <asm/fcntl.h>
-
+/**
+ * @def KSYMS_ERR
+ * Error message define.
+ */
#define KSYMS_ERR(format, args...) \
do { \
char *f = __FILE__; \
printk("%s:%u \'%s\' ERROR: " format "\n" , (n) ? n+1 : f, __LINE__, __FUNCTION__, ##args); \
} while(0)
-
+/**
+ * @struct sys_map_item
+ * @brief System map list item info.
+ * @var sys_map_item::list
+ * List pointer.
+ * @var sys_map_item::addr
+ * Symbol address.
+ * @var sys_map_item::name
+ * Symbol name.
+ */
struct sys_map_item {
struct list_head list;
static char* sm_path = NULL;
module_param(sm_path, charp, 0);
+/**
+ * @var smi_list
+ * List of sys_map_item.
+ */
LIST_HEAD(smi_list);
static struct file *file = NULL;
static int cnt_init_sm = 0;
+
+/**
+ * @var cnt_init_sm_lock
+ * System map items list lock.
+ */
DEFINE_SEMAPHORE(cnt_init_sm_lock);
static int file_open(void)
}
}
+/**
+ * @brief Generates symbols list.
+ *
+ * @return 0 on success.
+ */
int swap_get_ksyms(void)
{
int ret = 0;
}
EXPORT_SYMBOL_GPL(swap_get_ksyms);
+/**
+ * @brief Frees symbols list.
+ *
+ * @return Void.
+ */
void swap_put_ksyms(void)
{
down(&cnt_init_sm_lock);
}
EXPORT_SYMBOL_GPL(swap_put_ksyms);
+/**
+ * @brief Searches for symbol by its exact name.
+ *
+ * @param name Pointer the name string.
+ * @return Symbol's address.
+ */
unsigned long swap_ksyms(const char *name)
{
struct sys_map_item *smi;
}
EXPORT_SYMBOL_GPL(swap_ksyms);
+/**
+ * @brief Searches for symbol by substring of its name.
+ *
+ * @param name Pointer to the name substring.
+ * @return Symbol's address.
+ */
unsigned long swap_ksyms_substr(const char *name)
{
struct sys_map_item *smi;
}
EXPORT_SYMBOL_GPL(swap_ksyms_substr);
+/**
+ * @brief SWAP ksyms module initialization.
+ *
+ * @return 0 on success, negative error code on error.
+ */
int ksyms_init(void)
{
int ret = 0;
return 0;
}
+/**
+ * @brief SWAP ksyms module deinitialization.
+ *
+ * @return Void.
+ */
void ksyms_exit(void)
{
down(&cnt_init_sm_lock);