summaryrefslogtreecommitdiffstats
path: root/sys/i386/linux/linux_ptrace.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC 302900,302902,302921,303461,304009:jhb2016-08-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a mask of optional ptrace() events. 302900: Add a test for user signal delivery. This test verifies we get the correct ptrace event details when a signal is posted to a traced process from userland. 302902: Add a mask of optional ptrace() events. ptrace() now stores a mask of optional events in p_ptevents. Currently this mask is a single integer, but it can be expanded into an array of integers in the future. Two new ptrace requests can be used to manipulate the event mask: PT_GET_EVENT_MASK fetches the current event mask and PT_SET_EVENT_MASK sets the current event mask. The current set of events include: - PTRACE_EXEC: trace calls to execve(). - PTRACE_SCE: trace system call entries. - PTRACE_SCX: trace syscam call exits. - PTRACE_FORK: trace forks and auto-attach to new child processes. - PTRACE_LWP: trace LWP events. The S_PT_SCX and S_PT_SCE events in the procfs p_stops flags have been replaced by PTRACE_SCE and PTRACE_SCX. PTRACE_FORK replaces P_FOLLOW_FORK and PTRACE_LWP replaces P2_LWP_EVENTS. The PT_FOLLOW_FORK and PT_LWP_EVENTS ptrace requests remain for compatibility but now simply toggle corresponding flags in the event mask. While here, document that PT_SYSCALL, PT_TO_SCE, and PT_TO_SCX both modify the event mask and continue the traced process. 302921: Rename PTRACE_SYSCALL to LINUX_PTRACE_SYSCALL. 303461: Note that not all optional ptrace events use SIGTRAP. New child processes attached due to PTRACE_FORK use SIGSTOP instead of SIGTRAP. All other ptrace events use SIGTRAP. 304009: Remove description of P_FOLLOWFORK as this flag was removed.
* Rework signal code to allow using it by other modules, like linprocfs:dchagin2015-05-241-2/+1
| | | | | | | | | | | | | | | | | 1. Linux sigset always 64 bit on all platforms. In order to move Linux sigset code to the linux_common module define it as 64 bit int. Move Linux sigset manipulation routines to the MI path. 2. Move Linux signal number definitions to the MI path. In general, they are the same on all platforms except for a few signals. 3. Map Linux RT signals to the FreeBSD RT signals and hide signal conversion tables to avoid conversion errors. 4. Emulate Linux SIGPWR signal via FreeBSD SIGRTMIN signal which is outside of allowed on Linux signal numbers. PR: 197216
* MFamd64: Add support for extended FPU states on i386. This includesjhb2014-11-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | support for AVX on i386. - Similar to amd64, move the FPU save area out of the PCB and instead store saved FPU state in a variable-sized buffer after the PCB on the stack. - To support the variable PCB location, alter the locore code to only use the bottom-most page of proc0stack for init386(). init386() returns the correct stack pointer to locore which adjusts the stack for thread0 before calling mi_startup(). - Don't bother setting cr3 in thread0's pcb in locore before calling init386(). It wasn't used (init386() overwrote it at the end) and it doesn't work with the variable-sized FPU save area. - Remove the new-bus attachment from npx. This was only ever useful for external co-processors using IRQ13, but those have not been supported for several years. npxinit() is now called much earlier during boot (init386()) similar to amd64. - Implement PT_{GET,SET}XSTATE and I386_GET_XFPUSTATE. - npxsave() is now only called from context switch contexts so it can use XSAVEOPT. Differential Revision: https://reviews.freebsd.org/D1058 Reviewed by: kib Tested on: FreeBSD/i386 VM under bhyve on Intel i5-2520
* Reduce duplication between i386/linux/linux.h and amd64/linux32/linux.hjhb2013-01-291-0/+1
| | | | | | | by moving bits that are MI out into headers in compat/linux. Reviewed by: Chagin Dmitry dmitry | gmail MFC after: 2 weeks
* Introduce the x86 kernel interfaces to allow kernel code to usekib2010-06-051-2/+2
| | | | | | | | | | | | | | | | FPU/SSE hardware. Caller should provide a save area that is chained into the stack of the areas; pcb save_area for usermode FPU state is on top. The pcb now contains a pointer to the current FPU saved area, used during FPUDNA handling and context switches. There is also a facility to allow the kernel thread to use pcb save_area. Change the dreaded warnings "npxdna in kernel mode!" into the panics when FPU usage is not registered. KPI discussed with: fabient Tested by: pho, fabient Hardware provided by: Sentex Communications MFC after: 1 month
* - Move all of the PS_ flags into either p_flag or td_flags.jeff2007-09-171-2/+2
| | | | | | | | | | | | | | - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or previously the sched_lock. These bugs have existed for some time. - Allow swapout to try each thread in a process individually and then swapin the whole process if any of these fail. This allows us to move most scheduler related swap flags into td_flags. - Keep ki_sflag for backwards compat but change all in source tools to use the new and more correct location of P_INMEM. Reported by: pho Reviewed by: attilio, kib Approved by: re (kensmith)
* Close some races between procfs/ptrace and exit(2):jhb2006-02-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Reorder the events in exit(2) slightly so that we trigger the S_EXIT stop event earlier. After we have signalled that, we set P_WEXIT and then wait for any processes with a hold on the vmspace via PHOLD to release it. PHOLD now KASSERT()'s that P_WEXIT is clear when it is invoked, and PRELE now does a wakeup if P_WEXIT is set and p_lock drops to zero. - Change proc_rwmem() to require that the processing read from has its vmspace held via PHOLD by the caller and get rid of all the junk to screw around with the vmspace reference count as we no longer need it. - In ptrace() and pseudofs(), treat a process with P_WEXIT set as if it doesn't exist. - Only do one PHOLD in kern_ptrace() now, and do it earlier so it covers FIX_SSTEP() (since on alpha at least this can end up calling proc_rwmem() to clear an earlier single-step simualted via a breakpoint). We only do one to avoid races. Also, by making the EINVAL error for unknown requests be part of the default: case in the switch, the various switch cases can now just break out to return which removes a _lot_ of duplicated PRELE and proc unlocks, etc. Also, it fixes at least one bug where a LWP ptrace command could return EINVAL with the proc lock still held. - Changed the locking for ptrace_single_step(), ptrace_set_pc(), and ptrace_clear_single_step() to always be called with the proc lock held (it was a mixed bag previously). Alpha and arm have to drop the lock while the mess around with breakpoints, but other archs avoid extra lock release/acquires in ptrace(). I did have to fix a couple of other consumers in kern_kse and a few other places to hold the proc lock and PHOLD. Tested by: ps (1 mostly, but some bits of 2-4 as well) MFC after: 1 week
* Remove the CPU_ENABLE_SSE option from the i386 and pc98 architectures,delphij2005-07-021-4/+1
| | | | | | | | | | | | | | | | | | | | | | | as they are already default for I686_CPU for almost 3 years, and CPU_DISABLE_SSE always disables it. On the other hand, CPU_ENABLE_SSE does not work for I486_CPU and I586_CPU. This commit has: - Removed the option from conf/options.* - Removed the option and comments from MD NOTES files - Simplified the CPU_ENABLE_SSE ifdef's so they don't deal with CPU_ENABLE_SSE from kernel configuration. (*) For most users, this commit should be largely no-op. If you used to place CPU_ENABLE_SSE into your kernel configuration for some reason, it is time to remove it. (*) The ifdef's of CPU_ENABLE_SSE are not removed at this point, since we need to change it to !defined(CPU_DISABLE_SSE) && defined(I686_CPU), not just !defined(CPU_DISABLE_SSE), if we really want to do so. Discussed on: -arch Approved by: re (scottl)
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-061-1/+1
|
* Fix the following race:das2004-10-011-3/+4
| | | | | | | | | | | 1. Process p1 is currently being swapped in. 2. Process p2 calls linux_ptrace(PTRACE_GETFPXREGS, p1_pid, ...) 3. After acquiring a reference to FIRST_THREAD_IN_PROC(p1), p2 blocks in faultin() while p1 finishes being swapped in. This means p2 won't get back the lock on p1 until after p1's threads are runnable. 4. After p1 is swapped in, the first thread in p1 exits. 5. p2 now uses its dangling reference to p1's first thread.
* Consistently use __inline instead of __inline__ as the former is an empty macrostefanf2004-07-041-1/+1
| | | | in <sys/cdefs.h> for compilers without support for inline.
* Use __FBSDID().obrien2003-06-021-2/+3
|
* Prefer the proc lock to sched_lock when testing PS_INMEM now that it isjhb2003-04-221-16/+8
| | | | safe to do so.
* Sync up with changes to ptrace() and use P_SHOULDSTOP instead ofjhb2003-04-151-1/+1
| | | | | | a duplicate P_TRACED check. Submitted by: marcel
* Clean up whitespace and remove register keyword.des2003-03-031-3/+3
|
* More caddr_t removal, in conjunction with copy{in,out}(9) this time.des2003-03-031-10/+9
| | | | Also clean up some egregious casts and incorrect use of sizeof.
* Removed unused includes. Sorted includes. This is part of removingbde2002-09-151-5/+1
| | | | | includes of <sys/user.h> for its pollution only. <sys/user.h> wasn't even used for its pollution here.
* Include <machine/pcb.h> instead of depending on namespace pollution inbde2002-09-071-0/+1
| | | | <sys/user.h>.
* Automatically enable CPU_ENABLE_SSE (detect and enable SSE instructions)peter2002-09-071-1/+10
| | | | | | | | if compiling with I686_CPU as a target. CPU_DISABLE_SSE will prevent this from happening and will guarantee the code is not compiled in. I am still not happy with this, but gcc is now generating code that uses these instructions if you set CPUTYPE to p3/p4 or athlon-4/mp/xp or higher.
* Split up ptrace() into a wrapper that does the copying to and fromiedowse2002-09-051-95/+52
| | | | | | | user space and a kern_ptrace() implementation. Use the kern_*() version in the Linux emulation code to remove more stack gap uses. Approved by: des
* Part 1 of KSE-IIIjulian2002-06-291-1/+1
| | | | | | | | | | | | | The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals..
* o Fix race condition caused by doing ptrace() for permissionmarcel2002-05-191-24/+44
| | | | | | | | | | | checking, followed by a lookup of the process. Do not call ptrace() for permission checking, but do it inline. Spotted by: rwatson o While here, copy-in arguments before we lock. This fixes a possible permanent lock. Reviewed by: rwatson
* Sparkling new implementation of linux_ptrace. Slight tweaking bymarcel2002-05-191-0/+507
yours truly. PR: 33299 Submitted by: Alexander N. Kabaev <ak03@gte.com>
OpenPOWER on IntegriCloud