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
#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>
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;
}
#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
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;
#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>
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)
/*
* 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
* 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;
}
-void *alloc_insn_slot(struct slot_manager *sm)
+void *swap_slot_alloc(struct slot_manager *sm)
{
void *free_slot;
struct fixed_alloc *fa;
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);
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);
-#ifndef _DBI_INSNS_SLOTS_H
-#define _DBI_INSNS_SLOTS_H
+#ifndef _SWAP_SLOTS_H
+#define _SWAP_SLOTS_H
/*
* Kernel Probes (KProbes)
/*
* 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
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 */
#include <asm/traps.h>
#include <uprobe/swap_uprobes.h>
#include <uprobe/arch/asm/swap_uprobes.h>
-#include <kprobe/dbi_insn_slots.h>
+#include <kprobe/swap_slots.h>
#include <kprobe/dbi_kprobes_deps.h>
#include "trampoline_thumb.h"
return -EFAULT;
}
- up->atramp.utramp = alloc_insn_slot(up->sm);
+ up->atramp.utramp = swap_slot_alloc(up->sm);
if (up->atramp.utramp == NULL) {
- printk("Error: alloc_insn_slot failed (%08lx)\n", vaddr);
+ printk("Error: swap_slot_alloc failed (%08lx)\n", vaddr);
return -ENOMEM;
}
#include <kprobe/arch/asm/dbi_kprobes.h>
#include <uprobe/swap_uprobes.h>
#include <uprobe/arch/asm/swap_uprobes.h>
-#include <kprobe/dbi_insn_slots.h>
+#include <kprobe/swap_slots.h>
struct uprobe_ctlblk {
unsigned long flags;
struct task_struct *task = up->task;
void *tramp;
- tramp = alloc_insn_slot(up->sm);
+ tramp = swap_slot_alloc(up->sm);
if (tramp == 0) {
printk("trampoline out of memory\n");
return -ENOMEM;
if (!write_proc_vm_atomic(task, (unsigned long)tramp,
up->atramp.tramp,
sizeof(up->atramp.tramp))) {
- free_insn_slot(up->sm, tramp);
+ swap_slot_free(up->sm, tramp);
panic("failed to write memory %p!\n", tramp);
return -EINVAL;
}
#include <linux/hash.h>
#include <linux/mempolicy.h>
#include <linux/module.h>
-#include <kprobe/dbi_insn_slots.h>
+#include <kprobe/swap_slots.h>
#include <kprobe/dbi_kprobes_deps.h>
enum {
{
struct kprobe *p = up2kp(up);
- free_insn_slot(up->sm, p->ainsn.insn);
+ swap_slot_free(up->sm, p->ainsn.insn);
}
static struct hlist_head *uretprobe_inst_table_head(void *hash_key)
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/list.h>
-#include <kprobe/dbi_insn_slots.h>
+#include <kprobe/swap_slots.h>
#include <kprobe/arch/asm/dbi_kprobes.h>
#include "us_manager_common.h"