KI: add kernel patch for CONFIG_SWAP_HOOK_SYSCALL support 86/156486/4
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Wed, 4 Oct 2017 18:14:35 +0000 (21:14 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Fri, 20 Oct 2017 09:06:02 +0000 (12:06 +0300)
Change-Id: I922f4abf1cebde741ab28b94115daa18cc2e259d
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
kernel_integration/patches/0003-SWAP-DA-arm64-Add-CONFIG_SWAP_HOOK_SYSCALL.patch [new file with mode: 0644]

diff --git a/kernel_integration/patches/0003-SWAP-DA-arm64-Add-CONFIG_SWAP_HOOK_SYSCALL.patch b/kernel_integration/patches/0003-SWAP-DA-arm64-Add-CONFIG_SWAP_HOOK_SYSCALL.patch
new file mode 100644 (file)
index 0000000..d6baadb
--- /dev/null
@@ -0,0 +1,113 @@
+From ad125f67bab4d41c981b5a10b631104856d2658e Mon Sep 17 00:00:00 2001
+From: Your Name <your@email.com>
+Date: Wed, 4 Oct 2017 20:52:28 +0300
+Subject: [PATCH 3/9] SWAP-DA(arm64): Add CONFIG_SWAP_HOOK_SYSCALL
+
+---
+ arch/arm64/include/asm/thread_info.h |  4 +++-
+ arch/arm64/kernel/ptrace.c           |  7 +++++++
+ include/swap/hook_syscall_priv.h     | 10 ++++++++++
+ kernel/fork.c                        |  2 ++
+ 4 files changed, 22 insertions(+), 1 deletion(-)
+ create mode 100644 include/swap/hook_syscall_priv.h
+
+diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
+index 0e668e3..c459755 100644
+--- a/arch/arm64/include/asm/thread_info.h
++++ b/arch/arm64/include/asm/thread_info.h
+@@ -113,6 +113,7 @@ static inline struct thread_info *current_thread_info(void)
+ #define TIF_SYSCALL_AUDIT     9
+ #define TIF_SYSCALL_TRACEPOINT        10
+ #define TIF_SECCOMP           11
++#define TIF_SWAP_HOOK_SYSCALL 12
+ #define TIF_MEMDIE            18      /* is terminating due to OOM killer */
+ #define TIF_FREEZE            19
+ #define TIF_RESTORE_SIGMASK   20
+@@ -130,6 +131,7 @@ static inline struct thread_info *current_thread_info(void)
+ #define _TIF_SYSCALL_AUDIT    (1 << TIF_SYSCALL_AUDIT)
+ #define _TIF_SYSCALL_TRACEPOINT       (1 << TIF_SYSCALL_TRACEPOINT)
+ #define _TIF_SECCOMP          (1 << TIF_SECCOMP)
++#define _TIF_SWAP_HOOK_SYSCALL        (1 << TIF_SWAP_HOOK_SYSCALL)
+ #define _TIF_32BIT            (1 << TIF_32BIT)
+ #define _TIF_WORK_MASK                (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
+@@ -137,7 +139,7 @@ static inline struct thread_info *current_thread_info(void)
+ #define _TIF_SYSCALL_WORK     (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
+                                _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
+-                               _TIF_NOHZ)
++                               _TIF_NOHZ | _TIF_SWAP_HOOK_SYSCALL)
+ #endif /* __KERNEL__ */
+ #endif /* __ASM_THREAD_INFO_H */
+diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
+index d882b83..14d6df5 100644
+--- a/arch/arm64/kernel/ptrace.c
++++ b/arch/arm64/kernel/ptrace.c
+@@ -32,6 +32,7 @@
+ #include <linux/init.h>
+ #include <linux/signal.h>
+ #include <linux/uaccess.h>
++#include <swap/hook_syscall_priv.h>
+ #include <linux/perf_event.h>
+ #include <linux/hw_breakpoint.h>
+ #include <linux/regset.h>
+@@ -1160,6 +1161,9 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
+       if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+               trace_sys_enter(regs, regs->syscallno);
++      if (test_thread_flag(TIF_SWAP_HOOK_SYSCALL))
++              swap_hook_syscall_entry(regs);
++
+       audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1],
+                           regs->regs[2], regs->regs[3]);
+@@ -1170,6 +1174,9 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs)
+ {
+       audit_syscall_exit(regs);
++      if (test_thread_flag(TIF_SWAP_HOOK_SYSCALL))
++              swap_hook_syscall_exit(regs);
++
+       if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+               trace_sys_exit(regs, regs_return_value(regs));
+diff --git a/include/swap/hook_syscall_priv.h b/include/swap/hook_syscall_priv.h
+new file mode 100644
+index 0000000..33b6d70
+--- /dev/null
++++ b/include/swap/hook_syscall_priv.h
+@@ -0,0 +1,10 @@
++#ifndef _SWAP_HOOK_SYSCALL_PRIV_H
++#define _SWAP_HOOK_SYSCALL_PRIV_H
++
++
++static inline void swap_hook_syscall_update(struct task_struct *p) {}
++static inline void swap_hook_syscall_entry(struct pt_regs *regs) {}
++static inline void swap_hook_syscall_exit(struct pt_regs *regs) {}
++
++
++#endif /* _SWAP_HOOK_SYSCALL_PRIV_H */
+diff --git a/kernel/fork.c b/kernel/fork.c
+index f7f83a1..1899090 100644
+--- a/kernel/fork.c
++++ b/kernel/fork.c
+@@ -58,6 +58,7 @@
+ #include <linux/tsacct_kern.h>
+ #include <linux/cn_proc.h>
+ #include <linux/freezer.h>
++#include <swap/hook_syscall_priv.h>
+ #include <linux/delayacct.h>
+ #include <linux/taskstats_kern.h>
+ #include <linux/random.h>
+@@ -1552,6 +1553,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
+       total_forks++;
+       spin_unlock(&current->sighand->siglock);
+       syscall_tracepoint_update(p);
++      swap_hook_syscall_update(p);
+       write_unlock_irq(&tasklist_lock);
+       proc_fork_connector(p);
+-- 
+2.1.4
+