History log of /freebsd-src/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c (Results 1 – 25 of 34)
Revision Date Author Comments
# 8370e9df 29-Jul-2024 Mark Johnston <markj@FreeBSD.org>

vm: Remove kernel stack swapping support, part 3

- Modify PHOLD() to no longer fault in the process.
- Remove _PHOLD_LITE(), which is now the same as _PHOLD(), fix up
consumers.
- Remove faultin()

vm: Remove kernel stack swapping support, part 3

- Modify PHOLD() to no longer fault in the process.
- Remove _PHOLD_LITE(), which is now the same as _PHOLD(), fix up
consumers.
- Remove faultin() and its callees.

Tested by: pho
Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D46114

show more ...


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 3a56cfed 01-Mar-2022 Mark Johnston <markj@FreeBSD.org>

fasttrap: Avoid creating WX mappings

fasttrap instruments certain instructions by overwriting them and
copying the original instruction to some per-thread scratch space which
is executed after the p

fasttrap: Avoid creating WX mappings

fasttrap instruments certain instructions by overwriting them and
copying the original instruction to some per-thread scratch space which
is executed after the probe fires. This trampoline jumps back to the
tracepoint after executing the original instruction.

The created mapping has both write and execute permissions, and so this
mechanism doesn't work when allow_wx is disabled. Work around the
restriction by using proc_rwmem() to write to the trampoline.

Reviewed by: vangyzen
Tested by: Amit <akamit91@hotmail.com>
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34304

show more ...


# b7924341 27-Aug-2021 Andrew Turner <andrew@FreeBSD.org>

Create sys/reg.h for the common code previously in machine/reg.h

Move the common kernel function signatures from machine/reg.h to a new
sys/reg.h. This is in preperation for adding PT_GETREGSET to p

Create sys/reg.h for the common code previously in machine/reg.h

Move the common kernel function signatures from machine/reg.h to a new
sys/reg.h. This is in preperation for adding PT_GETREGSET to ptrace(2).

Reviewed by: imp, markj
Sponsored by: DARPA, AFRL (original work)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19830

show more ...


# a7af4a3e 12-Nov-2019 Konstantin Belousov <kib@FreeBSD.org>

amd64: move GDT into PCPU area.

Reviewed by: jhb, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D22302


# 8e7127fd 26-Feb-2019 Mark Johnston <markj@FreeBSD.org>

Fix fasttrap_sig{trap,segv}().

- Don't leak the ksiginfo structure.
- Hold the proc lock when sending a signal in fasttrap_sigsegv().

MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# df59ed07 26-Feb-2019 Mark Johnston <markj@FreeBSD.org>

Remove illumos-specific code from the x86 fasttrap_isa.c.

The file has not been touched upstream in over a decade, and the nature
of the code means that a lot of FreeBSD-specific bits are required.

Remove illumos-specific code from the x86 fasttrap_isa.c.

The file has not been touched upstream in over a decade, and the nature
of the code means that a lot of FreeBSD-specific bits are required. Remove
the dead code to improve readability. No functional change intended.

Discussed with: cem
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

show more ...


# f23e684b 21-Feb-2019 Mark Johnston <markj@FreeBSD.org>

Commit a missing piece of r344452.

MFC with: r344452


# 4f1b715c 21-Feb-2019 Mark Johnston <markj@FreeBSD.org>

Fix a tracepoint lookup race in fasttrap_pid_probe().

fasttrap hooks the userspace breakpoint handler; the hook looks up the
breakpoint address in a hash table of tracepoints. It is possible for
th

Fix a tracepoint lookup race in fasttrap_pid_probe().

fasttrap hooks the userspace breakpoint handler; the hook looks up the
breakpoint address in a hash table of tracepoints. It is possible for
the tracepoint to be removed by a different thread in between the
breakpoint trap and the hash table lookup, in which case SIGTRAP gets
delivered to the target process. Fix the problem by adding a
per-process generation counter that gets incremented when a tracepoint
belonging to that process is removed. Then, when a lookup fails, the
trapping instruction is restarted if the thread's counter doesn't match
that of the process.

Reviewed by: cem
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19273

show more ...


# d41e41f9 27-Mar-2018 John Baldwin <jhb@FreeBSD.org>

Remove very old and unused signal information codes.

These have been supplanted by the MI signal information codes in
<sys/signal.h> since 7.0. The FPE_*_TRAP ones were deprecated even
earlier in 1

Remove very old and unused signal information codes.

These have been supplanted by the MI signal information codes in
<sys/signal.h> since 7.0. The FPE_*_TRAP ones were deprecated even
earlier in 1999.

PR: 226579 (exp-run)
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D14637

show more ...


# 5bab6234 11-Dec-2017 Mark Johnston <markj@FreeBSD.org>

Pass the trap frame to fasttrap hooks.

The DTrace fasttrap entry points expect a struct reg containing the
register values of the calling thread. Perform the conversion in
fasttrap rather than in th

Pass the trap frame to fasttrap hooks.

The DTrace fasttrap entry points expect a struct reg containing the
register values of the calling thread. Perform the conversion in
fasttrap rather than in the trap handler: this reduces the number of
ifdefs and avoids wasting stack space for traps that don't involve
DTrace.

MFC after: 2 weeks

show more ...


# e9a2e17d 16-Nov-2017 Mark Johnston <markj@FreeBSD.org>

Avoid holding the process in uread() and uwrite().

In general, higher-level code will atomically verify that the process
is not exiting and hold the process. In one case, we were using uwrite()
to c

Avoid holding the process in uread() and uwrite().

In general, higher-level code will atomically verify that the process
is not exiting and hold the process. In one case, we were using uwrite()
to copy a probed instruction to a per-thread scratch space block, but
copyout() can be used for this purpose instead; this change effectively
reverts r227291.

MFC after: 1 week

show more ...


# da5320b9 27-Jan-2017 Mark Johnston <markj@FreeBSD.org>

Fix an off-by-one in an assertion on fasttrap tracepoint sizes.

FASTTRAP_MAX_INSTR_SIZE is the largest valid value of a tracepoint, so
correct the assertion accordingly. This limit was hit with a 15

Fix an off-by-one in an assertion on fasttrap tracepoint sizes.

FASTTRAP_MAX_INSTR_SIZE is the largest valid value of a tracepoint, so
correct the assertion accordingly. This limit was hit with a 15-byte NOP.

Reported by: bdrewery
MFC after: 1 week
Sponsored by: Dell EMC Isilon

show more ...


# 188011db 18-Nov-2016 Mark Johnston <markj@FreeBSD.org>

Support fetching RFLAGS in fasttrap_getreg().

MFC after: 1 week


# 9e579a58 24-Sep-2016 Mark Johnston <markj@FreeBSD.org>

Move implementations of uread() and uwrite() to the illumos compat layer.

MFC after: 1 week


# 57185c52 30-Jul-2016 Mark Johnston <markj@FreeBSD.org>

Restore an ifdef that should not have been removed in r303535.

X-MFC-With: r303535


# 6d1ffb50 30-Jul-2016 Mark Johnston <markj@FreeBSD.org>

Include fasttrap handling for DATAMODEL_ILP32 when compiling for amd64.

MFC after: 1 month


# 380344a7 08-Mar-2016 Mark Johnston <markj@FreeBSD.org>

Fix fasttrap tracepoint locking.

Upstream, tracepoints are protected by per-CPU mutexes. An unlinked
tracepoint may be freed once all the tracepoint mutexes have been acquired
and released - this is

Fix fasttrap tracepoint locking.

Upstream, tracepoints are protected by per-CPU mutexes. An unlinked
tracepoint may be freed once all the tracepoint mutexes have been acquired
and released - this is done in fasttrap_mod_barrier(). This mechanism was
not properly ported: in some places, the proc lock is used in place of a
tracepoint lock, and in others the locking is omitted entirely. This change
implements tracepoint locking with an rmlock, where the read lock is used
in fasttrap probe context. As a side effect, this fixes a recursion on the
proc lock when the raise action is used from a userland probe.

MFC after: 1 month

show more ...


# 711fbd17 07-Dec-2015 Mark Johnston <markj@FreeBSD.org>

Add helper functions proc_readmem() and proc_writemem().

These helper functions can be used to read in or write a buffer from or to
an arbitrary process' address space. Without them, this can only b

Add helper functions proc_readmem() and proc_writemem().

These helper functions can be used to read in or write a buffer from or to
an arbitrary process' address space. Without them, this can only be done
using proc_rwmem(), which requires the caller to fill out a uio. This is
onerous and results in code duplication; the new functions provide a simpler
interface which is sufficient for most existing callers of proc_rwmem().

This change also adds a manual page for proc_rwmem() and the new functions.

Reviewed by: jhb, kib
Differential Revision: https://reviews.freebsd.org/D4245

show more ...


# bc96366c 17-Jan-2015 Steven Hartland <smh@FreeBSD.org>

Mechanically convert cddl sun #ifdef's to illumos

Since the upstream for cddl code is now illumos not sun, mechanically
convert all sun #ifdef's to illumos #ifdef's which have been used in all
newer

Mechanically convert cddl sun #ifdef's to illumos

Since the upstream for cddl code is now illumos not sun, mechanically
convert all sun #ifdef's to illumos #ifdef's which have been used in all
newer code for some time.

Also do a manual pass to correct the use if #ifdef comments as per style(9)
as well as few uses of #if defined(__FreeBSD__) vs #ifndef illumos.

MFC after: 1 month
Sponsored by: Multiplay

show more ...


# 0626f3e4 14-Apr-2014 Mark Johnston <markj@FreeBSD.org>

DTrace's pid provider works by inserting breakpoint instructions at probe
sites and installing a hook at the kernel's trap handler. The fasttrap code
will emulate the overwritten instruction in some

DTrace's pid provider works by inserting breakpoint instructions at probe
sites and installing a hook at the kernel's trap handler. The fasttrap code
will emulate the overwritten instruction in some common cases, but otherwise
copies it out into some scratch space in the traced process' address space
and ensures that it's executed after returning from the trap.

In Solaris and illumos, this (per-thread) scratch space comes from some
reserved space in TLS, accessible via the fs segment register. This
approach is somewhat unappealing on FreeBSD since it would require some
modifications to rtld and jemalloc (for static TLS) to ensure that TLS is
executable, and would thus introduce dependencies on their implementation
details. I think it would also be impossible to safely trace static binaries
compiled without these modifications.

This change implements the functionality in a different way, by having
fasttrap map pages into the target process' address space on demand. Each
page is divided into 64-byte chunks for use by individual threads, and
fasttrap's process descriptor struct has been extended to keep track of
any scratch space allocated for the corresponding process.

With this change it's possible to trace all libc functions in a program,
e.g. with

pid$target:libc.so.*::entry {@[probefunc] = count();}

Previously this would generally cause the victim process to crash, as
tracing memcpy on amd64 requires the functionality described above.

Tested by: Prashanth Kumar <pra_udupi@yahoo.co.in> (earlier version)
MFC after: 6 weeks

show more ...


# ae520d3d 01-Mar-2014 Mark Johnston <markj@FreeBSD.org>

Fix emulation of call and jmp instructions on i386 and for 32-bit processes
on amd64.

Submitted by: Prashanth Kumar <pra_udupi@yahoo.co.in>
MFC after: 2 weeks


# 0339a1c2 27-Feb-2014 Mark Johnston <markj@FreeBSD.org>

Move some files that are identical on i386 and amd64 to an x86 subdirectory
rather than keeping duplicate copies.

Discussed with: avg
MFC after: 1 week


# 7159310f 18-Dec-2013 Mark Johnston <markj@FreeBSD.org>

The fasttrap fork handler is responsible for removing tracepoints in the
child process that were inherited from its parent. However, this should
not be done in the case of a vfork, since the fork han

The fasttrap fork handler is responsible for removing tracepoints in the
child process that were inherited from its parent. However, this should
not be done in the case of a vfork, since the fork handler ends up removing
the tracepoints from the shared vm space, and userland DTrace probes in the
parent will no longer fire as a result.

Now the child of a vfork may trigger userland DTrace probes enabled in its
parent, so modify the fasttrap probe handler to handle this case and handle
the child process in the same way that it would handle the traced process.
In particular, if once traces function foo() in a process that vforks, and
the child calls foo(), fasttrap will treat this call as having come from the
parent. This is the behaviour of the upstream code.

While here, add #ifdef guards to some code that isn't present upstream.

MFC after: 1 month

show more ...


# e53c69c1 11-Dec-2013 Mark Johnston <markj@FreeBSD.org>

Correct the check for errors from proc_rwmem().

MFC after: 2 weeks


12