summaryrefslogtreecommitdiff
path: root/arch/powerpc/platforms/powernv/vas.h
diff options
context:
space:
mode:
authorHaren Myneni <haren@linux.ibm.com>2020-04-16 09:02:16 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2020-04-20 09:53:00 +0300
commitdb1c08a7406351673c52594f5c8a65829baf5bf6 (patch)
treed809ccccd82d3e1e0dfafb96de4c772232ef44c1 /arch/powerpc/platforms/powernv/vas.h
parent8b8a73dc7919489b54ccd2772b2948088d3dbe6d (diff)
downloadlinux-db1c08a7406351673c52594f5c8a65829baf5bf6.tar.xz
powerpc/vas: Take reference to PID and mm for user space windows
When process opens a window, its pid and tgid will be saved in the vas_window struct. This window will be closed when the process exits. The kernel handles NX faults by updating CSB or send SEGV signal to pid of the process if the userspace csb addr is invalid. In multi-thread applications, a window can be opened by a child thread, but it will not be closed when this thread exits. It is expected that the parent will clean up all resources including NX windows opened by child threads. A child thread can send NX requests using this window and could be killed before completion is reported. If the pid assigned to this thread is reused while requests are pending, a failure SEGV would be directed to the wrong place. To prevent reusing the pid, take references to pid and mm when the window is opened and release them when when the window is closed. Then if child thread is not running, SEGV signal will be sent to thread group leader (tgid). Signed-off-by: Haren Myneni <haren@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/1587016936.2275.1057.camel@hbabu-laptop
Diffstat (limited to 'arch/powerpc/platforms/powernv/vas.h')
-rw-r--r--arch/powerpc/platforms/powernv/vas.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/powerpc/platforms/powernv/vas.h b/arch/powerpc/platforms/powernv/vas.h
index 88d084d3bfd9..2a040722dffa 100644
--- a/arch/powerpc/platforms/powernv/vas.h
+++ b/arch/powerpc/platforms/powernv/vas.h
@@ -355,7 +355,9 @@ struct vas_window {
bool user_win; /* True if user space window */
void *hvwc_map; /* HV window context */
void *uwc_map; /* OS/User window context */
- pid_t pid; /* Linux process id of owner */
+ struct pid *pid; /* Linux process id of owner */
+ struct pid *tgid; /* Thread group ID of owner */
+ struct mm_struct *mm; /* Linux process mm_struct */
int wcreds_max; /* Window credits */
char *dbgname;
@@ -430,6 +432,11 @@ extern void vas_window_init_dbgdir(struct vas_window *win);
extern void vas_window_free_dbgdir(struct vas_window *win);
extern int vas_setup_fault_window(struct vas_instance *vinst);
+static inline int vas_window_pid(struct vas_window *window)
+{
+ return pid_vnr(window->pid);
+}
+
static inline void vas_log_write(struct vas_window *win, char *name,
void *regptr, u64 val)
{