From ccfc2236fbd2c885739b3ed99076b1be4c08f71f Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Fri, 13 Apr 2018 18:04:09 +0300 Subject: [PATCH 01/16] ARM64: Fix for changing write protected kernel memory Use the private kernel function arch64_insn_patch_text() for changing kernel memory. Change-Id: Id9eec388f135ec15f82b46d2c4227a48ae8b6e80 Signed-off-by: Vyacheslav Cherkashin --- modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c b/modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c index 77970ef..1508091 100644 --- a/modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c +++ b/modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c @@ -27,6 +27,9 @@ */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + + #include #ifdef CONFIG_SWAP_KERNEL_IMMUTABLE @@ -72,10 +75,14 @@ static void flush_icache(unsigned long addr, size_t size) flush_icache_range(addr, addr + size); } +static int (*fn_aarch64_insn_patch_text)(void *addrs[], u32 insns[], int cnt); + static void write_u32(u32 *addr, u32 val) { - *addr = val; - flush_icache((unsigned long)addr, sizeof(val)); + void *addrs[1] = { (void *)addr }; + u32 insns[1] = { (u32)val }; + + BUG_ON(fn_aarch64_insn_patch_text(addrs, insns, 1)); } void arch_kp_core_arm(struct kp_core *p) @@ -548,6 +555,14 @@ EXPORT_SYMBOL_GPL(set_jump_cb); */ int arch_init_module_deps(void) { + const char *sym = "aarch64_insn_patch_text"; + + fn_aarch64_insn_patch_text = (void *)swap_ksyms(sym); + if (!fn_aarch64_insn_patch_text) { + pr_err("Symbol '%s' not found\n", sym); + return -ESRCH; + } + return 0; } -- 2.7.4 From 3b7bec5559be4f43b5df1c82fadf7f647435cad1 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 16 Apr 2018 14:24:57 +0300 Subject: [PATCH 02/16] ktd: Fix synchronization when module is unloaded Problem: When unloading the module there was a race condition between __put_task_strcut() handler call and cleaning td struct for all tasks (after swap_ktd_uninit_top() and before swap_ktd_uninit_bottom() calls). Solution: Add get_task_flag flag to td struct. Set it if task was catched (increment task usage in swap_ktd_uninit_top() and task_prepare()). Add checking this flag and it handler to do_put_task() handler. Change-Id: I627acad69819630c02f0eaac1632b11825d856f5 Signed-off-by: Vyacheslav Cherkashin --- modules/kprobe/swap_ktd.c | 91 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/modules/kprobe/swap_ktd.c b/modules/kprobe/swap_ktd.c index 3095346..976ada6 100644 --- a/modules/kprobe/swap_ktd.c +++ b/modules/kprobe/swap_ktd.c @@ -45,6 +45,7 @@ struct td { spinlock_t flags_lock; unsigned long init_flags; + unsigned get_task_flag:1; }; @@ -147,6 +148,7 @@ static struct td *td_by_task(struct task_struct *task) return (struct td *)swap_td_raw(&td_raw, task); } +bool g_shutdown_flag; static void task_prepare(struct task_struct *task, struct td *td, struct ktask_data *ktd) @@ -166,6 +168,19 @@ static void task_prepare(struct task_struct *task, struct td *td, spin_lock_init(&td->flags_lock); td->init_flags = 0; + /* + * Set get_task_flag to true and increment task usage + * if task_prepare() called between swap_ktd_uninit_top() + * and swap_ktd_uninit_bottom(). This is necessary to clear td struct + * in functions do_put_task() or swap_ktd_uninit_bottom(). + */ + if (g_shutdown_flag) { + get_task_struct(task); + td->get_task_flag = true; + } else { + td->get_task_flag = false; + } + /* add to prepare_list */ list_add(&td->list, &prepare_list); @@ -175,6 +190,7 @@ unlock: static void ktd_exit_all(struct td *td, struct task_struct *task); +/* Called with prepare_lock held */ static void td_prepare_clear_no_lock(struct td *td, struct task_struct *task) { if (task_prepare_is(task)) { @@ -187,15 +203,6 @@ static void td_prepare_clear_no_lock(struct td *td, struct task_struct *task) } } -static void td_prepare_clear(struct td *td, struct task_struct *task) -{ - unsigned long flags; - - write_lock_irqsave(&prepare_lock, flags); - td_prepare_clear_no_lock(td, task); - write_unlock_irqrestore(&prepare_lock, flags); -} - void *swap_ktd(struct ktask_data *ktd, struct task_struct *task) { struct td *td = td_by_task(task); @@ -271,11 +278,33 @@ void swap_ktd_unreg(struct ktask_data *ktd) } EXPORT_SYMBOL_GPL(swap_ktd_unreg); +struct task_struct *g_uninit_task; static void do_put_task(struct task_struct *task) { - if (task_prepare_is(task)) - td_prepare_clear(td_by_task(task), task); + unsigned long flags; + + if (current == g_uninit_task) { + /* The 'task' is already cleaned */ + return; + } + + write_lock_irqsave(&prepare_lock, flags); + if (task_prepare_is(task)) { + struct td *td = td_by_task(task); + + if (td->get_task_flag) { + /* + * Decrement the task usage because put_task_struct() + * call will lead to infinit loop + */ + atomic_dec(&task->usage); + WARN_ON(atomic_read(&task->usage)); + } + + td_prepare_clear_no_lock(td, task); + } + write_unlock_irqrestore(&prepare_lock, flags); } #ifdef CONFIG_SWAP_HOOK_TASKDATA @@ -344,14 +373,40 @@ int swap_ktd_init(void) void swap_ktd_uninit_top(void) { - struct td *td; + struct td *td, *n; unsigned long flags; /* get injected tasks */ write_lock_irqsave(&prepare_lock, flags); - list_for_each_entry(td, &prepare_list, list) { - get_task_struct(task_by_td(td)); + list_for_each_entry_safe(td, n, &prepare_list, list) { + int usage; + struct task_struct *task = task_by_td(td); + BUG_ON(td->get_task_flag); + + get_task_struct(task); + usage = atomic_read(&task->usage); + if (usage <= 0) { + WARN(1, "Incorrect usage=%d value, in task[%u %u %s]\n", + usage, task->tgid, task->pid, task->comm); + td_prepare_clear_no_lock(td, task); + atomic_dec(&task->usage); + } else if (usage == 1) { + /* + * Case between + * atomic_dec(&task->usage) [in put_task_struct()] + * and [__put_task_struct()] handler call + ` */ + td_prepare_clear_no_lock(td, task); + atomic_dec(&task->usage); + } else { + /* if (usage > 1) */ + td->get_task_flag = true; + } } + + BUG_ON(g_shutdown_flag); + g_shutdown_flag = true; + write_unlock_irqrestore(&prepare_lock, flags); } @@ -362,12 +417,20 @@ void swap_ktd_uninit_bottom(void) /* remove td injection from tasks and put tasks */ write_lock_irqsave(&prepare_lock, flags); + g_shutdown_flag = false; + g_uninit_task = current; list_for_each_entry_safe(td, n, &prepare_list, list) { struct task_struct *task = task_by_td(td); + if (!td->get_task_flag) { + pr_err("Incorrect TD for task[%u %u %s]\n", + task->tgid, task->pid, task->comm); + BUG(); + } td_prepare_clear_no_lock(td, task); put_task_struct(task); } + g_uninit_task = NULL; write_unlock_irqrestore(&prepare_lock, flags); taskdata_uninit(); -- 2.7.4 From aac96602a094eede7d12ade40804533c01bbd68f Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Tue, 17 Apr 2018 12:33:12 +0300 Subject: [PATCH 03/16] master: add support for kernel version v4.7..v4.14 This is a workaround for fix deadlock in a kernel debugfs v4.7..v4.14 Change-Id: Ib1ad88b205f82e9503e1ca21e915a7fa2536a95b Signed-off-by: Vyacheslav Cherkashin --- modules/master/swap_debugfs.c | 106 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 96 insertions(+), 10 deletions(-) diff --git a/modules/master/swap_debugfs.c b/modules/master/swap_debugfs.c index f437016..7c23752 100644 --- a/modules/master/swap_debugfs.c +++ b/modules/master/swap_debugfs.c @@ -296,16 +296,6 @@ static ssize_t write_enable(struct file *file, const char __user *user_buf, char buf[32]; size_t buf_size; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - /* - * Global rcu-lock(debugfs_srcu) was added to debugfs - * in commit to linux-kernel:9fd4dcece43. - * It causes deadlock in debugfs_remove_recursive(). - */ - pr_err("This kernel version does not supported\n"); - return -EPERM; -#endif - buf_size = min(count, (sizeof(buf) - 1)); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; @@ -315,7 +305,101 @@ static ssize_t write_enable(struct file *file, const char __user *user_buf, return ret ? ret : count; } + +/* For kernel v4.7..v4.14 */ +#define WORKAROUND_DEADLOCK_IN_DEBUGFS ( \ + LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) \ +) + +#if WORKAROUND_DEADLOCK_IN_DEBUGFS +/* + * Global rcu-lock(debugfs_srcu) was added to kernel debugfs + * in commit 9fd4dcece43 and removed in commit c9afbec2708. + * In case write 0 to "/sys/kernel/debug/swap/enable" + * it causes deadlock in debugfs_remove_recursive(). + * + * This workaround solves this problem! + */ + + +#include + + +DEFINE_STATIC_SRCU(g_workaround_srcu); + +static ssize_t do_proxy_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + ssize_t ret; + int srcu_idx; + struct file_operations *real_fops = file->f_path.dentry->d_fsdata; + + /* use file start */ + srcu_idx = srcu_read_lock(&g_workaround_srcu); + barrier(); + + ret = real_fops->write(file, user_buf, count, ppos); + + /* use file finish */ + srcu_read_unlock(&g_workaround_srcu, srcu_idx); + + return ret; +} + +static void *g_real_proxy_write; + +static int workaround_proxy_enable_open(struct inode *inode, struct file *filp) +{ + struct file_operations *fops; + + /* remove const mode */ + fops = (struct file_operations *)filp->f_op; + + if (g_real_proxy_write) { + BUG_ON(g_real_proxy_write != fops->write); + } else { + /* save write method */ + g_real_proxy_write = fops->write; + } + + /* replace write method */ + fops->write = do_proxy_write; + + return 0; +} + +static int workaround_proxy_enable_release(struct inode *inode, + struct file *filp) +{ + struct file_operations *fops; + BUG_ON(!g_real_proxy_write); + + /* remove const mode */ + fops = (struct file_operations *)filp->f_op; + + /* restore write method */ + fops->write = g_real_proxy_write; + + return 0; +} + +static void fops_enable_sync(void) +{ + synchronize_srcu(&g_workaround_srcu); +} +#else /* WORKAROUND_DEADLOCK_IN_DEBUGFS */ +static void fops_enable_sync(void) +{ +} +#endif /* WORKAROUND_DEADLOCK_IN_DEBUGFS */ + + static const struct file_operations fops_enable = { +#if WORKAROUND_DEADLOCK_IN_DEBUGFS + .open = workaround_proxy_enable_open, + .release = workaround_proxy_enable_release, +#endif /* WORKAROUND_DEADLOCK_IN_DEBUGFS */ .owner = THIS_MODULE, .read = read_enable, .write = write_enable, @@ -351,6 +435,8 @@ static void debugfs_dir_exit(void) swap_dir = NULL; debugfs_remove_recursive(dir); + + fops_enable_sync(); } /** -- 2.7.4 From c0b2bf8d2731c7300d2ec309bdf5cd5ca2187f7d Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 23 Apr 2018 17:46:47 +0300 Subject: [PATCH 04/16] packaging: fix repacking aarch64 to armv7l Change-Id: I436b68fbff1dc586c54a5d26ac847c201dc792b5 Signed-off-by: Vyacheslav Cherkashin --- packaging/baselibs.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index 8e94d5f..b09b3c9 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -1,3 +1,4 @@ arch aarch64 targets armv7l:aarch64 swap-modules +post "/opt/swap/sdk/deploy.sh" +/ -- 2.7.4 From d7a6d4450e880eba3cde14786cbd8e5b2c0b8b7a Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 16 Apr 2018 15:37:45 +0300 Subject: [PATCH 05/16] tests: add kprobe tests for kernel and for module Change-Id: I591f52b9caf5a35374744e7961d5161049c80666 Signed-off-by: Vyacheslav Cherkashin --- modules/tests/kprobe_tests/kp_tests.c | 97 +++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/modules/tests/kprobe_tests/kp_tests.c b/modules/tests/kprobe_tests/kp_tests.c index 6386f50..627517d 100644 --- a/modules/tests/kprobe_tests/kp_tests.c +++ b/modules/tests/kprobe_tests/kp_tests.c @@ -76,6 +76,101 @@ noinline void my_kfree(const void *data) +/* + ****************************************************************************** + * kprobe in kernel * + ****************************************************************************** + */ +static int kfunc_cnt; + +static struct kprobe *kp_kfunc; +static int kfunc_h(struct kprobe *kp, struct pt_regs *regs) +{ + if (cur_task == current) + ++kfunc_cnt; + + return 0; +} + +static void run_test_kfunc(void) +{ + find_module(KBUILD_MODNAME); +} + +static void do_test_kfunc(void) +{ + kp_reg(kp_kfunc, "find_module", kfunc_h); + + run_test_kfunc(); + + kp_unreg(kp_kfunc); +} + +static void test_kfunc(void) +{ + olog("Kprob in kernel:\n"); + + kfunc_cnt = 0; + + do_test_kfunc(); + + if (kfunc_cnt == 1) + olog(" OK\n"); + else + olog(" ERROR: kfunc_cnt=%d\n", kfunc_cnt); +} + + + + +/* + ****************************************************************************** + * kprobe in module * + ****************************************************************************** + */ +static int mfunc_cnt; + +static struct kprobe *kp_mfunc; +static int mfunc_h(struct kprobe *kp, struct pt_regs *regs) +{ + if (cur_task == current) + ++mfunc_cnt; + + return 0; +} + +static void run_test_mfunc(void) +{ + my_kfree(NULL); + my_kfree(NULL); + my_kfree(NULL); +} + +static void do_test_mfunc(void) +{ + kp_reg(kp_mfunc, "my_kfree", mfunc_h); + + run_test_mfunc(); + + kp_unreg(kp_mfunc); +} + +static void test_mfunc(void) +{ + olog("Kprob in module:\n"); + + mfunc_cnt = 0; + + do_test_mfunc(); + + if (mfunc_cnt == 3) + olog(" OK\n"); + else + olog(" ERROR: mfunc_cnt=%d\n", mfunc_cnt); +} + + + /* ****************************************************************************** @@ -409,6 +504,8 @@ int kp_tests_run(void) { cur_task = current; + test_kfunc(); + test_mfunc(); test_recursion(); test_recursion_and_multiple_handlers(); test_recursion_and_multiple_handlers2(); -- 2.7.4 From b67ac707f7088c523fcf4f4badf21f8b4c37a36e Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 16 Apr 2018 15:50:48 +0300 Subject: [PATCH 06/16] tests: fix kretprobe test Change-Id: I06b58814997883f390ccc6a4dfa33816f4efa9aa Signed-off-by: Vyacheslav Cherkashin --- modules/tests/kprobe_tests/krp_tests.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/tests/kprobe_tests/krp_tests.c b/modules/tests/kprobe_tests/krp_tests.c index db59126..d39a570 100644 --- a/modules/tests/kprobe_tests/krp_tests.c +++ b/modules/tests/kprobe_tests/krp_tests.c @@ -20,6 +20,7 @@ */ +#include #include #include "kp_module.h" @@ -78,10 +79,12 @@ static long do_test_func(long v0, long v1, long v2, long v3, return v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7; } -static noinline long test_func(long v0, long v1, long v2, long v3, - long v4, long v5, long v6, long v7) +noinline long test_func(long v0, long v1, long v2, long v3, + long v4, long v5, long v6, long v7) { - return do_test_func(v0, v1, v2, v3, v4, v5, v6, v7); + long ret = do_test_func(v0, v1, v2, v3, v4, v5, v6, v7); + pr_info("CALL: ret=%ld\n", ret); + return ret; } static int test_func_eh(struct kretprobe_instance *ri, struct pt_regs *regs) @@ -149,13 +152,13 @@ static void post_test_krp(void) memcmp(&tf_data_gage, &tf_data_tmp, sizeof(tf_data_gage)) == 0) { olog(" OK\n"); } else { - olog(" ERROR:\n" - " tf_data_gage=[%ld %ld %ld %ld %ld %ld %ld %ld] ret=%ld\n" - " tf_data_tmp =[%ld %ld %ld %ld %ld %ld %ld %ld] ret=%ld\n", + olog(" ERROR:\n"); + olog(" tf_data_gage=[%ld %ld %ld %ld %ld %ld %ld %ld] ret=%ld\n", tf_data_gage.v0, tf_data_gage.v1, tf_data_gage.v2, tf_data_gage.v3, tf_data_gage.v4, tf_data_gage.v5, - tf_data_gage.v6, tf_data_gage.v7, ret, + tf_data_gage.v6, tf_data_gage.v7, ret); + olog(" tf_data_tmp =[%ld %ld %ld %ld %ld %ld %ld %ld] ret=%ld\n", tf_data_tmp.v0, tf_data_tmp.v1, tf_data_tmp.v2, tf_data_tmp.v3, tf_data_tmp.v4, tf_data_tmp.v5, -- 2.7.4 From 36c74eb1d83c3336e1ab4000720a94ba45c9fad2 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 16 Apr 2018 16:10:51 +0300 Subject: [PATCH 07/16] tests: add support for kernel >= v4.5 Change-Id: I420156efbe222c7009613253d3beb4f2dc705a76 Signed-off-by: Vyacheslav Cherkashin --- modules/tests/kprobe_tests/kp_module.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/tests/kprobe_tests/kp_module.c b/modules/tests/kprobe_tests/kp_module.c index a0e1c80..2db00c9 100644 --- a/modules/tests/kprobe_tests/kp_module.c +++ b/modules/tests/kprobe_tests/kp_module.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "kp_module.h" @@ -71,10 +72,23 @@ void olog(const char *fmt, ...) static void print_mod_info(void) { struct module *mod = THIS_MODULE; + void *init_begin, *init_end, *core_begin, *core_end; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) + init_begin = mod->init_layout.base; + init_end = mod->init_layout.base + mod->init_layout.text_size; + core_begin = mod->core_layout.base; + core_end = mod->core_layout.base + mod->core_layout.text_size; +#else + init_begin = mod->module_init; + init_end = mod->module_init + mod->init_text_size; + core_begin = mod->module_core; + core_end = mod->module_core + mod->core_text_size; +#endif printk("### MOD_INFO:\n"); - printk(" core: %p..%p\n", mod->module_init, mod->module_init + mod->init_text_size); - printk(" init: %p..%p\n", mod->module_core, mod->module_core + mod->core_text_size); + printk(" init: %p..%p\n", init_begin, init_end); + printk(" core: %p..%p\n", core_begin, core_end); printk("\n"); } -- 2.7.4 From 4753dc12056b03d7711806b553535808750c3745 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 14 May 2018 08:53:53 +0300 Subject: [PATCH 08/16] Remove structurally dead code Change-Id: I984551f439cce060b94033eb186a39ef8cb02dad Signed-off-by: Vyacheslav Cherkashin --- modules/arch/arm/probes/decode_thumb.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/arch/arm/probes/decode_thumb.c b/modules/arch/arm/probes/decode_thumb.c index 9ab32ad..ab2e723 100644 --- a/modules/arch/arm/probes/decode_thumb.c +++ b/modules/arch/arm/probes/decode_thumb.c @@ -349,8 +349,6 @@ static int t32_1110_1(thumb_insn_t insn, struct decode_info *info) } else { return t32_1110_11(insn, info); } - - return thumb_not_implement(insn, info); } static int t32_1111_0(thumb_insn_t insn, struct decode_info *info) @@ -364,8 +362,6 @@ static int t32_1111_0(thumb_insn_t insn, struct decode_info *info) /* [1111 0xxx xxxx xxxx 1xxx xxxx xxxx xxxx] */ return t32_1111_0xxx_xxxx_xxxx_1(insn, info); } - - return thumb_not_implement(insn, info); } decode_handler_t table_111x_x[4] = { -- 2.7.4 From 3bad571a84ff4cd0f9fecfaff185dd4d088b5d89 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 27 Feb 2017 19:43:24 +0300 Subject: [PATCH 09/16] ARM64: add __switch_to() support for kprobe Change-Id: I62efddef49d7863e8e5746ef0a5928cc910a4e98 Signed-off-by: Vyacheslav Cherkashin --- modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c b/modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c index 1508091..d09079a 100644 --- a/modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c +++ b/modules/kprobe/arch/arm64/swap-asm/swap_kprobes.c @@ -287,6 +287,7 @@ static int reenter_kp_core(struct kp_core *p, struct pt_regs *regs, static int post_kp_core_handler(struct kp_core_ctlblk *kcb, struct pt_regs *regs) { + bool put_curr = false; struct kp_core *cur = kp_core_running(); struct restore_data *restore = current_restore_td(); @@ -299,7 +300,7 @@ static int post_kp_core_handler(struct kp_core_ctlblk *kcb, if (is_ss_setup(restore)) { regs->pc = restore->restore_addr; restore->restore_addr = 0; - kp_core_put(cur); + put_curr = true; } else { WARN_ON(1); } @@ -312,6 +313,11 @@ static int post_kp_core_handler(struct kp_core_ctlblk *kcb, kp_core_running_set(NULL); } + if (put_curr) { + switch_to_bits_reset(current_kctx, SWITCH_TO_KP); + kp_core_put(cur); + } + return 1; } @@ -320,10 +326,15 @@ static enum dbg_code kprobe_handler(struct pt_regs *regs, unsigned int esr) struct kp_core *p, *cur; struct kp_core_ctlblk *kcb; unsigned long addr = regs->pc; - struct restore_data *restore = current_restore_td(); + struct kctx *ctx = current_kctx; + struct restore_data *restore; + + if (regs->pc == sched_addr) + switch_to_bits_set(ctx, SWITCH_TO_KP); kcb = kp_core_ctlblk(); cur = kp_core_running(); + restore = current_restore_td(); rcu_read_lock(); p = kp_core_by_addr(addr); @@ -333,8 +344,10 @@ static enum dbg_code kprobe_handler(struct pt_regs *regs, unsigned int esr) if (p) { if (cur && reenter_kp_core(p, regs, kcb)) { - if (!is_ss_setup(restore)) + if (!is_ss_setup(restore)) { + switch_to_bits_reset(ctx, SWITCH_TO_KP); kp_core_put(p); + } return DBG_HANDLED; } else if (!p->ainsn.check_condn || @@ -360,8 +373,10 @@ static enum dbg_code kprobe_handler(struct pt_regs *regs, unsigned int esr) nop_singlestep_skip(regs); } - if (!is_ss_setup(restore)) + if (!is_ss_setup(restore)) { + switch_to_bits_reset(ctx, SWITCH_TO_KP); kp_core_put(p); + } } else if (*(kprobe_opcode_t *)addr != BRK64_OPCODE_BP) { /* * The breakpoint instruction was removed right -- 2.7.4 From 10848cc0134ac145d3165b66b44de237109605da Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 4 Jul 2018 12:10:49 +0300 Subject: [PATCH 10/16] Add the swap-modules-rpi3 package build For enabling/disabling build of the swap-modules-rpi3 package set BUILD_PACKAGE_RPI3 to 1/0. Change-Id: Ib69beb17dc664abb00a13f7cfd1c6b64eaa87c1d Signed-off-by: Vyacheslav Cherkashin --- packaging/baselibs.conf | 12 ++++++++++-- packaging/swap-modules.spec | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index b09b3c9..483e88e 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -1,4 +1,12 @@ arch aarch64 targets armv7l:aarch64 + swap-modules -post "/opt/swap/sdk/deploy.sh" - +/ + post "/opt/swap/sdk/deploy.sh" + +/ + +swap-modules-rpi3 + provides "swap-modules" + provides "swap-modules = %{version}-%{release}" + post "ln -s /opt/swap/modules/rpi3 /opt/swap/sdk" + preun "rm /opt/swap/sdk" + +/ diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index 222e96b..5fa4fd4 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -9,6 +9,20 @@ Group: System Environment/Kernel Vendor: Samsung Source: swap-modules-3.0.tar.gz + +# Setup build config. +# 0 - disable +# 1 - enable +%define BUILD_PACKAGE_RPI3 1 + + +# Validate build config. +# If current architecture does not support configuration, it disables. +%ifnarch aarch64 + %define BUILD_PACKAGE_RPI3 0 +%endif + + Requires: model-config BuildRequires: perl @@ -94,6 +108,12 @@ cd modules %endif %install +mkdir -p %{buildroot}/opt/swap/modules/ + +%if %{BUILD_PACKAGE_RPI3} + cp -r /tmp/rpi3_swap_modules %{buildroot}/opt/swap/modules/rpi3 +%endif + mkdir -p %{buildroot}/opt/swap/sdk/ %ifarch armv7l mv /tmp/tm1_swap_modules %{buildroot}/opt/swap/sdk/ @@ -138,3 +158,24 @@ install -m 770 modules/deploy.sh -t %{buildroot}/opt/swap/sdk %endif %endif /opt/swap/sdk/deploy.sh + + +%if %{BUILD_PACKAGE_RPI3} +%package rpi3 +Summary: SWAP modules for RPI3 +Provides: swap-modules +Provides: swap-modules = %{version}-%{release} + +%description rpi3 +This package provides SWAP modules for RPI3 + +%post rpi3 +ln -s /opt/swap/modules/rpi3 /opt/swap/sdk + +%preun rpi3 +rm /opt/swap/sdk + +%files rpi3 +%license LICENSE.GPL-2.0+ +/opt/swap/modules/rpi3/ +%endif # BUILD_PACKAGE_RPI3 -- 2.7.4 From f82e6fe8a5b5bcb9239986dfda2eb9d3a1441391 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 4 Jul 2018 19:41:15 +0300 Subject: [PATCH 11/16] Add the swap-modules-tm2 package build For enabling/disabling build of the swap-modules-tm2 package set BUILD_PACKAGE_TM2 to 1/0. Change-Id: Idd276b96eb5a0d92ba0d8cbebe3b462482cfeb3c Signed-off-by: Vyacheslav Cherkashin --- packaging/baselibs.conf | 7 +++++++ packaging/swap-modules.spec | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index 483e88e..cabb9d3 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -4,6 +4,13 @@ swap-modules post "/opt/swap/sdk/deploy.sh" +/ +swap-modules-tm2 + provides "swap-modules" + provides "swap-modules = %{version}-%{release}" + post "ln -s /opt/swap/modules/tm2 /opt/swap/sdk" + preun "rm /opt/swap/sdk" + +/ + swap-modules-rpi3 provides "swap-modules" provides "swap-modules = %{version}-%{release}" diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index 5fa4fd4..6d9aff8 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -13,12 +13,14 @@ Source: swap-modules-3.0.tar.gz # Setup build config. # 0 - disable # 1 - enable +%define BUILD_PACKAGE_TM2 1 %define BUILD_PACKAGE_RPI3 1 # Validate build config. # If current architecture does not support configuration, it disables. %ifnarch aarch64 + %define BUILD_PACKAGE_TM2 0 %define BUILD_PACKAGE_RPI3 0 %endif @@ -110,6 +112,10 @@ cd modules %install mkdir -p %{buildroot}/opt/swap/modules/ +%if %{BUILD_PACKAGE_TM2} + cp -r /tmp/tm2_swap_modules %{buildroot}/opt/swap/modules/tm2 +%endif + %if %{BUILD_PACKAGE_RPI3} cp -r /tmp/rpi3_swap_modules %{buildroot}/opt/swap/modules/rpi3 %endif @@ -160,6 +166,26 @@ install -m 770 modules/deploy.sh -t %{buildroot}/opt/swap/sdk /opt/swap/sdk/deploy.sh +%if %{BUILD_PACKAGE_TM2} +%package tm2 +Summary: SWAP modules for TM2 +Provides: swap-modules +Provides: swap-modules = %{version}-%{release} + +%description tm2 +This package provides SWAP modules for TM2 + +%post tm2 +ln -s /opt/swap/modules/tm2 /opt/swap/sdk + +%preun tm2 +rm /opt/swap/sdk + +%files tm2 +%license LICENSE.GPL-2.0+ +/opt/swap/modules/tm2/ +%endif # BUILD_PACKAGE_TM2 + %if %{BUILD_PACKAGE_RPI3} %package rpi3 Summary: SWAP modules for RPI3 -- 2.7.4 From 1735096b40f5cffb226801d8bf53da39bb990d89 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 4 Jul 2018 19:49:23 +0300 Subject: [PATCH 12/16] Add the swap-modules-tw2 package build For enabling/disabling build of the swap-modules-tw2 package set BUILD_PACKAGE_TW2 to 1/0. Change-Id: Ic5901b57c8ace46f15552d733283c937858ee81d Signed-off-by: Vyacheslav Cherkashin --- packaging/baselibs.conf | 7 +++++++ packaging/swap-modules.spec | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index cabb9d3..b69905f 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -11,6 +11,13 @@ swap-modules-tm2 preun "rm /opt/swap/sdk" +/ +swap-modules-tw2 + provides "swap-modules" + provides "swap-modules = %{version}-%{release}" + post "ln -s /opt/swap/modules/tw2 /opt/swap/sdk" + preun "rm /opt/swap/sdk" + +/ + swap-modules-rpi3 provides "swap-modules" provides "swap-modules = %{version}-%{release}" diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index 6d9aff8..e18b173 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -14,6 +14,7 @@ Source: swap-modules-3.0.tar.gz # 0 - disable # 1 - enable %define BUILD_PACKAGE_TM2 1 +%define BUILD_PACKAGE_TW2 1 %define BUILD_PACKAGE_RPI3 1 @@ -21,6 +22,7 @@ Source: swap-modules-3.0.tar.gz # If current architecture does not support configuration, it disables. %ifnarch aarch64 %define BUILD_PACKAGE_TM2 0 + %define BUILD_PACKAGE_TW2 0 %define BUILD_PACKAGE_RPI3 0 %endif @@ -116,6 +118,10 @@ mkdir -p %{buildroot}/opt/swap/modules/ cp -r /tmp/tm2_swap_modules %{buildroot}/opt/swap/modules/tm2 %endif +%if %{BUILD_PACKAGE_TW2} + cp -r /tmp/tw2_swap_modules %{buildroot}/opt/swap/modules/tw2 +%endif + %if %{BUILD_PACKAGE_RPI3} cp -r /tmp/rpi3_swap_modules %{buildroot}/opt/swap/modules/rpi3 %endif @@ -186,6 +192,26 @@ rm /opt/swap/sdk /opt/swap/modules/tm2/ %endif # BUILD_PACKAGE_TM2 +%if %{BUILD_PACKAGE_TW2} +%package tw2 +Summary: SWAP modules for TW2 +Provides: swap-modules +Provides: swap-modules = %{version}-%{release} + +%description tw2 +This package provides SWAP modules for TW2 + +%post tw2 +ln -s /opt/swap/modules/tw2 /opt/swap/sdk + +%preun tw2 +rm /opt/swap/sdk + +%files tw2 +%license LICENSE.GPL-2.0+ +/opt/swap/modules/tw2/ +%endif # BUILD_PACKAGE_TW2 + %if %{BUILD_PACKAGE_RPI3} %package rpi3 Summary: SWAP modules for RPI3 -- 2.7.4 From 2f3289107a2aef28a50453822f41bdcec31fa5c9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 4 Jul 2018 20:18:22 +0300 Subject: [PATCH 13/16] Add the swap-modules-tm1 package build For enabling/disabling build of the swap-modules-tm1 package set BUILD_PACKAGE_TM1 to 1/0. Change-Id: I405c172ec76c6c6c5199184b6c68cbd2b168eeba Signed-off-by: Vyacheslav Cherkashin --- packaging/swap-modules.spec | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index e18b173..d79f2cb 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -13,6 +13,7 @@ Source: swap-modules-3.0.tar.gz # Setup build config. # 0 - disable # 1 - enable +%define BUILD_PACKAGE_TM1 1 %define BUILD_PACKAGE_TM2 1 %define BUILD_PACKAGE_TW2 1 %define BUILD_PACKAGE_RPI3 1 @@ -20,6 +21,9 @@ Source: swap-modules-3.0.tar.gz # Validate build config. # If current architecture does not support configuration, it disables. +%ifnarch %arm + %define BUILD_PACKAGE_TM1 0 +%endif %ifnarch aarch64 %define BUILD_PACKAGE_TM2 0 %define BUILD_PACKAGE_TW2 0 @@ -114,6 +118,10 @@ cd modules %install mkdir -p %{buildroot}/opt/swap/modules/ +%if %{BUILD_PACKAGE_TM1} + cp -r /tmp/tm1_swap_modules %{buildroot}/opt/swap/modules/tm1 +%endif + %if %{BUILD_PACKAGE_TM2} cp -r /tmp/tm2_swap_modules %{buildroot}/opt/swap/modules/tm2 %endif @@ -172,6 +180,26 @@ install -m 770 modules/deploy.sh -t %{buildroot}/opt/swap/sdk /opt/swap/sdk/deploy.sh +%if %{BUILD_PACKAGE_TM1} +%package tm1 +Summary: SWAP modules for TM1 +Provides: swap-modules +Provides: swap-modules = %{version}-%{release} + +%description tm1 +This package provides SWAP modules for TM1 + +%post tm1 +ln -s /opt/swap/modules/tm1 /opt/swap/sdk + +%preun tm1 +rm /opt/swap/sdk + +%files tm1 +%license LICENSE.GPL-2.0+ +/opt/swap/modules/tm1/ +%endif # BUILD_PACKAGE_TM1 + %if %{BUILD_PACKAGE_TM2} %package tm2 Summary: SWAP modules for TM2 -- 2.7.4 From 9c16d7f20602fcae663aecfc4b2564eb057147c0 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 4 Jul 2018 21:00:50 +0300 Subject: [PATCH 14/16] Add the swap-modules-odroidxu3 package build For enabling/disabling build of the swap-modules-odroidxu3 package set BUILD_PACKAGE_ODROIDXU3 to 1/0. Change-Id: I7efa5543b7c7eb44203f60b442623eef68550dac Signed-off-by: Vyacheslav Cherkashin --- packaging/swap-modules.spec | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index d79f2cb..0144d78 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -17,12 +17,14 @@ Source: swap-modules-3.0.tar.gz %define BUILD_PACKAGE_TM2 1 %define BUILD_PACKAGE_TW2 1 %define BUILD_PACKAGE_RPI3 1 +%define BUILD_PACKAGE_ODROIDXU3 1 # Validate build config. # If current architecture does not support configuration, it disables. %ifnarch %arm %define BUILD_PACKAGE_TM1 0 + %define BUILD_PACKAGE_ODROIDXU3 0 %endif %ifnarch aarch64 %define BUILD_PACKAGE_TM2 0 @@ -134,6 +136,10 @@ mkdir -p %{buildroot}/opt/swap/modules/ cp -r /tmp/rpi3_swap_modules %{buildroot}/opt/swap/modules/rpi3 %endif +%if %{BUILD_PACKAGE_ODROIDXU3} + cp -r /tmp/odroid_swap_modules %{buildroot}/opt/swap/modules/odroidxu3 +%endif + mkdir -p %{buildroot}/opt/swap/sdk/ %ifarch armv7l mv /tmp/tm1_swap_modules %{buildroot}/opt/swap/sdk/ @@ -259,3 +265,23 @@ rm /opt/swap/sdk %license LICENSE.GPL-2.0+ /opt/swap/modules/rpi3/ %endif # BUILD_PACKAGE_RPI3 + +%if %{BUILD_PACKAGE_ODROIDXU3} +%package odroidxu3 +Summary: SWAP modules for ODROIDXU3 +Provides: swap-modules +Provides: swap-modules = %{version}-%{release} + +%description odroidxu3 +This package provides SWAP modules for ODROIDXU3 + +%post odroidxu3 +ln -s /opt/swap/modules/odroidxu3 /opt/swap/sdk + +%preun odroidxu3 +rm /opt/swap/sdk + +%files odroidxu3 +%license LICENSE.GPL-2.0+ +/opt/swap/modules/odroidxu3/ +%endif # BUILD_PACKAGE_ODROIDXU3 -- 2.7.4 From 230b71caaedf873c975f50c7e56b118de4cd0796 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 4 Jul 2018 21:25:23 +0300 Subject: [PATCH 15/16] Add the swap-modules-emulator32 package build For enabling/disabling build of the swap-modules-emulator32 package set BUILD_PACKAGE_EMULATOR32 to 1/0. Change-Id: Ie9ba14a981fce8396198eea875c7d865a61eb65c Signed-off-by: Vyacheslav Cherkashin --- packaging/swap-modules.spec | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index 0144d78..76ec71e 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -18,10 +18,14 @@ Source: swap-modules-3.0.tar.gz %define BUILD_PACKAGE_TW2 1 %define BUILD_PACKAGE_RPI3 1 %define BUILD_PACKAGE_ODROIDXU3 1 +%define BUILD_PACKAGE_EMULATOR32 1 # Validate build config. # If current architecture does not support configuration, it disables. +%ifnarch %ix86 + %define BUILD_PACKAGE_EMULATOR32 0 +%endif %ifnarch %arm %define BUILD_PACKAGE_TM1 0 %define BUILD_PACKAGE_ODROIDXU3 0 @@ -140,6 +144,10 @@ mkdir -p %{buildroot}/opt/swap/modules/ cp -r /tmp/odroid_swap_modules %{buildroot}/opt/swap/modules/odroidxu3 %endif +%if %{BUILD_PACKAGE_EMULATOR32} + cp -r /tmp/emul_swap_modules %{buildroot}/opt/swap/modules/emulator32 +%endif + mkdir -p %{buildroot}/opt/swap/sdk/ %ifarch armv7l mv /tmp/tm1_swap_modules %{buildroot}/opt/swap/sdk/ @@ -285,3 +293,23 @@ rm /opt/swap/sdk %license LICENSE.GPL-2.0+ /opt/swap/modules/odroidxu3/ %endif # BUILD_PACKAGE_ODROIDXU3 + +%if %{BUILD_PACKAGE_EMULATOR32} +%package emulator32 +Summary: SWAP modules for Emulator x86 +Provides: swap-modules +Provides: swap-modules = %{version}-%{release} + +%description emulator32 +This package provides SWAP modules for Emulator x86 + +%post emulator32 +ln -s /opt/swap/modules/emulator32 /opt/swap/sdk + +%preun emulator32 +rm /opt/swap/sdk + +%files emulator32 +%license LICENSE.GPL-2.0+ +/opt/swap/modules/emulator32/ +%endif # BUILD_PACKAGE_EMULATOR32 -- 2.7.4 From ecffb057da4125af90e6bf7d76fbbf1917aa03be Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Fri, 6 Jul 2018 15:33:49 +0300 Subject: [PATCH 16/16] Remove swap-modules package build swap-modules package containing modules for all supported targets is obsolete and it is no longer used. Now each supported device has its own package. Change-Id: Ifbada7ada8ec551b48eea6628c6b11caa87ab31f Signed-off-by: Vyacheslav Cherkashin --- kernel_integration/sync_swap_to_kernel.sh | 1 - modules/deploy.sh | 53 --------- packaging/baselibs.conf | 4 - packaging/swap-modules.spec | 182 +++++++++--------------------- 4 files changed, 55 insertions(+), 185 deletions(-) delete mode 100755 modules/deploy.sh diff --git a/kernel_integration/sync_swap_to_kernel.sh b/kernel_integration/sync_swap_to_kernel.sh index 2fa5d6d..39223dc 100755 --- a/kernel_integration/sync_swap_to_kernel.sh +++ b/kernel_integration/sync_swap_to_kernel.sh @@ -146,7 +146,6 @@ check_file() { black_files="\ $SHORT_MODULES_SUBDIR/build.sh \ $SHORT_MODULES_SUBDIR/build.config.example \ -$SHORT_MODULES_SUBDIR/deploy.sh \ $SHORT_MODULES_SUBDIR/pack.sh \ " diff --git a/modules/deploy.sh b/modules/deploy.sh deleted file mode 100755 index 5309f27..0000000 --- a/modules/deploy.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -model=$(sed -n "s|.*tizen.org/system/model_name[^>]*>\([^<]*\)<.*|\1|p" /etc/config/model-config.xml) -modpath=/opt/swap/sdk - -case $model in -# armv7l - "TM1") - mv $modpath/tm1_swap_modules/* $modpath - rm -r $modpath/tm1_swap_modules - rm -rf $modpath/odroid_swap_modules - rm -rf $modpath/tw1_swap_modules - ;; - "xu3") - mv $modpath/odroid_swap_modules/* $modpath - rm -r $modpath/odroid_swap_modules - rm -rf $modpath/tm1_swap_modules - rm -rf $modpath/tw1_swap_modules - ;; - "TW1") - mv $modpath/tw1_swap_modules/* $modpath - rm -r $modpath/tw1_swap_modules - rm -rf $modpath/odroid_swap_modules - rm -rf $modpath/tm1_swap_modules - ;; -# x86 - "Emulator") - mv $modpath/emul_swap_modules/* $modpath - rm -r $modpath/emul_swap_modules - ;; -# aarch64 - "TM2") - mv $modpath/tm2_swap_modules/* $modpath - rm -r $modpath/tm2_swap_modules - rm -rf $modpath/rpi3_swap_modules - rm -rf $modpath/tw2_swap_modules - ;; - "TW2") - mv $modpath/tw2_swap_modules/* $modpath - rm -r $modpath/tw2_swap_modules - rm -rf $modpath/rpi3_swap_modules - rm -rf $modpath/tm2_swap_modules - ;; - "rpi3") - mv $modpath/rpi3_swap_modules/* $modpath - rm -r $modpath/rpi3_swap_modules - rm -rf $modpath/tw2_swap_modules - rm -rf $modpath/tm2_swap_modules - ;; - *) - echo "Device isn't supported" > /tmp/swap-modules_install.log - ;; -esac diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf index b69905f..456e2ed 100644 --- a/packaging/baselibs.conf +++ b/packaging/baselibs.conf @@ -1,9 +1,5 @@ arch aarch64 targets armv7l:aarch64 -swap-modules - post "/opt/swap/sdk/deploy.sh" - +/ - swap-modules-tm2 provides "swap-modules" provides "swap-modules = %{version}-%{release}" diff --git a/packaging/swap-modules.spec b/packaging/swap-modules.spec index 76ec71e..38423fc 100755 --- a/packaging/swap-modules.spec +++ b/packaging/swap-modules.spec @@ -1,5 +1,3 @@ -%bcond_with emulator - Name: swap-modules Version: 3.0 Release: 1 @@ -8,6 +6,10 @@ Summary: Linux profiler Group: System Environment/Kernel Vendor: Samsung Source: swap-modules-3.0.tar.gz +Provides: swap-modules + +%description +Kernel modules for SWAP # Setup build config. @@ -37,161 +39,76 @@ Source: swap-modules-3.0.tar.gz %endif -Requires: model-config - -BuildRequires: perl -BuildRequires: python -Provides: swap-modules - -%ifarch armv7l -# TM1 -BuildRequires: kernel-devel-3.10-sc7730 -# Odroid -BuildRequires: arm-odroidxu3-linux-kernel-devel -# TW1 -BuildRequires: kernel-devel-3.4-exynos3250 -%else - %ifarch aarch64 -# RPI3 -BuildRequires: arm64-rpi3-linux-kernel-devel -# TM2 -BuildRequires: arm64-tm2-linux-kernel-devel -# TW2 -BuildRequires: kernel-devel-exynos7270-tw2 - %else - %ifarch i586 i686 - %if %{with emulator} -BuildRequires: emulator-kernel-devel - %else -ExclusiveArch: - %endif - %else -ExclusiveArch: - %endif - %endif -%endif - -# # This exclude condition is only for public OBS. -# %if "%{_repository}" == "arm-wayland" || "%{_repository}" == "arm64-wayland" || "%{_repository}" == "ia32-wayland" || "%{_repository}" == "x86_64-wayland" -# ExclusiveArch: -# %endif - - -%description -Kernel modules for SWAP - %prep %setup -q + %build cd modules -%ifarch armv7l -# TM1 -./build.sh --kernel /boot/kernel/devel/kernel-devel-tizen_tm1 --arch arm clean -./build.sh --kernel /boot/kernel/devel/kernel-devel-tizen_tm1 --arch arm compile -./pack.sh /tmp/tm1_swap_modules/ -# Odroid -./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm clean -./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm compile -./pack.sh /tmp/odroid_swap_modules/ -# TW1 -./build.sh --kernel /boot/kernel/devel/kernel-devel-tizen_wc1 --arch arm clean -./build.sh --kernel /boot/kernel/devel/kernel-devel-tizen_wc1 --arch arm compile -./pack.sh /tmp/tw1_swap_modules/ -%else - %ifarch aarch64 -# RPI3 -./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 clean -./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 compile -./pack.sh /tmp/rpi3_swap_modules/ -# TM2 -./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-tm2 --arch arm64 clean -./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-tm2 --arch arm64 compile -./pack.sh /tmp/tm2_swap_modules/ -# TW2 -./build.sh --kernel /boot/kernel/devel/kernel-devel-tw2 --arch arm64 clean -./build.sh --kernel /boot/kernel/devel/kernel-devel-tw2 --arch arm64 compile -./pack.sh /tmp/tw2_swap_modules/ - %else - %ifarch i586 i686 -./build.sh --kernel /usr/src/kernel-devel-tizen_emulator --arch i386 clean -./build.sh --kernel /usr/src/kernel-devel-tizen_emulator --arch i386 compile -./pack.sh /tmp/emul_swap_modules/ - %endif - %endif -%endif - -%install -mkdir -p %{buildroot}/opt/swap/modules/ %if %{BUILD_PACKAGE_TM1} - cp -r /tmp/tm1_swap_modules %{buildroot}/opt/swap/modules/tm1 + ./build.sh --kernel /boot/kernel/devel/kernel-devel-tizen_tm1 --arch arm clean + ./build.sh --kernel /boot/kernel/devel/kernel-devel-tizen_tm1 --arch arm compile + ./pack.sh /tmp/modules/tm1 %endif %if %{BUILD_PACKAGE_TM2} - cp -r /tmp/tm2_swap_modules %{buildroot}/opt/swap/modules/tm2 + ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-tm2 --arch arm64 clean + ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-tm2 --arch arm64 compile + ./pack.sh /tmp/modules/tm2 %endif %if %{BUILD_PACKAGE_TW2} - cp -r /tmp/tw2_swap_modules %{buildroot}/opt/swap/modules/tw2 + ./build.sh --kernel /boot/kernel/devel/kernel-devel-tw2 --arch arm64 clean + ./build.sh --kernel /boot/kernel/devel/kernel-devel-tw2 --arch arm64 compile + ./pack.sh /tmp/modules/tw2 %endif %if %{BUILD_PACKAGE_RPI3} - cp -r /tmp/rpi3_swap_modules %{buildroot}/opt/swap/modules/rpi3 + ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 clean + ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm64-rpi3 --arch arm64 compile + ./pack.sh /tmp/modules/rpi3 %endif %if %{BUILD_PACKAGE_ODROIDXU3} - cp -r /tmp/odroid_swap_modules %{buildroot}/opt/swap/modules/odroidxu3 + ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm clean + ./build.sh --kernel /boot/kernel/devel/kernel-devel-arm-odroidxu3 --arch arm compile + ./pack.sh /tmp/modules/odroidxu3 %endif %if %{BUILD_PACKAGE_EMULATOR32} - cp -r /tmp/emul_swap_modules %{buildroot}/opt/swap/modules/emulator32 + ./build.sh --kernel /usr/src/kernel-devel-tizen_emulator --arch i386 clean + ./build.sh --kernel /usr/src/kernel-devel-tizen_emulator --arch i386 compile + ./pack.sh /tmp/modules/emulator32 %endif -mkdir -p %{buildroot}/opt/swap/sdk/ -%ifarch armv7l -mv /tmp/tm1_swap_modules %{buildroot}/opt/swap/sdk/ -mv /tmp/odroid_swap_modules %{buildroot}/opt/swap/sdk/ -mv /tmp/tw1_swap_modules %{buildroot}/opt/swap/sdk/ -%else - %ifarch aarch64 -mv /tmp/rpi3_swap_modules %{buildroot}/opt/swap/sdk/ -mv /tmp/tm2_swap_modules %{buildroot}/opt/swap/sdk/ -mv /tmp/tw2_swap_modules %{buildroot}/opt/swap/sdk/ - %else - %ifarch i586 i686 -mv /tmp/emul_swap_modules %{buildroot}/opt/swap/sdk/ - %endif - %endif + +%install +mkdir -p %{buildroot}/opt/swap/modules/ + +%if %{BUILD_PACKAGE_TM1} + mv /tmp/modules/tm1 %{buildroot}/opt/swap/modules/ %endif -install -m 770 modules/deploy.sh -t %{buildroot}/opt/swap/sdk +%if %{BUILD_PACKAGE_TM2} + mv /tmp/modules/tm2 %{buildroot}/opt/swap/modules/ +%endif -# mkdir -p %{buildroot}/usr/share/license -# cp LICENSE.GPL-2.0+ %{buildroot}/usr/share/license/%{name} +%if %{BUILD_PACKAGE_TW2} + mv /tmp/modules/tw2 %{buildroot}/opt/swap/modules/ +%endif -%post -/opt/swap/sdk/deploy.sh +%if %{BUILD_PACKAGE_RPI3} + mv /tmp/modules/rpi3 %{buildroot}/opt/swap/modules/ +%endif -%files -%license LICENSE.GPL-2.0+ -%defattr(-,root,root) -%ifarch armv7l -/opt/swap/sdk/tm1_swap_modules -/opt/swap/sdk/odroid_swap_modules -/opt/swap/sdk/tw1_swap_modules -%else - %ifarch aarch64 -/opt/swap/sdk/rpi3_swap_modules -/opt/swap/sdk/tm2_swap_modules -/opt/swap/sdk/tw2_swap_modules - %else - %ifarch i586 i686 -/opt/swap/sdk/emul_swap_modules - %endif - %endif +%if %{BUILD_PACKAGE_ODROIDXU3} + mv /tmp/modules/odroidxu3 %{buildroot}/opt/swap/modules/ +%endif + +%if %{BUILD_PACKAGE_EMULATOR32} + mv /tmp/modules/emulator32 %{buildroot}/opt/swap/modules/ %endif -/opt/swap/sdk/deploy.sh %if %{BUILD_PACKAGE_TM1} @@ -199,6 +116,7 @@ install -m 770 modules/deploy.sh -t %{buildroot}/opt/swap/sdk Summary: SWAP modules for TM1 Provides: swap-modules Provides: swap-modules = %{version}-%{release} +BuildRequires: kernel-devel-3.10-sc7730 %description tm1 This package provides SWAP modules for TM1 @@ -214,11 +132,13 @@ rm /opt/swap/sdk /opt/swap/modules/tm1/ %endif # BUILD_PACKAGE_TM1 + %if %{BUILD_PACKAGE_TM2} %package tm2 Summary: SWAP modules for TM2 Provides: swap-modules Provides: swap-modules = %{version}-%{release} +BuildRequires: arm64-tm2-linux-kernel-devel %description tm2 This package provides SWAP modules for TM2 @@ -234,11 +154,13 @@ rm /opt/swap/sdk /opt/swap/modules/tm2/ %endif # BUILD_PACKAGE_TM2 + %if %{BUILD_PACKAGE_TW2} %package tw2 Summary: SWAP modules for TW2 Provides: swap-modules Provides: swap-modules = %{version}-%{release} +BuildRequires: kernel-devel-exynos7270-tw2 %description tw2 This package provides SWAP modules for TW2 @@ -254,11 +176,13 @@ rm /opt/swap/sdk /opt/swap/modules/tw2/ %endif # BUILD_PACKAGE_TW2 + %if %{BUILD_PACKAGE_RPI3} %package rpi3 Summary: SWAP modules for RPI3 Provides: swap-modules Provides: swap-modules = %{version}-%{release} +BuildRequires: arm64-rpi3-linux-kernel-devel %description rpi3 This package provides SWAP modules for RPI3 @@ -274,11 +198,13 @@ rm /opt/swap/sdk /opt/swap/modules/rpi3/ %endif # BUILD_PACKAGE_RPI3 + %if %{BUILD_PACKAGE_ODROIDXU3} %package odroidxu3 Summary: SWAP modules for ODROIDXU3 Provides: swap-modules Provides: swap-modules = %{version}-%{release} +BuildRequires: arm-odroidxu3-linux-kernel-devel %description odroidxu3 This package provides SWAP modules for ODROIDXU3 @@ -294,11 +220,13 @@ rm /opt/swap/sdk /opt/swap/modules/odroidxu3/ %endif # BUILD_PACKAGE_ODROIDXU3 + %if %{BUILD_PACKAGE_EMULATOR32} %package emulator32 Summary: SWAP modules for Emulator x86 Provides: swap-modules Provides: swap-modules = %{version}-%{release} +BuildRequires: emulator-kernel-devel %description emulator32 This package provides SWAP modules for Emulator x86 -- 2.7.4