uti: Hook system calls by binary-patching glibc
(1) Add --enable-uti option. The binary-patch library is
preloaded with this option.
(2) Binary-patching is done by syscall_intercept developed by Intel
This commit includes the following fixes:
(1) Fix do_exit() and terminate() handling
(2) Fix timing of killing mcexec threads when McKernel thread calls terminate()
Change-Id: Iad885e1e5540ed79f0808debd372463e3b8fecea
This commit is contained in:
@ -305,6 +305,7 @@ struct mcos_handler_info;
|
||||
static LIST_HEAD(host_threads); /* Used for FS switch */
|
||||
DEFINE_RWLOCK(host_thread_lock);
|
||||
|
||||
/* Info of Linux counterpart of migrated-to-Linux thread */
|
||||
struct host_thread {
|
||||
struct list_head list;
|
||||
struct mcos_handler_info *handler;
|
||||
@ -2474,7 +2475,7 @@ mcexec_util_thread2(ihk_os_t os, unsigned long arg, struct file *file)
|
||||
exiting release_handler()
|
||||
*/
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, task_tgid_vnr(current));
|
||||
|
||||
pr_ppd("get", task_pid_vnr(current), ppd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2508,8 +2509,7 @@ mcexec_sig_thread(ihk_os_t os, unsigned long arg, struct file *file)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long
|
||||
mcexec_terminate_thread_unsafe(ihk_os_t os, int pid, int tid, long sig, struct task_struct *tsk)
|
||||
static long mcexec_terminate_thread_unsafe(ihk_os_t os, int pid, int tid, long sig, struct task_struct *tsk)
|
||||
{
|
||||
struct ikc_scd_packet *packet;
|
||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||
@ -2697,6 +2697,7 @@ long mcexec_syscall_thread(ihk_os_t os, unsigned long arg, struct file *file)
|
||||
(struct syscall_struct __user *)arg;
|
||||
long rc;
|
||||
|
||||
|
||||
if (copy_from_user(¶m, uparam, sizeof param)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
@ -299,10 +299,21 @@ static int __notify_syscall_requester(ihk_os_t os, struct ikc_scd_packet *packet
|
||||
IHK_SCD_REQ_THREAD_SPINNING,
|
||||
IHK_SCD_REQ_THREAD_TO_BE_WOKEN)) {
|
||||
dprintk("%s: no need to send IKC message for PID %d\n",
|
||||
__FUNCTION__, packet->pid);
|
||||
__FUNCTION__, packet->pid);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Wait until the status goes back to IHK_SCD_REQ_THREAD_SPINNING or
|
||||
IHK_SCD_REQ_THREAD_DESCHEDULED because two wake-up attempts are competing.
|
||||
Note that mcexec_terminate_thread() and remote page fault and
|
||||
returning EINTR would compete. */
|
||||
if (res->req_thread_status == IHK_SCD_REQ_THREAD_TO_BE_WOKEN) {
|
||||
printk("%s: INFO: someone else is waking up the McKernel thread, "
|
||||
"pid: %d, req status: %lu, syscall nr: %lu\n",
|
||||
__FUNCTION__, packet->pid,
|
||||
res->req_thread_status, packet->req.number);
|
||||
}
|
||||
|
||||
/* The thread is not spinning any more, make sure it's descheduled */
|
||||
if (!__sync_bool_compare_and_swap(&res->req_thread_status,
|
||||
IHK_SCD_REQ_THREAD_DESCHEDULED,
|
||||
@ -522,6 +533,23 @@ out_put_ppd:
|
||||
return syscall_ret;
|
||||
}
|
||||
|
||||
#if 0 /* debug */
|
||||
/* Info of Linux counterpart of migrated-to-Linux thread */
|
||||
struct host_thread {
|
||||
struct host_thread *next;
|
||||
struct mcos_handler_info *handler;
|
||||
int pid;
|
||||
int tid;
|
||||
unsigned long usp;
|
||||
unsigned long lfs;
|
||||
unsigned long rfs;
|
||||
struct task_struct *task;
|
||||
};
|
||||
|
||||
extern struct host_thread *host_threads;
|
||||
extern rwlock_t host_thread_lock;
|
||||
#endif
|
||||
|
||||
int remote_page_fault(struct mcctrl_usrdata *usrdata, void *fault_addr, uint64_t reason)
|
||||
{
|
||||
struct ikc_scd_packet *packet;
|
||||
@ -791,6 +819,8 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
/* Look up per-process structure */
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, task_tgid_vnr(current));
|
||||
if (!ppd) {
|
||||
kprintf("%s: INFO: no per-process structure for pid %d (tid %d), try to use pid %d\n",
|
||||
__FUNCTION__, task_tgid_vnr(current), task_pid_vnr(current), vma->vm_mm->owner->pid);
|
||||
ppd = mcctrl_get_per_proc_data(usrdata, vma->vm_mm->owner->pid);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user