From: Haren Myneni <hidden> Date: 2019-11-27 01:12:52
For each fault CRB, update fault address in CRB (fault_storage_addr)
and translation error status in CSB so that user space touch the
fault address and resend the request. If the user space passed invalid
CSB address send signal to process with SIGSEGV.
Signed-off-by: Sukadev Bhattiprolu <redacted>
Signed-off-by: Haren Myneni <haren@us.ibm.com>
---
arch/powerpc/platforms/powernv/vas-fault.c | 121 ++++++++++++++++++++++++++++-
1 file changed, 120 insertions(+), 1 deletion(-)
Shouldn't this use force_sig_fault_to_task instead?
quoted hunk
+ /*+ * User space passed invalid CSB address, Notify process with+ * SEGV signal.+ */+ tsk = get_pid_task(window->pid, PIDTYPE_PID);+ /*+ * Send window will be closed after processing all NX requests+ * and process exits after closing all windows. In multi-thread+ * applications, thread may not exists, but does not close FD+ * (means send window) upon exit. Parent thread (tgid) can use+ * and close the window later.+ */+ if (tsk) {+ if (tsk->flags & PF_EXITING)+ task_exit = 1;+ put_task_struct(tsk);+ pid = vas_window_pid(window);
The pid is later used for sending the signal again, why not keep the
reference?
Shouldn't this use force_sig_fault_to_task instead?
quoted
+ /*+ * User space passed invalid CSB address, Notify process with+ * SEGV signal.+ */+ tsk = get_pid_task(window->pid, PIDTYPE_PID);+ /*+ * Send window will be closed after processing all NX requests+ * and process exits after closing all windows. In multi-thread+ * applications, thread may not exists, but does not close FD+ * (means send window) upon exit. Parent thread (tgid) can use+ * and close the window later.+ */+ if (tsk) {+ if (tsk->flags & PF_EXITING)+ task_exit = 1;+ put_task_struct(tsk);+ pid = vas_window_pid(window);
The pid is later used for sending the signal again, why not keep the
reference?
Sorry, Not dropping the PID reference here, Happens only when window
closed. If the task for this PID is not available, looking for tgid in the
case of multi-thread process.
Why does this not need a reference to the task, but the other one does?
Window is opened with open() and ioctl(fd), will be closed either by close
(fd) explicitly or release FD during process exit.
Process closes all open windows when it exits. So we do not need to keep
the reference for this case. In multi-thread case, child thread can open a
window, but it does not release FD when it exits. Parent thread (tgid) can
continue use this window and closes it upon its exit. So taking reference
to PID in case if this pid is assigned to child thread to make sure its pid
is not reused until window is closed.
We are taking pid reference during window open and releases it when closing
the window.
Thanks
Haren
From: Haren Myneni <hidden> Date: 2019-12-06 22:49:04
<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10pt" ><div dir="ltr" ><font face="Default Monospace,Courier New,Courier,monospace" size="2" >> <br>> +static void notify_process(pid_t pid, u64 fault_addr)<br>> +{<br>> + int rc;<br>> + struct kernel_siginfo info;<br>> +<br>> + memset(&info, 0, sizeof(info));<br>> +<br>> + info.si_signo = SIGSEGV;<br>> + info.si_errno = EFAULT;<br>> + info.si_code = SEGV_MAPERR;<br>> +<br>> + info.si_addr = (void *)fault_addr;<br>> + rcu_read_lock();<br>> + rc = kill_pid_info(SIGSEGV, &info, find_vpid(pid));<br>> + rcu_read_unlock();<br>> +<br>> + pr_devel("%s(): pid %d kill_proc_info() rc %d\n", __func__, pid, rc);<br>> +}<br><br>Shouldn't this use force_sig_fault_to_task instead?</font><br> </div>
<div dir="ltr" ><font face="Default Monospace,Courier New,Courier,monospace" size="2" >User space send compression request as Coprocessor Request Block (CRB) with CSB (status block)to NX directly and polls on CSB address. NX updates CSB after processing the request. If NX sees fault on the request buffer or CSB, interrupts kernel. So generally CSB should be valid since it supposed to poll csb.flags. </font></div>
<div dir="ltr" > </div>
<div dir="ltr" ><font face="Default Monospace,Courier New,Courier,monospace" size="2" >If an application does not behave as expected or NX pastes wrong information, an error message will be printed and send signal to an application. So applications or libnxz can ignore SEGV signal or can have their own handlers. </font><br> </div></div><BR>