uti: Fix signal relay from mcexec to McKernel

Change-Id: I2ffd8049a0fb1637cfc6bab7fe24c6a85e5e53fc
This commit is contained in:
Masamichi Takagi
2018-09-04 09:42:16 +09:00
parent 5cb8a1f10f
commit 8c11daf726
2 changed files with 19 additions and 13 deletions

View File

@ -2467,17 +2467,20 @@ mcexec_util_thread2(ihk_os_t os, unsigned long arg, struct file *file)
return 0;
}
/* Return value: 0 if target is uti thread, -EINVAL if not */
long
mcexec_sig_thread(ihk_os_t os, unsigned long arg, struct file *file)
{
int tid = task_pid_vnr(current);
int pid = task_tgid_vnr(current);
unsigned long flags;
struct host_thread *thread;
struct host_thread *thread_iter, *thread = NULL;
long ret = 0;
read_lock_irqsave(&host_thread_lock, flags);
list_for_each_entry(thread, &host_threads, list) {
if(thread->pid == pid && thread->tid == tid) {
list_for_each_entry(thread_iter, &host_threads, list) {
if(thread_iter->pid == pid && thread_iter->tid == tid) {
thread = thread_iter;
break;
}
}
@ -2487,9 +2490,11 @@ mcexec_sig_thread(ihk_os_t os, unsigned long arg, struct file *file)
restore_fs(thread->lfs);
else
restore_fs(thread->rfs);
return 0;
goto out;
}
return -EINVAL;
ret = -EINVAL;
out:
return ret;
}
static long
@ -2560,7 +2565,7 @@ mcexec_terminate_thread(ihk_os_t os, struct terminate_thread_desc * __user arg)
long rc;
unsigned long flags;
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))) {
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 */
write_lock_irqsave(&host_thread_lock, flags);
list_for_each_entry(thread, &host_threads, list) {
if(thread->tid == desc.tid) {
list_for_each_entry(thread_iter, &host_threads, list) {
if(thread_iter->tid == desc.tid) {
thread = thread_iter;
break;
}
}

View File

@ -1154,9 +1154,9 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
int cpu;
struct signal_desc sigdesc;
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();
tid = gettid();
if (siginfo->si_pid == pid &&
@ -1189,7 +1189,7 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
remote_tid = -1;
}
if (localthread) {
if (not_uti) { /* target isn't uti thread, ask McKernel to call the handler */
memset(&sigdesc, '\0', sizeof sigdesc);
sigdesc.cpu = cpu;
sigdesc.pid = (int)pid;
@ -1201,7 +1201,7 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
exit(1);
}
}
else {
else { /* target is uti thread, mcexec calls the handler */
struct syscall_struct param;
int rc;
@ -1226,7 +1226,7 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
}
}
out:
if (!localthread)
if (!not_uti)
ioctl(fd, MCEXEC_UP_SIG_THREAD, 0);
}