* [uml-devel] [PATCH 2/3] um: Add kerneldoc for segv_handler @ 2017-07-05 22:34 Thomas Meyer 2017-07-05 22:34 ` [uml-devel] [PATCH 3/3] um: Add kerneldoc for userspace_tramp() and start_userspace() Thomas Meyer 0 siblings, 1 reply; 4+ messages in thread From: Thomas Meyer @ 2017-07-05 22:34 UTC (permalink / raw) To: user-mode-linux-devel Signed-off-by: Thomas Meyer <thomas@m3y3r.de> --- arch/um/kernel/trap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c index 5915887..4e6fcb3 100644 --- a/arch/um/kernel/trap.c +++ b/arch/um/kernel/trap.c @@ -183,6 +183,16 @@ void fatal_sigsegv(void) os_dump_core(); } +/** + * segv_handler() - the SIGSEGV handler + * @sig: the signal number + * @unused_si: the signal info struct; unused in this handler + * @regs: the ptrace register information + * + * The handler first extracts the faultinfo from the UML ptrace regs struct. + * If the userfault did not happen in an UML userspace process, bad_segv is called. + * Otherwise the signal did happen in a cloned userspace process, handle it. + */ void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs) { struct faultinfo * fi = UPT_FAULTINFO(regs); -- 2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [uml-devel] [PATCH 3/3] um: Add kerneldoc for userspace_tramp() and start_userspace() 2017-07-05 22:34 [uml-devel] [PATCH 2/3] um: Add kerneldoc for segv_handler Thomas Meyer @ 2017-07-05 22:34 ` Thomas Meyer 2017-07-07 9:07 ` Richard Weinberger 0 siblings, 1 reply; 4+ messages in thread From: Thomas Meyer @ 2017-07-05 22:34 UTC (permalink / raw) To: user-mode-linux-devel Also use correct function name spelling (stub_segv_handler) for better grepping Signed-off-by: Thomas Meyer <thomas@m3y3r.de> --- arch/um/os-Linux/skas/process.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 03b3c4c..4530867 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -108,7 +108,7 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi) wait_stub_done(pid); /* - * faultinfo is prepared by the stub-segv-handler at start of + * faultinfo is prepared by the stub_segv_handler at start of * the stub stack page. We just have to copy it. */ memcpy(fi, (void *)current_stub_stack(), sizeof(*fi)); @@ -175,6 +175,21 @@ static void handle_trap(int pid, struct uml_pt_regs *regs, extern char __syscall_stub_start[]; +/** + * userspace_tramp() - userspace trampoline + * @stack: pointer to the new userspace stack page, can be NULL, if? FIXME: + * + * The userspace trampoline is used to setup a new userspace process in start_userspace() after it was clone()'ed. + * This function will run on a temporary stack page. + * It ptrace()'es itself, then + * Two pages are mapped into the userspace address space: + * - STUB_CODE (with EXEC), which contains the skas stub code + * - 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. + * Also for the userspace process a SIGSEGV handler is installed to catch pagefaults in the userspace process. + * And last the process stops itself to give control to the UML kernel for this userspace process. + * + * Return: Always zero, otherwise the current userspace process is ended with non null exit() call + */ static int userspace_tramp(void *stack) { void *addr; @@ -236,12 +251,24 @@ static int userspace_tramp(void *stack) int userspace_pid[NR_CPUS]; +/** + * start_userspace() - prepare a new userspace process + * @stub_stack: pointer to the stub stack. Can be NULL, if? FIXME: + * + * Setups a new temporary stack page that is used while userspace_tramp() runs + * Clones the kernel process into a new userspace process, with FDs only. + * + * Return: When positive: the process id of the new userspace process, + * when negative: an error number. + * FIXME: can PIDs become negative?! + */ int start_userspace(unsigned long stub_stack) { void *stack; unsigned long sp; int pid, status, n, flags, err; + /* setup a temporary stack page */ stack = mmap(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); @@ -252,10 +279,12 @@ int start_userspace(unsigned long stub_stack) return err; } + /* set stack pointer to the end of the stack page, so it can grow downwards */ sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); flags = CLONE_FILES | SIGCHLD; + /* clone into new userspace process */ pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack); if (pid < 0) { err = -errno; -- 2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [uml-devel] [PATCH 3/3] um: Add kerneldoc for userspace_tramp() and start_userspace() 2017-07-05 22:34 ` [uml-devel] [PATCH 3/3] um: Add kerneldoc for userspace_tramp() and start_userspace() Thomas Meyer @ 2017-07-07 9:07 ` Richard Weinberger 0 siblings, 0 replies; 4+ messages in thread From: Richard Weinberger @ 2017-07-07 9:07 UTC (permalink / raw) To: Thomas Meyer; +Cc: user-mode-linux-devel@lists.sourceforge.net On Thu, Jul 6, 2017 at 12:34 AM, Thomas Meyer <thomas@m3y3r.de> wrote: > Also use correct function name spelling (stub_segv_handler) for better grepping > > Signed-off-by: Thomas Meyer <thomas@m3y3r.de> > --- > arch/um/os-Linux/skas/process.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) Series applied. -- Thanks, //richard ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* [uml-devel] [PATCH 2/3] um: Add kerneldoc for segv_handler @ 2017-05-14 15:03 Thomas Meyer 0 siblings, 0 replies; 4+ messages in thread From: Thomas Meyer @ 2017-05-14 15:03 UTC (permalink / raw) To: user-mode-linux-devel@lists.sourceforge.net [-- Attachment #1.1: Type: text/plain, Size: 906 bytes --] Signed-off-by: Thomas Meyer <thomas@m3y3r.de> --- arch/um/kernel/trap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c index 5915887..4e6fcb3 100644 --- a/arch/um/kernel/trap.c +++ b/arch/um/kernel/trap.c @@ -183,6 +183,16 @@ void fatal_sigsegv(void) os_dump_core(); } +/** + * segv_handler() - the SIGSEGV handler + * @sig: the signal number + * @unused_si: the signal info struct; unused in this handler + * @regs: the ptrace register information + * + * The handler first extracts the faultinfo from the UML ptrace regs struct. + * If the userfault did not happen in an UML userspace process, bad_segv is called. + * Otherwise the signal did happen in a cloned userspace process, handle it. + */ void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs) { struct faultinfo * fi = UPT_FAULTINFO(regs); [-- Attachment #1.2: Type: text/html, Size: 7735 bytes --] [-- Attachment #2: Type: text/plain, Size: 202 bytes --] ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot [-- Attachment #3: Type: text/plain, Size: 194 bytes --] _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-07 9:07 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-05 22:34 [uml-devel] [PATCH 2/3] um: Add kerneldoc for segv_handler Thomas Meyer 2017-07-05 22:34 ` [uml-devel] [PATCH 3/3] um: Add kerneldoc for userspace_tramp() and start_userspace() Thomas Meyer 2017-07-07 9:07 ` Richard Weinberger -- strict thread matches above, loose matches on Subject: below -- 2017-05-14 15:03 [uml-devel] [PATCH 2/3] um: Add kerneldoc for segv_handler Thomas Meyer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox