uti: Fix signal relay from mcexec to McKernel
Change-Id: I2ffd8049a0fb1637cfc6bab7fe24c6a85e5e53fc
This commit is contained in:
@ -2467,17 +2467,20 @@ mcexec_util_thread2(ihk_os_t os, unsigned long arg, struct file *file)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return value: 0 if target is uti thread, -EINVAL if not */
|
||||||
long
|
long
|
||||||
mcexec_sig_thread(ihk_os_t os, unsigned long arg, struct file *file)
|
mcexec_sig_thread(ihk_os_t os, unsigned long arg, struct file *file)
|
||||||
{
|
{
|
||||||
int tid = task_pid_vnr(current);
|
int tid = task_pid_vnr(current);
|
||||||
int pid = task_tgid_vnr(current);
|
int pid = task_tgid_vnr(current);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct host_thread *thread;
|
struct host_thread *thread_iter, *thread = NULL;
|
||||||
|
long ret = 0;
|
||||||
|
|
||||||
read_lock_irqsave(&host_thread_lock, flags);
|
read_lock_irqsave(&host_thread_lock, flags);
|
||||||
list_for_each_entry(thread, &host_threads, list) {
|
list_for_each_entry(thread_iter, &host_threads, list) {
|
||||||
if(thread->pid == pid && thread->tid == tid) {
|
if(thread_iter->pid == pid && thread_iter->tid == tid) {
|
||||||
|
thread = thread_iter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2487,9 +2490,11 @@ mcexec_sig_thread(ihk_os_t os, unsigned long arg, struct file *file)
|
|||||||
restore_fs(thread->lfs);
|
restore_fs(thread->lfs);
|
||||||
else
|
else
|
||||||
restore_fs(thread->rfs);
|
restore_fs(thread->rfs);
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
out:
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long
|
static long
|
||||||
@ -2560,7 +2565,7 @@ mcexec_terminate_thread(ihk_os_t os, struct terminate_thread_desc * __user arg)
|
|||||||
long rc;
|
long rc;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct terminate_thread_desc desc;
|
struct terminate_thread_desc desc;
|
||||||
struct host_thread *thread;
|
struct host_thread *thread_iter, *thread = NULL;
|
||||||
|
|
||||||
if (copy_from_user(&desc, arg, sizeof(struct terminate_thread_desc))) {
|
if (copy_from_user(&desc, arg, sizeof(struct terminate_thread_desc))) {
|
||||||
rc = -EFAULT;
|
rc = -EFAULT;
|
||||||
@ -2571,8 +2576,9 @@ mcexec_terminate_thread(ihk_os_t os, struct terminate_thread_desc * __user arg)
|
|||||||
|
|
||||||
/* Stop switching FS registers for uti thread */
|
/* Stop switching FS registers for uti thread */
|
||||||
write_lock_irqsave(&host_thread_lock, flags);
|
write_lock_irqsave(&host_thread_lock, flags);
|
||||||
list_for_each_entry(thread, &host_threads, list) {
|
list_for_each_entry(thread_iter, &host_threads, list) {
|
||||||
if(thread->tid == desc.tid) {
|
if(thread_iter->tid == desc.tid) {
|
||||||
|
thread = thread_iter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1154,9 +1154,9 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
|
|||||||
int cpu;
|
int cpu;
|
||||||
struct signal_desc sigdesc;
|
struct signal_desc sigdesc;
|
||||||
struct thread_data_s *tp;
|
struct thread_data_s *tp;
|
||||||
int localthread;
|
int not_uti;
|
||||||
|
|
||||||
localthread = ioctl(fd, MCEXEC_UP_SIG_THREAD, 1);
|
not_uti = ioctl(fd, MCEXEC_UP_SIG_THREAD, 1);
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
tid = gettid();
|
tid = gettid();
|
||||||
if (siginfo->si_pid == pid &&
|
if (siginfo->si_pid == pid &&
|
||||||
@ -1189,7 +1189,7 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
|
|||||||
remote_tid = -1;
|
remote_tid = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localthread) {
|
if (not_uti) { /* target isn't uti thread, ask McKernel to call the handler */
|
||||||
memset(&sigdesc, '\0', sizeof sigdesc);
|
memset(&sigdesc, '\0', sizeof sigdesc);
|
||||||
sigdesc.cpu = cpu;
|
sigdesc.cpu = cpu;
|
||||||
sigdesc.pid = (int)pid;
|
sigdesc.pid = (int)pid;
|
||||||
@ -1201,7 +1201,7 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else { /* target is uti thread, mcexec calls the handler */
|
||||||
struct syscall_struct param;
|
struct syscall_struct param;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -1226,7 +1226,7 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (!localthread)
|
if (!not_uti)
|
||||||
ioctl(fd, MCEXEC_UP_SIG_THREAD, 0);
|
ioctl(fd, MCEXEC_UP_SIG_THREAD, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user