From cc07d6e017173a054a62e230f29e2d4c0658256e Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Thu, 18 Apr 2019 11:31:11 +0900 Subject: [PATCH] mcctrl_get_per_thread_data: Un-inline Change-Id: I881db244ca551b3ca232918cb0b4245776f17295 Fujitsu: POSTK_DEBUG_ARCH_DEP_56 --- executer/kernel/mcctrl/mcctrl.h | 36 ++------------------------------ executer/kernel/mcctrl/syscall.c | 5 ++--- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/executer/kernel/mcctrl/mcctrl.h b/executer/kernel/mcctrl/mcctrl.h index c4a8254a..46d3c189 100644 --- a/executer/kernel/mcctrl/mcctrl.h +++ b/executer/kernel/mcctrl/mcctrl.h @@ -453,40 +453,8 @@ void mcctrl_put_per_proc_data(struct mcctrl_per_proc_data *ppd); int mcctrl_add_per_thread_data(struct mcctrl_per_proc_data *ppd, void *data); void mcctrl_put_per_thread_data_unsafe(struct mcctrl_per_thread_data *ptd); void mcctrl_put_per_thread_data(struct mcctrl_per_thread_data* ptd); -#ifdef POSTK_DEBUG_ARCH_DEP_56 /* Strange how to use inline declaration fix. */ -static inline struct mcctrl_per_thread_data *mcctrl_get_per_thread_data(struct mcctrl_per_proc_data *ppd, - struct task_struct *task) -{ - struct mcctrl_per_thread_data *ptd_iter, *ptd = NULL; - int hash = (((uint64_t)task >> 4) & MCCTRL_PER_THREAD_DATA_HASH_MASK); - unsigned long flags; - - /* Check if data for this thread exists */ - write_lock_irqsave(&ppd->per_thread_data_hash_lock[hash], flags); - - list_for_each_entry(ptd_iter, &ppd->per_thread_data_hash[hash], hash) { - if (ptd_iter->task == task) { - ptd = ptd_iter; - break; - } - } - - if (ptd) { - if (atomic_read(&ptd->refcount) <= 0) { - printk("%s: ERROR: use-after-free detected (%d)", __FUNCTION__, atomic_read(&ptd->refcount)); - ptd = NULL; - goto out; - } - atomic_inc(&ptd->refcount); - } - - out: - write_unlock_irqrestore(&ppd->per_thread_data_hash_lock[hash], flags); - return ptd; -} -#else /* POSTK_DEBUG_ARCH_DEP_56 */ -inline struct mcctrl_per_thread_data *mcctrl_get_per_thread_data(struct mcctrl_per_proc_data *ppd, struct task_struct *task); -#endif /* POSTK_DEBUG_ARCH_DEP_56 */ +struct mcctrl_per_thread_data *mcctrl_get_per_thread_data(struct mcctrl_per_proc_data *ppd, + struct task_struct *task); int mcctrl_clear_pte_range(uintptr_t start, uintptr_t len); void __return_syscall(ihk_os_t os, struct ikc_scd_packet *packet, diff --git a/executer/kernel/mcctrl/syscall.c b/executer/kernel/mcctrl/syscall.c index 9ae4f214..a22cc768 100644 --- a/executer/kernel/mcctrl/syscall.c +++ b/executer/kernel/mcctrl/syscall.c @@ -178,8 +178,8 @@ int mcctrl_add_per_thread_data(struct mcctrl_per_proc_data *ppd, void *data) return ret; } -#ifndef POSTK_DEBUG_ARCH_DEP_56 /* Strange how to use inline declaration fix. */ -struct mcctrl_per_thread_data *mcctrl_get_per_thread_data(struct mcctrl_per_proc_data *ppd, struct task_struct *task) +struct mcctrl_per_thread_data *mcctrl_get_per_thread_data(struct mcctrl_per_proc_data *ppd, + struct task_struct *task) { struct mcctrl_per_thread_data *ptd_iter, *ptd = NULL; int hash = (((uint64_t)task >> 4) & MCCTRL_PER_THREAD_DATA_HASH_MASK); @@ -208,7 +208,6 @@ struct mcctrl_per_thread_data *mcctrl_get_per_thread_data(struct mcctrl_per_proc read_unlock_irqrestore(&ppd->per_thread_data_hash_lock[hash], flags); return ptd; } -#endif /* !POSTK_DEBUG_ARCH_DEP_56 */ static int __notify_syscall_requester(ihk_os_t os, struct ikc_scd_packet *packet, struct syscall_response *res)