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 wait_stub_done(pid); 109 110 /* 111 - * faultinfo is prepared by the stub-segv-handler at start of 112 * the stub stack page. We just have to copy it. 113 */ 114 memcpy(fi, (void *)current_stub_stack(), sizeof(*fi)); ··· 175 176 extern char __syscall_stub_start[]; 177 178 static int userspace_tramp(void *stack) 179 { 180 void *addr; ··· 251 252 int userspace_pid[NR_CPUS]; 253 254 int start_userspace(unsigned long stub_stack) 255 { 256 void *stack; 257 unsigned long sp; 258 int pid, status, n, flags, err; 259 260 stack = mmap(NULL, UM_KERN_PAGE_SIZE, 261 PROT_READ | PROT_WRITE | PROT_EXEC, 262 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); ··· 279 return err; 280 } 281 282 sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); 283 284 flags = CLONE_FILES | SIGCHLD; 285 286 pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack); 287 if (pid < 0) { 288 err = -errno;
··· 108 wait_stub_done(pid); 109 110 /* 111 + * faultinfo is prepared by the stub_segv_handler at start of 112 * the stub stack page. We just have to copy it. 113 */ 114 memcpy(fi, (void *)current_stub_stack(), sizeof(*fi)); ··· 175 176 extern char __syscall_stub_start[]; 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 + */ 193 static int userspace_tramp(void *stack) 194 { 195 void *addr; ··· 236 237 int userspace_pid[NR_CPUS]; 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 + */ 250 int start_userspace(unsigned long stub_stack) 251 { 252 void *stack; 253 unsigned long sp; 254 int pid, status, n, flags, err; 255 256 + /* setup a temporary stack page */ 257 stack = mmap(NULL, UM_KERN_PAGE_SIZE, 258 PROT_READ | PROT_WRITE | PROT_EXEC, 259 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); ··· 252 return err; 253 } 254 255 + /* set stack pointer to the end of the stack page, so it can grow downwards */ 256 sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); 257 258 flags = CLONE_FILES | SIGCHLD; 259 260 + /* clone into new userspace process */ 261 pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack); 262 if (pid < 0) { 263 err = -errno;