aboutsummaryrefslogtreecommitdiff
path: root/sys/modules/dtrace
Commit message (Collapse)AuthorAgeFilesLines
* dtraceall: Enable kinst for aarch64 and riscv as wellChristos Margiolis2025-09-161-3/+3
| | | | | | | | | aarch64 and riscv are supported since 2023 so it should be safe to enable it by default. MFC after: 2 weeks Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D52575
* dtrace: Build systrace_freebsd32 only if COMPAT_FREEBSD32 is configuredMark Johnston2025-01-221-0/+2
| | | | | MFC after: 1 week Sponsored by: Innovate UK
* dtraceall: Make dtaudit a dependencyMark Johnston2024-08-121-0/+3
| | | | | | | Reported by: tsoome Reviewed by: tsoome Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D46274
* dtrace: Avoid including dtrace_isa.c directly into dtrace.cMark Johnston2024-07-241-0/+1
| | | | | | | | | | | | | | This was done in the original DTrace import, presumably because that made it a bit easier to handle includes. However, this can cause dtrace_getpcstack() to be inlined into dtrace_probe(), resulting in a missing frame in stack traces since dtrace_getpcstack() takes care to bump "aframes" to account for its own stack frame. To avoid this, compile dtrace_isa.c separately on all platforms. Add requisite includes. MFC after: 2 weeks Sponsored by: Innovate UK
* Remove residual blank line at start of MakefileWarner Losh2024-07-1517-17/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* sdt: Implement SDT probes using hot-patchingMark Johnston2024-06-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea here is to avoid a memory access and conditional branch per probe site. Instead, the probe is represented by an "unreachable" unconditional function call. asm goto is used to store the address of the probe site (represented by a no-op sled) and the address of the function call into a tracepoint record. Each SDT probe carries a list of tracepoints. When the probe is enabled, the no-op sled corresponding to each tracepoint is overwritten with a jmp to the corresponding label. The implementation uses smp_rendezvous() to park all other CPUs while the instruction is being overwritten, as this can't be done atomically in general. The compiler moves argument marshalling code and the sdt_probe() function call out-of-line, i.e., to the end of the function. Per gallatin@ in D43504, this approach has less overhead when probes are disabled. To make the implementation a bit simpler, I removed support for probes with 7 arguments; nothing makes use of this except a regression test case. It could be re-added later if need be. The approach taken in this patch enables some more improvements: 1. We can now automatically fill out the "function" field of SDT probe names. The SDT macros let the programmer specify the function and module names, but this is really a bug and shouldn't have been allowed. The intent was to be able to have the same probe in multiple functions and to let the user restrict which probes actually get enabled by specifying a function name or glob. 2. We can avoid branching on SDT_PROBES_ENABLED() by adding the ability to include blocks of code in the out-of-line path. For example: if (SDT_PROBES_ENABLED()) { int reason = CLD_EXITED; if (WCOREDUMP(signo)) reason = CLD_DUMPED; else if (WIFSIGNALED(signo)) reason = CLD_KILLED; SDT_PROBE1(proc, , , exit, reason); } could be written SDT_PROBE1_EXT(proc, , , exit, reason, int reason; reason = CLD_EXITED; if (WCOREDUMP(signo)) reason = CLD_DUMPED; else if (WIFSIGNALED(signo)) reason = CLD_KILLED; ); In the future I would like to use this mechanism more generally, e.g., to remove branches and marshalling code used by hwpmc, and generally to make it easier to add new tracepoint consumers without having to add more conditional branches to hot code paths. Reviewed by: Domagoj Stolfa, avg MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D44483
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-1617-17/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* kinst: port to arm64Christos Margiolis2023-07-191-1/+1
| | | | | | | Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40337
* kinst: port to riscvChristos Margiolis2023-07-041-0/+3
| | | | | | | Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39884
* kinst: accommodate other architectures in MakefileChristos Margiolis2023-07-041-4/+11
| | | | | | | Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40871
* dtrace: implement dtrace_instr_size() for arm64Christos Margiolis2023-05-231-1/+1
| | | | | | | Reviewed by: markj Approved by; markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39955
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* dtrace: expose dtrace_instr_size() to userland and implement it for riscvChristos Margiolis2023-04-201-0/+4
| | | | | | | | | | dtrace_instr_size() is needed by the forthcoming RISC-V port of kinst, as well as by libdtrace in D38825 for both amd64 and RISC-V. Reviewed by: markj, mhorne MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39489
* sys: Retire OPENZFS_CWARNFLAGS now that it is empty.John Baldwin2023-03-2214-14/+1
| | | | | Reviewed by: markj, emaste Differential Revision: https://reviews.freebsd.org/D39217
* dtrace: whack __mips__ from dtraceallMateusz Guzik2023-03-011-2/+1
| | | | | | Note contrib code is not modified. Sponsored by: Rubicon Communications, LLC ("Netgate")
* dtrace: include fbt module unconditionallyMitchell Horne2023-01-121-7/+3
| | | | | | | | It is supported on all platforms. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37658
* dtrace: Load fasttrap on powerpc with dtraceallJustin Hibbits2022-10-301-1/+1
| | | | | | | This was missing from the original port of DTrace to powerpc 10 years ago. MFC after: 3 weeks
* dtrace: Add pid provider to the build for powerpcJustin Hibbits2022-10-301-1/+3
| | | | | | | | The fasttrap pid provider has been in place for a long time, but stopped getting built by efe88d92da in preparation for 64-bit atomics. 32-bit emulation of 64-bit atomics was added in 9aafc7c05. MFC after: 3 weeks
* dtraceall: Automatically load kinst.ko on amd64Mark Johnston2022-10-111-0/+3
| | | | MFC after: 3 months
* kinst: Initial revisionChristos Margiolis2022-10-112-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a new DTrace provider which allows arbitrary kernel instructions to be traced. Currently it is implemented only for amd64. kinst probes are created on demand by libdtrace, and there is a probe for each kernel instruction. Probes are named kinst:<module>:<function>:<offset>, where "offset" is the offset of the target instruction relative to the beginning of the function. Omitting "offset" causes all instructions in the function to be traced. kinst works similarly to FBT in that it places a breakpoint on the target instruction and hooks into the kernel breakpoint handler. Because kinst has to be able to trace arbitrary instructions, it does not emulate most of them in software but rather causes the traced thread to execute a copy of the instruction before returning to the original code. The provider is quite low-level and as-is will be useful mostly only to kernel developers. However, it provides a great deal of visibility into kernel code execution and could be used as a building block for higher-level tooling which can in some sense translate between C sources and generated machine code. In particular, the "regs" variable recently added to D allows the CPU's register file to be accessed from kinst probes. kinst is experimental and should not be used on production systems for now. In collaboration with: markj Sponsored by: Google, Inc. (GSoC 2022) MFC after: 3 months Differential Revision: https://reviews.freebsd.org/D36851
* mips: Remove dtrace build supportWarner Losh2021-12-311-2/+0
| | | | Sponsored by: Netflix
* Export symbols from opensolaris.ko and dtrace.koMark Johnston2021-11-171-3/+1
| | | | | | | | Both modules provide many symbols used by various DTrace provider modules, so just export everything. MFC after: 1 week Sponsored by: The FreeBSD Foundation
* dtrace: Fix /"string" == NULL/ comparisons using an uninitialized value.Bryan Drewery2021-01-081-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A test of this is funcs/tst.strtok.d which has this filter: BEGIN /(this->field = strtok(this->str, ",")) == NULL/ { exit(1); } The test will randomly fail with exit status of 1 indicating that this->field was NULL even though printing it out shows it is not. This is compiled to the DTrace instruction set: // Pushed arguments not shown here // call strtok() and set result into %r1 07: 2f001f01 call DIF_SUBR(31), %r1 ! strtok // set thread local scalar this->field from %r1 08: 39050101 stls %r1, DT_VAR(1281) ! DT_VAR(1281) = "field" // Prepare for the == comparison // Set right side of %r2 to NULL 09: 25000102 setx DT_INTEGER[1], %r2 ! 0x0 // string compare %r1 (strtok result) to %r2 10: 27010200 scmp %r1, %r2 In this case only %r1 is loaded with a string limit set to lim1. %r2 being NULL does not get loaded and does not set lim2. Then we call dtrace_strncmp() with MIN(lim1, lim2) resulting in passing 0 and comparing neither side. dtrace_strncmp() handles this case fine and it already has been while being lucky with what lim2 was [un]initialized as. Reviewed by: markj, Don Morris <dgmorris AT earthlink.net> Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27671
* openzfs: fix gcc kernel module buildsRyan Libby2020-12-2713-0/+13
| | | | | | | | | | | | | | | | | - Suppress -Wredundant-decls. Ultimately this warning is harmless in any case, and it does not look like there is a simple way to avoid redundant declarations in this case without a lot of header pollution (e.g. having openzfs's shim param.h pulling in sys/kernel.h for hz). - Suppress -Wnested-externs, which is useless anyway. Unfortunately it was not sufficient just to modify OPENZFS_CFLAGS, because the warning suppressions need to appear on the command line after they are explicitly enabled by CWARNFLAGS from sys/conf/kern.mk, but OPENZFS_CFLAGS get added before due to use of -I for the shims. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D27685
* Update OpenZFS to 2.0.0-rc3-gfc5966Matt Macy2020-10-171-1/+1
| | | | | | | | | | | - fix panic due to tqid overflow - Improve libzfs_error_init messages - Expose zfetch_max_idistance tunable - Make dbufstat work on FreeBSD - Fix EIO after resuming receive of new dataset over an existing one Notes: svn path=/head/; revision=366780
* Merge OpenZFS support in to HEAD.Matt Macy2020-08-2513-44/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The primary benefit is maintaining a completely shared code base with the community allowing FreeBSD to receive new features sooner and with less effort. I would advise against doing 'zpool upgrade' or creating indispensable pools using new features until this change has had a month+ to soak. Work on merging FreeBSD support in to what was at the time "ZFS on Linux" began in August 2018. I first publicly proposed transitioning FreeBSD to (new) OpenZFS on December 18th, 2018. FreeBSD support in OpenZFS was finally completed in December 2019. A CFT for downstreaming OpenZFS support in to FreeBSD was first issued on July 8th. All issues that were reported have been addressed or, for a couple of less critical matters there are pull requests in progress with OpenZFS. iXsystems has tested and dogfooded extensively internally. The TrueNAS 12 release is based on OpenZFS with some additional features that have not yet made it upstream. Improvements include: project quotas, encrypted datasets, allocation classes, vectorized raidz, vectorized checksums, various command line improvements, zstd compression. Thanks to those who have helped along the way: Ryan Moeller, Allan Jude, Zack Welch, and many others. Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D25872 Notes: svn path=/head/; revision=364746
* Stop compiling dtrace modules with -DSMP.Mark Johnston2020-02-052-4/+0
| | | | | | | | | | | | I believe this is left over from when dtrace was being ported and developed out-of-tree. Now it just ensures that dtrace.ko and a non-SMP kernel have incompatible KBIs. PR: 243711 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357586
* Disconnect fasttrap from the 32-bit powerpc build.Mark Johnston2019-02-211-3/+2
| | | | | | | | | | | | | An upcoming bug fix requires 64-bit atomics, which aren't implemented on powerpc. The powerpc port of fasttrap is incomplete anyway and doesn't get loaded by dtraceall.ko on powerpc because of a missing dependency; it's presumed that it's effectively unused. Discussed with: jhibbits MFC after: 2 weeks Notes: svn path=/head/; revision=344450
* Move most of the contents of opt_compat.h to opt_global.h.Brooks Davis2018-04-064-11/+3
| | | | | | | | | | | | | | | | | | | | | opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941 Notes: svn path=/head/; revision=332122
* Rename assym.s to assym.incEd Maste2018-03-201-3/+3
| | | | | | | | | | | | assym is only to be included by other .s files, and should never actually be assembled by itself. Reviewed by: imp, bdrewery (earlier) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D14180 Notes: svn path=/head/; revision=331254
* Build systrace_freebsd32 on arm64.Michael Tuexen2018-01-111-0/+1
| | | | | | | | | | | Since r326501 which added COMPAT_FREEBSD32 to the GENERIC config for arm64, we need to build systrace_freebsd32, since dtraceall depends on it. Reviewed by: ed, gnn Differential Revision: https://reviews.freebsd.org/D13670 Notes: svn path=/head/; revision=327846
* sys: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326272
* Don't redefine _KERNEL.Mark Johnston2017-11-241-2/+0
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=326178
* Enable dtrace support for mips64 and the ERL kernel configKurt Lidl2017-09-063-3/+7
| | | | | | | | | | | | | | Turn on the required options in the ERL config file, and ensure that the fbt module is listed as a dependency for mips in the modules/dtrace/dtraceall/dtraceall.c file. PR: 220346 Reviewed by: gnn, markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D12227 Notes: svn path=/head/; revision=323206
* o Replace __riscv__ with __riscvRuslan Bukin2017-08-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Replace __riscv64 with (__riscv && __riscv_xlen == 64) This is required to support new GCC 7.1 compiler. This is compatible with current GCC 6.1 compiler. RISC-V is extensible ISA and the idea here is to have built-in define per each extension, so together with __riscv we will have some subset of these as well (depending on -march string passed to compiler): __riscv_compressed __riscv_atomic __riscv_mul __riscv_div __riscv_muldiv __riscv_fdiv __riscv_fsqrt __riscv_float_abi_soft __riscv_float_abi_single __riscv_float_abi_double __riscv_cmodel_medlow __riscv_cmodel_medany __riscv_cmodel_pic __riscv_xlen Reviewed by: ngie Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D11901 Notes: svn path=/head/; revision=322168
* Normalize SYSDIR on SRCTOP instead of .CURDIREnji Cooper2017-05-181-1/+1
| | | | | | | | | | This is being done to simplify pathing for CFLAGS and source files. MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=318440
* Stop building assym.o into the module.Bryan Drewery2017-04-051-15/+1
| | | | | | | | | | | | | | | | | | DTrace includes assym.s, to build this we build assym.o, however this is unneeded as assym.s only contains macros. Remove the need to build this by removing it from OBJS, but keep assym.s in the module dependencies via DPSRCS. This fixes the build when there is no assembler, e.g. on arm64 without the external binutils. Submitted by: andrew MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D10041 Notes: svn path=/head/; revision=316534
* Add an experimental DTrace audit provider, which allows users of DTrace toRobert Watson2017-03-292-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instrument security event auditing rather than relying on conventional BSM trail files or audit pipes: - Add a set of per-event 'commit' probes, which provide access to particular auditable events at the time of commit in system-call return. These probes gain access to audit data via the in-kernel audit_record data structure, providing convenient access to system-call arguments and return values in a single probe. - Add a set of per-event 'bsm' probes, which provide access to particular auditable events at the time of BSM record generation in the audit worker thread. These probes have access to the in-kernel audit_record data structure and BSM representation as would be written to a trail file or audit pipe -- i.e., asynchronously in the audit worker thread. DTrace probe arguments consist of the name of the audit event (to support future mechanisms of instrumenting multiple events via a single probe -- e.g., using classes), a pointer to the in-kernel audit record, and an optional pointer to the BSM data and its length. For human convenience, upper-case audit event names (AUE_...) are converted to lower case in DTrace. DTrace scripts can now cause additional audit-based data to be collected on system calls, and inspect internal and BSM representations of the data. They do not affect data captured in the audit trail or audit pipes configured in the system. auditd(8) must be configured and running in order to provide a database of event information, as well as other audit configuration parameters (e.g., to capture command-line arguments or environmental variables) for the provider to operate. Reviewed by: gnn, jonathan, markj Sponsored by: DARPA, AFRL MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D10149 Notes: svn path=/head/; revision=316176
* sys/modules: normalize .CURDIR-relative paths to SRCTOPEnji Cooper2017-03-0414-14/+14
| | | | | | | | | | | This simplifies make output/logic Tested with: `cd sys/modules; make ALL_MODULES=` on amd64 MFC after: 1 month Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314651
* Replace the implementation of DTrace's RAND subroutine for generatingGeorge V. Neville-Neil2017-02-033-0/+4
| | | | | | | | | | | | | | low-quality random numbers with a modern implementation (xoroshiro128+) that is capable of generating better quality randomness without compromising performance. Submitted by: Graeme Jenkinson Reviewed by: markj MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9051 Notes: svn path=/head/; revision=313176
* Add full softfloat and hardfloat support for RISC-V.Ruslan Bukin2016-11-161-0/+4
| | | | | | | | | | | Hardfloat is now default (use riscv64sf as TARGET_ARCH for softfloat). Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8529 Notes: svn path=/head/; revision=308731
* o Add support for long double.Ruslan Bukin2016-11-031-1/+1
| | | | | | | | | | o Add support for latest RISC-V GNU toolchain. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Notes: svn path=/head/; revision=308251
* Revert r303911 "Remove extra -msoft-float flags settings."Ruslan Bukin2016-08-111-0/+5
| | | | | | | This was not properly tested. Notes: svn path=/head/; revision=303959
* Remove extra -msoft-float flags settings.Ruslan Bukin2016-08-101-5/+0
| | | | | | | | | | This helps to build firmware modules. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Notes: svn path=/head/; revision=303911
* Include FBT to modules build on RISC-V.Ruslan Bukin2016-07-292-2/+4
| | | | Notes: svn path=/head/; revision=303480
* Build DTrace assym.o with -msoft-float flag for RISC-V so we haveRuslan Bukin2016-07-281-0/+5
| | | | | | | | | | correct flag in ELF file. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Notes: svn path=/head/; revision=303439
* Rename remaining linux32 symbols such as linux_sysent[] andJohn Baldwin2015-10-223-6/+23
| | | | | | | | | | | | | | | | | | | | linux_syscallnames[] from linux_* to linux32_* to avoid conflicts with linux64.ko. While here, add support for linux64 binaries to systrace. - Update NOPROTO entries in amd64/linux/syscalls.master to match the main table to fix systrace build. - Add a special case for union l_semun arguments to the systrace generation. - The systrace_linux32 module now only builds the systrace_linux32.ko. module on amd64. - Add a new systrace_linux module that builds on both i386 and amd64. For i386 it builds the existing systrace_linux.ko. For amd64 it builds a systrace_linux.ko for 64-bit binaries. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D3954 Notes: svn path=/head/; revision=289769
* Implement the lockstat provider using SDT(9) instead of the custom providerMark Johnston2015-07-194-22/+0
| | | | | | | | | | | in lockstat.ko. This means that lockstat probes now have typed arguments and will utilize SDT probe hot-patching support when it arrives. Reviewed by: gnn Differential Revision: https://reviews.freebsd.org/D2993 Notes: svn path=/head/; revision=285703