summaryrefslogtreecommitdiff
path: root/kprobe
diff options
context:
space:
mode:
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>2014-05-07 17:47:19 +0400
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>2014-05-07 17:47:19 +0400
commit4b2aaed051b4ad09a3bf874988c67ce11d5c655e (patch)
tree6f45c4032a07e703019b027a66eeefed75c06e35 /kprobe
parent343dd852ba3d9eda57a7531a050ac133b052feb5 (diff)
downloadswap-modules-4b2aaed051b4ad09a3bf874988c67ce11d5c655e.tar.gz
swap-modules-4b2aaed051b4ad09a3bf874988c67ce11d5c655e.tar.bz2
swap-modules-4b2aaed051b4ad09a3bf874988c67ce11d5c655e.zip
[REFACTOR] slots manager
to fix names conflict when building in kernel Change-Id: I2f66053243fc5a47be7276a02175852aa034f041 Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
Diffstat (limited to 'kprobe')
-rw-r--r--kprobe/Kbuild5
-rw-r--r--kprobe/arch/asm-arm/dbi_kprobes.c6
-rw-r--r--kprobe/arch/asm-x86/dbi_kprobes.c4
-rw-r--r--kprobe/dbi_kprobes.c4
-rw-r--r--kprobe/swap_slots.c (renamed from kprobe/dbi_insn_slots.c)19
-rw-r--r--kprobe/swap_slots.h (renamed from kprobe/dbi_insn_slots.h)12
6 files changed, 28 insertions, 22 deletions
diff --git a/kprobe/Kbuild b/kprobe/Kbuild
index d086f97a..a9994fbf 100644
--- a/kprobe/Kbuild
+++ b/kprobe/Kbuild
@@ -1,5 +1,8 @@
EXTRA_CFLAGS := $(extra_cflags)
obj-m := swap_kprobe.o
-swap_kprobe-y := dbi_kprobes_deps.o dbi_insn_slots.o arch/asm/dbi_kprobes.o dbi_kprobes.o
+swap_kprobe-y := dbi_kprobes.o \
+ dbi_kprobes_deps.o \
+ arch/asm/dbi_kprobes.o \
+ swap_slots.o
swap_kprobe-$(CONFIG_ARM) += arch/asm/trampoline_arm.o
diff --git a/kprobe/arch/asm-arm/dbi_kprobes.c b/kprobe/arch/asm-arm/dbi_kprobes.c
index 3ae5e258..313bd06f 100644
--- a/kprobe/arch/asm-arm/dbi_kprobes.c
+++ b/kprobe/arch/asm-arm/dbi_kprobes.c
@@ -37,7 +37,7 @@
#include <kprobe/dbi_kprobes.h>
#include <kprobe/dbi_kdebug.h>
-#include <kprobe/dbi_insn_slots.h>
+#include <kprobe/swap_slots.h>
#include <kprobe/dbi_kprobes_deps.h>
#include <ksyms/ksyms.h>
@@ -300,13 +300,13 @@ int arch_prepare_kprobe(struct kprobe *p, struct slot_manager *sm)
unsigned long *tramp;
int ret;
- tramp = alloc_insn_slot(sm);
+ tramp = swap_slot_alloc(sm);
if (tramp == NULL)
return -ENOMEM;
ret = arch_make_trampoline_arm(addr, insn, tramp);
if (ret) {
- free_insn_slot(sm, tramp);
+ swap_slot_free(sm, tramp);
return ret;
}
diff --git a/kprobe/arch/asm-x86/dbi_kprobes.c b/kprobe/arch/asm-x86/dbi_kprobes.c
index 8fdf17da..a7c65eaa 100644
--- a/kprobe/arch/asm-x86/dbi_kprobes.c
+++ b/kprobe/arch/asm-x86/dbi_kprobes.c
@@ -52,7 +52,7 @@
#include <kprobe/dbi_kprobes.h>
#include <kprobe/dbi_kdebug.h>
-#include <kprobe/dbi_insn_slots.h>
+#include <kprobe/swap_slots.h>
#include <kprobe/dbi_kprobes_deps.h>
#define SUPRESS_BUG_MESSAGES
@@ -230,7 +230,7 @@ static int is_IF_modifier (kprobe_opcode_t opcode)
int arch_prepare_kprobe(struct kprobe *p, struct slot_manager *sm)
{
/* insn: must be on special executable page on i386. */
- p->ainsn.insn = alloc_insn_slot(sm);
+ p->ainsn.insn = swap_slot_alloc(sm);
if (p->ainsn.insn == NULL)
return -ENOMEM;
diff --git a/kprobe/dbi_kprobes.c b/kprobe/dbi_kprobes.c
index 9374f05d..c20150bb 100644
--- a/kprobe/dbi_kprobes.c
+++ b/kprobe/dbi_kprobes.c
@@ -51,7 +51,7 @@
#include "dbi_kdebug.h"
#include "dbi_kprobes_deps.h"
-#include "dbi_insn_slots.h"
+#include "swap_slots.h"
#include <ksyms/ksyms.h>
#include <linux/version.h>
@@ -490,7 +490,7 @@ EXPORT_SYMBOL_GPL(register_aggr_kprobe);
static void remove_kprobe(struct kprobe *p)
{
/* TODO: check boostable for x86 and MIPS */
- free_insn_slot(&sm, p->ainsn.insn);
+ swap_slot_free(&sm, p->ainsn.insn);
}
int dbi_register_kprobe(struct kprobe *p)
diff --git a/kprobe/dbi_insn_slots.c b/kprobe/swap_slots.c
index 57239358..e1d7e4a0 100644
--- a/kprobe/dbi_insn_slots.c
+++ b/kprobe/swap_slots.c
@@ -21,7 +21,7 @@
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/dbi_insn_slots.c
+ * modules/kprobe/swap_slots.c
*
* 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
@@ -45,12 +45,15 @@
* 2012-2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com> new memory allocator for slots
*/
-#include "dbi_insn_slots.h"
+
#include <linux/module.h>
#include <linux/rculist.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <kprobe/dbi_kprobes_deps.h>
+
+#include "swap_slots.h"
+#include "dbi_kprobes_deps.h"
+
struct chunk {
unsigned long *data;
@@ -164,7 +167,7 @@ static void free_fixed_alloc(struct slot_manager *sm, struct fixed_alloc *fa)
}
-void *alloc_insn_slot(struct slot_manager *sm)
+void *swap_slot_alloc(struct slot_manager *sm)
{
void *free_slot;
struct fixed_alloc *fa;
@@ -185,9 +188,9 @@ void *alloc_insn_slot(struct slot_manager *sm)
return chunk_allocate(&fa->chunk, sm->slot_size);
}
-EXPORT_SYMBOL_GPL(alloc_insn_slot);
+EXPORT_SYMBOL_GPL(swap_slot_alloc);
-void free_insn_slot(struct slot_manager *sm, void *slot)
+void swap_slot_free(struct slot_manager *sm, void *slot)
{
struct fixed_alloc *fa;
DECLARE_NODE_PTR_FOR_HLIST(pos);
@@ -209,6 +212,6 @@ void free_insn_slot(struct slot_manager *sm, void *slot)
return;
}
- panic("free_insn_slot: slot=%p is not data base\n", slot);
+ panic("%s: slot=%p is not data base\n", __func__, slot);
}
-EXPORT_SYMBOL_GPL(free_insn_slot);
+EXPORT_SYMBOL_GPL(swap_slot_free);
diff --git a/kprobe/dbi_insn_slots.h b/kprobe/swap_slots.h
index db5ad627..3e48059a 100644
--- a/kprobe/dbi_insn_slots.h
+++ b/kprobe/swap_slots.h
@@ -1,5 +1,5 @@
-#ifndef _DBI_INSNS_SLOTS_H
-#define _DBI_INSNS_SLOTS_H
+#ifndef _SWAP_SLOTS_H
+#define _SWAP_SLOTS_H
/*
* Kernel Probes (KProbes)
@@ -24,7 +24,7 @@
/*
* Dynamic Binary Instrumentation Module based on KProbes
- * modules/kprobe/dbi_insn_slots.h
+ * modules/kprobe/swap_slots.h
*
* 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
@@ -58,7 +58,7 @@ struct slot_manager {
void *data;
};
-void *alloc_insn_slot(struct slot_manager *sm);
-void free_insn_slot(struct slot_manager *sm, void *slot);
+void *swap_slot_alloc(struct slot_manager *sm);
+void swap_slot_free(struct slot_manager *sm, void *slot);
-#endif /* _DBI_INSNS_SLOTS_H */
+#endif /* _SWAP_SLOTS_H */