echo -e "\t--file <config file>"
# echo -e "\t--debug"
echo -e "\t--kernel <kernel path>"
- echo -e "\t--arch <arm|i386>"
+ echo -e "\t--arch <arm|arm64|i386>"
echo -e "\t[--toolchain <cross compile path>]"
exit 1
}
if [ "${ARCH}" = "arm" ] ; then
LINKNAME="arm"
+elif [ "${ARCH}" = "arm64" ] ; then
+ LINKNAME="arm64"
elif [ "${ARCH}" = "i386" ] ; then
LINKNAME="x86"
else
struct lcd_priv_data *lcd;
if (tms_brt_cnt <= 0) {
- printk(KERN_INFO "error variable tms_brt_cnt=%d\n",
+ printk(KERN_INFO "error variable tms_brt_cnt=%zu\n",
tms_brt_cnt);
return NULL;
}
{
switch (action) {
case LAT_BRIGHTNESS:
- set_brightness(ops, (int)data);
+ set_brightness(ops, VOIDP2INT(data));
break;
case LAT_POWER:
- set_power(ops, (int)data);
+ set_power(ops, VOIDP2INT(data));
break;
default:
printk(KERN_INFO "LCD energy error: action=%d\n", action);
#include <energy/rational_debugfs.h>
+#define VOIDP2INT(x) ((int)(unsigned long)(x))
+#define INT2VOIDP(x) ((void *)(unsigned long)(x))
+
+
/** Description of actions */
enum lcd_action_type {
LAT_BRIGHTNESS, /**< LCD brightness */
if (!ret && maru_ops.notifier)
maru_ops.notifier(&maru_ops, LAT_BRIGHTNESS,
- (void *)*brightness);
+ INT2VOIDP(*brightness));
return 0;
}
int *power = (int *)ri->data;
if (!ret && s6e8aa0_ops.notifier)
- s6e8aa0_ops.notifier(&s6e8aa0_ops, LAT_POWER, (void *)*power);
+ s6e8aa0_ops.notifier(&s6e8aa0_ops, LAT_POWER, INT2VOIDP(*power));
return 0;
}
if (!ret && s6e8aa0_ops.notifier)
s6e8aa0_ops.notifier(&s6e8aa0_ops, LAT_BRIGHTNESS,
- (void *)*brightness);
+ INT2VOIDP(*brightness));
return 0;
}
if (!ret && s6e8aa0_ops.notifier)
s6e8aa0_ops.notifier(&s6e8aa0_ops, LAT_POWER,
- (void *)*power);
+ INT2VOIDP(*power));
return 0;
}
if (!ret && s6e8aa0_ops.notifier)
s6e8aa0_ops.notifier(&s6e8aa0_ops, LAT_BRIGHTNESS,
- (void *)*brightness);
+ INT2VOIDP(*brightness));
return 0;
}
endif #ifeq ($(CONFIG_STRICT_MEMORY_RWX), y)
+### ARM64
+swap_kprobe-$(CONFIG_ARM64) += arch/arm64/swap-asm/swap_kprobes.o
+
+
### X86
swap_kprobe-$(CONFIG_X86) += arch/x86/swap-asm/swap_kprobes.o
--- /dev/null
+/*
+ * 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.
+ *
+ * Copyright (C) Samsung Electronics, 2014
+ *
+ * 2014 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/bug.h>
+
+
+struct kprobe;
+struct pt_regs;
+
+
+int swap_arch_init_kprobes(void)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+void swap_arch_exit_kprobes(void)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
--- /dev/null
+#ifndef _ASM_ARM64_KPROBES_H
+#define _ASM_ARM64_KPROBES_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
+ * 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.
+ *
+ * Copyright (C) Samsung Electronics, 2014
+ *
+ * 2014 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/types.h>
+
+
+#define BREAKPOINT_INSTRUCTION 0 /* FIXME: to implement */
+#define KPROBES_TRAMP_LEN 10 /* FIXME: to implement */
+
+
+typedef u32 kprobe_opcode_t;
+
+struct arch_specific_insn { /* FIXME: to implement */
+ /* copy of the original instruction */
+ kprobe_opcode_t *insn;
+};
+
+/* per-cpu kprobe control block */
+struct kp_core_ctlblk { /* FIXME: to implement */
+ unsigned long kp_core_status;
+};
+
+
+struct kprobe;
+struct kp_core;
+struct slot_manager;
+struct kretprobe_instance;
+
+
+static inline unsigned long swap_get_karg(struct pt_regs *regs,
+ unsigned long n)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline unsigned long swap_get_sarg(struct pt_regs *regs,
+ unsigned long n)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline unsigned long swap_get_instr_ptr(struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0xdeadc0de;
+}
+
+static inline void swap_set_instr_ptr(struct pt_regs *regs, unsigned long val)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline unsigned long swap_get_ret_addr(struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0xdeadc0de;
+}
+
+static inline void swap_set_ret_addr(struct pt_regs *regs, unsigned long val)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline int arch_kp_core_prepare(struct kp_core *p,
+ struct slot_manager *sm)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline void arch_kp_core_arm(struct kp_core *p)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline void arch_kp_core_disarm(struct kp_core *p)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+
+static inline void restore_previous_kp_core(struct kp_core_ctlblk *kcb)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline void swap_arch_prepare_kretprobe(struct kretprobe_instance *ri,
+ struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline void swap_kretprobe_trampoline(void)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+
+static inline unsigned long arch_get_task_pc(struct task_struct *p)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0xdeadc0de;
+}
+
+static inline void arch_set_task_pc(struct task_struct *p, unsigned long val)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline int swap_setjmp_pre_handler(struct kprobe *p,
+ struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+/* jumper */
+typedef unsigned long (*jumper_cb_t)(void *);
+
+static inline unsigned long get_jump_addr(void)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0x87654321;
+}
+
+static inline int set_jump_cb(unsigned long ret_addr, struct pt_regs *regs,
+ jumper_cb_t cb, void *data, size_t size)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline int arch_init_module_deps(void)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+
+int swap_arch_init_kprobes(void);
+void swap_arch_exit_kprobes(void);
+
+
+#endif /* _ASM_ARM64_KPROBES_H */
if (found) {
printk(KERN_INFO "---> [%d] %s (%d/%d): tramp (%08lx) "
- "found at %08lx (%08lx /%+d) - %08lx\n",
+ "found at %08lx (%08lx /%+ld) - %08lx\n",
task_cpu(ri->task),
ri->task->comm, ri->task->tgid, ri->task->pid,
(long unsigned int)tramp,
(long unsigned int)found, (long unsigned int)ri->sp,
- found - ri->sp, ri->rp ? ri->rp->kp.addr : 0);
+ (unsigned long)(found - ri->sp), ri->rp ? ri->rp->kp.addr : 0);
*found = (unsigned long)ri->ret_addr;
retval = 0;
} else {
size_t i;
for (i = 0; i < f->cnt; ++i)
- printk(KERN_INFO " feature[%3u]: %s\n", i,
+ printk(KERN_INFO " feature[%3zu]: %s\n", i,
get_sys_name(f->feature_list[i]));
}
swap_put_uarg(regs, 0, priv->arg0);
swap_put_uarg(regs, 1, priv->arg1);
swap_set_ret_addr(regs, priv->raddr);
-#ifndef CONFIG_ARM
+#ifdef CONFIG_X86_32
/* need to do it only on x86 */
regs->EREG(ip) -= 1;
-#endif /* !CONFIG_ARM */
+#endif /* CONFIG_X86_32 */
/* we have just restored the registers => no need to do it in
* trampoline_uprobe_handler */
ri->ret_addr = NULL;
{
struct dentry *dentry = lpd_get_dentry(hd);
-#ifdef CONFIG_ARM
+#if defined(CONFIG_ARM)
printk(LOADER_PREFIX "%s[%d/%d] %s (%d) %s addr(%08lx), "
"r0(%08lx), r1(%08lx), r2(%08lx), r3(%08lx), "
"r4(%08lx), r5(%08lx), r6(%08lx), r7(%08lx), "
regs->ARM_r0, regs->ARM_r1, regs->ARM_r2, regs->ARM_r3,
regs->ARM_r4, regs->ARM_r5, regs->ARM_r6, regs->ARM_r7,
regs->ARM_sp, regs->ARM_lr, regs->ARM_pc);
-#else /* !CONFIG_ARM */
+#elif defined(CONFIG_X86_32)
printk(LOADER_PREFIX "%s[%d/%d] %s (%d) %s addr(%08lx), "
"ip(%08lx), arg0(%08lx), arg1(%08lx), raddr(%08lx)\n",
current->comm, current->tgid, current->pid,
prefix, (unsigned long)ri->rp->up.addr,
regs->EREG(ip), swap_get_uarg(regs, 0), swap_get_uarg(regs, 1),
swap_get_ret_addr(regs));
-#endif /* CONFIG_ARM */
+#elif defined(CONFIG_ARM64)
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ (void)dentry;
+#else /* CONFIG_arch */
+# error "this architecture is not supported"
+#endif /* CONFIG_arch */
}
static inline unsigned long __get_r_debug_off(struct vm_area_struct *linker_vma)
int msg_keep_alive(struct msg_buf *mb)
{
if (!is_end_mb(mb)) {
- print_err("to long message, remained=%u", remained_mb(mb));
+ print_err("to long message, remained=%zu", remained_mb(mb));
return -EINVAL;
}
return -EINVAL;
if (!is_end_mb(mb)) {
- print_err("to long message, remained=%u", remained_mb(mb));
+ print_err("to long message, remained=%zu", remained_mb(mb));
ret = -EINVAL;
goto free_us_inst;
}
int discarded;
if (!is_end_mb(mb)) {
- print_err("to long message, remained=%u", remained_mb(mb));
+ print_err("to long message, remained=%zu", remained_mb(mb));
return -EINVAL;
}
return -EINVAL;
if (!is_end_mb(mb)) {
- print_err("to long message, remained=%u", remained_mb(mb));
+ print_err("to long message, remained=%zu", remained_mb(mb));
ret = -EINVAL;
goto free_conf_data;
}
return -EINVAL;
if (!is_end_mb(mb)) {
- print_err("to long message, remained=%u", remained_mb(mb));
+ print_err("to long message, remained=%zu", remained_mb(mb));
ret = -EINVAL;
goto free_us_inst;
}
return -EINVAL;
if (!is_end_mb(mb)) {
- print_err("to long message, remained=%u", remained_mb(mb));
+ print_err("to long message, remained=%zu", remained_mb(mb));
ret = -EINVAL;
goto free_us_inst;
}
buf = kmalloc(len, GFP_ATOMIC);
if (buf == NULL) {
- printk(PRELOAD_PREFIX "No mem for buffer! Size = %d\n", len);
+ printk(PRELOAD_PREFIX "No mem for buffer! Size = %zd\n", len);
return 0;
}
ret = read_proc_vm_atomic(current, (unsigned long)user_buf, buf, len);
if (ret < 0) {
printk(PRELOAD_PREFIX "Cannot copy data from userspace! Size = "
- "%d ptr 0x%lx ret %d\n", len,
+ "%zd ptr 0x%lx ret %d\n", len,
(unsigned long)user_buf, ret);
goto write_msg_fail;
}
arch/arm/swap-asm/thumb_tramps.o
+### ARM64
+swap_uprobe-$(CONFIG_ARM64) += arch/arm64/swap-asm/swap_uprobes.o
+
+
### X86
swap_uprobe-$(CONFIG_X86) += arch/x86/swap-asm/swap_uprobes.o \
arch/x86/swap-asm/swap_sc_patch.o
--- /dev/null
+/*
+ * 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.
+ *
+ * Copyright (C) Samsung Electronics, 2014
+ *
+ * 2014 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/bug.h>
+
+
+int swap_arch_init_uprobes(void)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+void swap_arch_exit_uprobes(void)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
--- /dev/null
+#ifndef _ASM_ARM64_UPROBES_H
+#define _ASM_ARM64_UPROBES_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
+ * 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.
+ *
+ * Copyright (C) Samsung Electronics, 2014
+ *
+ * 2014 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#define UPROBES_TRAMP_LEN 1 /* FIXME: to implement */
+
+
+struct kprobe;
+struct uprobe;
+struct uretprobe;
+struct uretprobe_instance;
+
+
+typedef u32 uprobe_opcode_t;
+
+struct arch_insn {
+ uprobe_opcode_t *insn; /* FIXME: to implement */
+};
+
+
+static inline u32 swap_get_urp_float(struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline u64 swap_get_urp_double(struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline unsigned long swap_get_uarg(struct pt_regs *regs, unsigned long n)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0x12345678;
+}
+
+static inline void swap_put_uarg(struct pt_regs *regs, unsigned long n,
+ unsigned long val)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline int arch_prepare_uprobe(struct uprobe *up)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline void arch_remove_uprobe(struct uprobe *up)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline int setjmp_upre_handler(struct uprobe *p, struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline int longjmp_break_uhandler(struct uprobe *p,
+ struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline int arch_arm_uprobe(struct uprobe *p)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline void arch_disarm_uprobe(struct uprobe *p,
+ struct task_struct *task)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+
+static inline unsigned long arch_get_trampoline_addr(struct uprobe *p,
+ struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline void arch_set_orig_ret_addr(unsigned long orig_ret_addr,
+ struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+static inline int arch_prepare_uretprobe(struct uretprobe_instance *ri,
+ struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline int arch_opcode_analysis_uretprobe(struct uretprobe *rp)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline int arch_disarm_urp_inst(struct uretprobe_instance *ri,
+ struct task_struct *task)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
+static inline void arch_ujprobe_return(void)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+}
+
+int swap_arch_init_uprobes(void);
+void swap_arch_exit_uprobes(void);
+
+
+#endif /* _ASM_ARM64_UPROBES_H */
data->addr = read_cr2();
data->pf_regs = (struct pt_regs *)swap_get_karg(regs, 0);
data->save_pc = data->pf_regs->ip;
+#elif defined(CONFIG_ARM64)
+ WARN(1, "not implemented"); /* FIXME: to implement */
#else
#error "this architecture is not supported"
#endif /* CONFIG_arch */
#include "proc_filters.h"
#include <us_manager/sspt/sspt.h>
+
+#define VOIDP2PID(x) ((pid_t)(unsigned long)(x))
+#define PID2VOIDP(x) ((void *)(unsigned long)(x))
+
static int check_dentry(struct task_struct *task, struct dentry *dentry)
{
struct vm_area_struct *vma;
static struct task_struct *call_by_tgid(struct proc_filter *self,
struct task_struct *task)
{
- pid_t tgid = (pid_t)self->data;
+ pid_t tgid = VOIDP2PID(self->data);
if (task->tgid == tgid)
return task;
void set_pf_by_tgid(struct proc_filter *pf, pid_t tgid, void *priv)
{
pf->call = &call_by_tgid;
- pf->data = (void *)tgid;
+ pf->data = PID2VOIDP(tgid);
pf->priv = priv;
}
*/
int check_pf_by_tgid(struct proc_filter *filter, pid_t tgid)
{
- return filter->data == (void *)tgid && filter->call == &call_by_tgid;
+ return filter->data == PID2VOIDP(tgid)
+ && filter->call == &call_by_tgid;
}
/**
#include <kprobe/swap_slots.h>
#include <swap-asm/swap_kprobes.h>
+#include <swap-asm/swap_uprobes.h>
#include "us_manager_common.h"
/* Regs manipulations */
#if defined(CONFIG_ARM)
-#define get_regs_ip(regs) (regs->ARM_pc) /**< Get pc reg. */
#define get_regs_ret_func(regs) (regs->ARM_lr) /**< Get lr reg. */
#define get_regs_ret_val(regs) (regs->ARM_r0) /**< Get ret val. */
#define get_regs_stack_ptr(regs) (regs->ARM_sp) /**< Get stack pointer. */
#elif defined(CONFIG_X86_32)
-#define get_regs_ip(regs) (regs->ip - 1) /**< Get ip. */
#define get_regs_ret_val(regs) (regs->ax) /**< Get ret val. */
#define get_regs_stack_ptr(regs) (regs->sp) /**< Get stack pointer. */
sp = (u32 *)regs->sp;
if (get_user(addr, sp))
pr_info("failed to dereference a pointer, sp=%p, "
- "pc=%lx\n", sp, get_regs_ip(regs));
+ "pc=%lx\n", sp, regs->ip - 1);
} else {
sp = (u32 *)kernel_stack_pointer(regs);
addr = *sp;
return addr;
}
+#elif defined(CONFIG_ARM64)
+
+static inline u64 get_regs_ret_func(struct pt_regs *regs)
+{
+ WARN(1, "not implemented"); /* FIXME: to implement */
+ return 0;
+}
+
#endif /* CONFIG_arch */
#endif /* __KERNEL_OPERATIONS_H__ */
struct swap_msg *m = (struct swap_msg *)data;
if (sizeof(*m) > size) {
- pr_err(MSG_PREFIX "ERROR: message RAW small size=%u\n", size);
+ pr_err(MSG_PREFIX "ERROR: message RAW small size=%zu\n", size);
return -EINVAL;
}