driver/ \
writer/ \
kprobe/ \
- ks_manager/ \
uprobe/ \
us_manager/ \
ks_features/ \
task_ctx/ \
uihv/ \
got_patcher/
+
+ifneq ($(CONFIG_SWAP_KERNEL_IMMUTABLE), y)
+obj-m += ks_manager/
+endif # CONFIG_SWAP_KERNEL_IMMUTABLE
#include <linux/string.h>
#include <linux/fdtable.h>
#include <net/sock.h>
-#include <kprobe/swap_kprobes.h>
#include <ksyms/ksyms.h>
#include <master/swap_deps.h>
+#include <swap-asm/swap_kprobes.h>
#include <us_manager/sspt/sspt_proc.h>
#include <us_manager/sspt/sspt_feature.h>
#include <linux/atomic.h>
#ifdef CONFIG_SWAP_HOOK_SWITCH_TO
# include <swap/hook_switch_to.h>
+#else /* CONFIG_SWAP_HOOK_SWITCH_TO */
+# include <kprobe/swap_kprobes.h>
#endif /* CONFIG_SWAP_HOOK_SWITCH_TO */
#ifdef CONFIG_SWAP_HOOK_ENERGY
# include <swap/hook_syscall.h>
# include <swap/hook_energy.h>
# include <kprobe/swap_td_raw.h>
+#else /* CONFIG_SWAP_HOOK_ENERGY */
+# include <kprobe/swap_kprobes.h>
#endif /* CONFIG_SWAP_HOOK_ENERGY */
#include "energy.h"
#include <linux/string.h>
#include <linux/namei.h>
#include <linux/slab.h>
+#include <linux/limits.h>
#include <kprobe/swap_ktd.h>
#include <us_manager/pf/pf_group.h>
#include <us_manager/sspt/sspt_page.h>
EXTRA_CFLAGS := $(extra_cflags)
obj-m := swap_kprobe.o
-swap_kprobe-y := swap_kprobes.o \
- swap_kprobes_deps.o \
- swap_slots.o \
- swap_td_raw.o \
- swap_ktd.o
+swap_kprobe-y := \
+ swap_kprobes_deps.o \
+ swap_slots.o \
+ swap_td_raw.o \
+ swap_ktd.o
+
+
+### ARM64
+swap_kprobe-$(CONFIG_ARM64) += \
+ arch/arm64/swap-asm/simulate-insn.o \
+ arch/arm64/swap-asm/condn-helpers.o
+
+
+ifeq ($(CONFIG_SWAP_KERNEL_IMMUTABLE), y)
+
+swap_kprobe-y += swap_no_kprobes.o
+
+else # CONFIG_SWAP_KERNEL_IMMUTABLE
+
+swap_kprobe-y += swap_kprobes.o
### ARM
swap_kprobe-$(CONFIG_ARM) += \
### ARM64
swap_kprobe-$(CONFIG_ARM64) += arch/arm64/swap-asm/swap_kprobes.o \
arch/arm64/swap-asm/dbg_interface.o \
- arch/arm64/swap-asm/kprobes-arm64.o \
- arch/arm64/swap-asm/condn-helpers.o \
- arch/arm64/swap-asm/simulate-insn.o
+ arch/arm64/swap-asm/kprobes-arm64.o
### X86
swap_kprobe-$(CONFIG_X86) += arch/x86/swap-asm/swap_kprobes.o
+
+endif # CONFIG_SWAP_KERNEL_IMMUTABLE
* SWAP kprobe implementation for ARM architecture.
*/
+
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
#include <linux/module.h>
#include <asm/cacheflush.h>
#include <asm/traps.h>
*/
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
#include <linux/module.h>
#include <linux/rwlock.h>
#include <asm/debug-monitors.h>
*/
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
#include <linux/slab.h>
#include <linux/types.h>
#include <asm/cacheflush.h>
* SWAP krpobes arch-dependend part for x86.
*/
+
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
#include<linux/module.h>
#include <linux/kdebug.h>
#ifndef _SWAP_KPROBES_H
#define _SWAP_KPROBES_H
+
+#include <linux/kconfig.h>
+
+#ifdef CONFIG_SWAP_KERNEL_IMMUTABLE
+# error "Kernel is immutable"
+#endif /* CONFIG_SWAP_KERNEL_IMMUTABLE */
+
+
#include <linux/version.h> /* LINUX_VERSION_CODE, KERNEL_VERSION() */
#include <linux/notifier.h>
#include <linux/percpu.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/spinlock.h>
-#include <kprobe/swap_kprobes.h>
#include <kprobe/swap_kprobes_deps.h>
#include <ksyms/ksyms.h>
#include "swap_ktd.h"
--- /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, 2015
+ *
+ * 2016 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/module.h>
+#include <kprobe/swap_ktd.h>
+#include <kprobe/swap_kprobes_deps.h>
+#include <master/swap_initializer.h>
+
+
+static void ktd_uninit(void)
+{
+ swap_ktd_uninit_top();
+ swap_ktd_uninit_bottom();
+}
+
+SWAP_LIGHT_INIT_MODULE(init_module_dependencies, swap_ktd_init, ktd_uninit, NULL, NULL);
+
+MODULE_LICENSE("GPL");
#include <linux/slab.h>
#include <linux/errno.h>
#include <ksyms/ksyms.h>
-#include <kprobe/swap_kprobes.h>
#include <master/swap_initializer.h>
#include <writer/event_filter.h>
#include <swap/hook_syscall.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <ksyms/ksyms.h>
-#include <kprobe/swap_kprobes.h>
#include <master/swap_initializer.h>
#include <writer/event_filter.h>
#include "ksf_msg.h"
/* ====================== SWITCH_CONTEXT ======================= */
-static int switch_entry_handler(struct kretprobe_instance *ri,
- struct pt_regs *regs)
-{
- if (check_event(current))
- ksf_switch_entry(current);
-
- return 0;
-}
-
-static int switch_ret_handler(struct kretprobe_instance *ri,
- struct pt_regs *regs)
-{
- if (check_event(current))
- ksf_switch_exit(current);
-
- 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;
#else /* CONFIG_SWAP_HOOK_SWITCH_TO */
+static int switch_entry_handler(struct kretprobe_instance *ri,
+ struct pt_regs *regs)
+{
+ if (check_event(current))
+ ksf_switch_entry(current);
+
+ return 0;
+}
+
+static int switch_ret_handler(struct kretprobe_instance *ri,
+ struct pt_regs *regs)
+{
+ if (check_event(current))
+ ksf_switch_exit(current);
+
+ return 0;
+}
+
+/**
+ * @var switch_rp
+ * Kretprobe for scheduler.
+ */
+struct kretprobe switch_rp = {
+ .entry_handler = switch_entry_handler,
+ .handler = switch_ret_handler
+};
+
/**
* @brief Get scheduler address.
*
#include <linux/mman.h>
#include <linux/err.h>
#include <linux/types.h>
+#include <linux/fs.h>
#include <us_manager/sspt/sspt_proc.h>
#include <us_manager/sspt/sspt_ip.h>
#include <us_manager/callbacks.h>
#include <linux/spinlock.h>
#include <linux/limits.h>
#include <linux/list.h>
+#include <linux/fs.h>
#include <us_manager/sspt/sspt_ip.h>
#include <us_manager/us_common_file.h>
*/
+#include <linux/kconfig.h>
#include <linux/types.h>
#include <asm/traps.h>
#include <arch/arm/uprobe/swap_uprobe.h>
if (ret)
return ret;
- /* for aarch64 */
- dbg_brk_hook_reg(&dbg_up_ss);
- dbg_brk_hook_reg(&dbg_up_bp);
- dbg_brk_hook_reg(&dbg_urp_bp);
+ if (!IS_ENABLED(CONFIG_SWAP_KERNEL_IMMUTABLE)) {
+ /* for aarch64 */
+ dbg_brk_hook_reg(&dbg_up_ss);
+ dbg_brk_hook_reg(&dbg_up_bp);
+ dbg_brk_hook_reg(&dbg_urp_bp);
+ } else {
+ pr_err("64-bit uprobes doesn't supported in case of Immutable kernel\n");
+ }
/* for aarch32 */
__register_undef_hook(&undef_hook_arm);
__unregister_undef_hook(&undef_hook_thumb);
__unregister_undef_hook(&undef_hook_arm);
- /* for aarch64 */
- dbg_brk_hook_unreg(&dbg_urp_bp);
- dbg_brk_hook_unreg(&dbg_up_bp);
- dbg_brk_hook_unreg(&dbg_up_ss);
+ if (!IS_ENABLED(CONFIG_SWAP_KERNEL_IMMUTABLE)) {
+ /* for aarch64 */
+ dbg_brk_hook_unreg(&dbg_urp_bp);
+ dbg_brk_hook_unreg(&dbg_up_bp);
+ dbg_brk_hook_unreg(&dbg_up_ss);
+ }
+
swap_td_raw_unreg(&td_raw);
}
#include <kprobe/swap_slots.h>
#include <kprobe/swap_td_raw.h>
+#include <kprobe/swap_kprobes.h>
#include <uprobe/swap_uprobes.h>
#include "swap_uprobes.h"
#include <master/wait.h>
-#include <kprobe/swap_kprobes.h>
#include <swap-asm/swap_uprobes.h>
*/
-#include <kprobe/swap_kprobes.h>
#include <uprobe/swap_uprobes.h>
#include "probes.h"
#include <kprobe/swap_kprobes_deps.h>
#include <us_manager/probes/probes.h>
-static inline void print_jprobe(struct jprobe *jp)
-{
- printk(KERN_INFO "### JP: entry=%lx, pre_entry=%lx\n",
- (unsigned long)jp->entry, (unsigned long)jp->pre_entry);
-}
static inline void print_retprobe(struct uretprobe *rp)
{
#include <linux/module.h>
#include <linux/vmalloc.h>
#include <linux/spinlock.h>
-#include <kprobe/swap_kprobes.h>
#include <buffer/swap_buffer_module.h>
#include <swap-asm/swap_kprobes.h>
#include <swap-asm/swap_uprobes.h>