DESC UML - SKAS & Ptrace: adds the host SYSEMU -v4 support, for UML and general usage EDESC From: Laurent Vivier , Jeff Dike , Paolo 'Blaisorblade' Giarrusso Adds a new ptrace(2) mode, called PTRACE_SYSEMU (or PTRACE_SYSEMU, this is yet to decide properly), resembling PTRACE_SYSCALL except that the kernel does not execute the requested syscall; this is useful for virtual environments, like UML, which want to run the syscall on their own. This patch includes some suggestions of Jeff Dike to avoid adding any instructions to the syscall fast path, plus some other little changes, by myself, to make it work even when the syscall is executed with SYSENTER (but I'm unsure about them). DESC Rename PTRACE_SCEMU to PTRACE_SYSEMU, to match the guest patch. EDESC Rename PTRACE_SCEMU to PTRACE_SYSEMU, to match the guest SYSEMU patch. DESC SYSEMU: fix behaviour when changing state EDESC In do_syscall_trace, we check the status of the TIF_SYSCALL_EMU flag only after doing the debugger notification; but the debugger might have changed the status of this flag because he continued execution with PTRACE_SYSCALL, so this is buggy. This patch fixes it by saving the flag status before calling ptrace_notify. DESC SYSEMU: avoid intercepting syscall on return when using SYSCALL again. EDESC From: Bodo Stroesser A guest process switching from using PTRACE_SYSEMU to PTRACE_SYSCALL crashes. The problem is in arch/i386/kernel/entry.S. The current SYSEMU patch inhibits the syscall-handler to be called, but does not prevent do_syscall_trace to be called after this for syscall completion interception. The appended patch fixes this. It reuses the flag TIF_SYSCALL_EMU to remember "we come from PTRACE_SYSEMU and now are in PTRACE_SYSCALL", since the flag is unused in the depicted situation. The patch is tested, AFAICS, it works fine, i.e. sysemu can be switched on and off dynamically without crash. Bodo DESC Fix PTRACE_SINGLESTEP after PTRACE_SYSEMU EDESC From: Bodo Stroesser When testing 2.6.9 and the skas3.v6 patch, with my latest patch and had problems with singlestepping on UML in SKAS with SYSEMU. It looped receiving SIGTRAPs without moving forward. EIP of the traced process was the same for all SIGTRAPs. What's missing is to handle switching from PTRACE_SYSCALL_EMU to PTRACE_SINGLESTEP in a way very similar to what is done for the change from PTRACE_SYSCALL_EMU to PTRACE_SYSCALL_TRACE. I.e., after calling ptrace(PTRACE_SYSEMU), on the return path, the debugger is notified and then wake ups the process; the syscall is executed (or skipped, when do_syscall_trace returns 0, i.e. when using PTRACE_SYSEMU), and do_syscall_trace is called again. Since we are on the return path of a SYSEMU'd syscall, if the wake up is performed through ptrace(PTRACE_SYSCALL), we must still avoid notifying the parent of the syscall exit. Now, this behaviour is extended even to resuming with PTRACE_SINGLESTEP.