um: Add kerneldoc for userspace_tramp() and start_userspace()

Also use correct function name spelling (stub_segv_handler) for better grepping

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Thomas Meyer and committed by
Richard Weinberger
e9099830 88af2338

+30 -1
+30 -1
arch/um/os-Linux/skas/process.c
··· 108 108 wait_stub_done(pid); 109 109 110 110 /* 111 - * faultinfo is prepared by the stub-segv-handler at start of 111 + * faultinfo is prepared by the stub_segv_handler at start of 112 112 * the stub stack page. We just have to copy it. 113 113 */ 114 114 memcpy(fi, (void *)current_stub_stack(), sizeof(*fi)); ··· 175 175 176 176 extern char __syscall_stub_start[]; 177 177 178 + /** 179 + * userspace_tramp() - userspace trampoline 180 + * @stack: pointer to the new userspace stack page, can be NULL, if? FIXME: 181 + * 182 + * The userspace trampoline is used to setup a new userspace process in start_userspace() after it was clone()'ed. 183 + * This function will run on a temporary stack page. 184 + * It ptrace()'es itself, then 185 + * Two pages are mapped into the userspace address space: 186 + * - STUB_CODE (with EXEC), which contains the skas stub code 187 + * - STUB_DATA (with R/W), which contains a data page that is used to transfer certain data between the UML userspace process and the UML kernel. 188 + * Also for the userspace process a SIGSEGV handler is installed to catch pagefaults in the userspace process. 189 + * And last the process stops itself to give control to the UML kernel for this userspace process. 190 + * 191 + * Return: Always zero, otherwise the current userspace process is ended with non null exit() call 192 + */ 178 193 static int userspace_tramp(void *stack) 179 194 { 180 195 void *addr; ··· 251 236 252 237 int userspace_pid[NR_CPUS]; 253 238 239 + /** 240 + * start_userspace() - prepare a new userspace process 241 + * @stub_stack: pointer to the stub stack. Can be NULL, if? FIXME: 242 + * 243 + * Setups a new temporary stack page that is used while userspace_tramp() runs 244 + * Clones the kernel process into a new userspace process, with FDs only. 245 + * 246 + * Return: When positive: the process id of the new userspace process, 247 + * when negative: an error number. 248 + * FIXME: can PIDs become negative?! 249 + */ 254 250 int start_userspace(unsigned long stub_stack) 255 251 { 256 252 void *stack; 257 253 unsigned long sp; 258 254 int pid, status, n, flags, err; 259 255 256 + /* setup a temporary stack page */ 260 257 stack = mmap(NULL, UM_KERN_PAGE_SIZE, 261 258 PROT_READ | PROT_WRITE | PROT_EXEC, 262 259 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); ··· 279 252 return err; 280 253 } 281 254 255 + /* set stack pointer to the end of the stack page, so it can grow downwards */ 282 256 sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); 283 257 284 258 flags = CLONE_FILES | SIGCHLD; 285 259 260 + /* clone into new userspace process */ 286 261 pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack); 287 262 if (pid < 0) { 288 263 err = -errno;