summaryrefslogtreecommitdiffstats
path: root/sys/cddl/dev/dtrace
Commit message (Collapse)AuthorAgeFilesLines
...
* Use a C wrapper for trap() instead of checking and calling the DTrace trapmarkj2014-07-191-3/+1
| | | | | | | | hook in assembly. Suggested by: kib Reviewed by: kib (original version) X-MFC-With: r268600
* Invoke the DTrace trap handler before calling trap() on amd64. This matchesmarkj2014-07-144-19/+18
| | | | | | | | | | | the upstream implementation and helps ensure that a trap induced by tracing fbt::trap:entry is handled without recursively generating another trap. This makes it possible to run most (but not all) of the DTrace tests under common/safety/ without triggering a kernel panic. Submitted by: Anton Rang <anton.rang@isilon.com> (original version) Phabric: D95
* Pull in r267961 and r267973 again. Fix for issues reported will follow.hselasky2014-06-281-2/+1
|
* Revert r267961, r267973:gjb2014-06-271-1/+2
| | | | | | | | | | These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifhselasky2014-06-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies
* MFV illumos r266986:rpaulo2014-06-261-0/+1
| | | | | | | | 2915 DTrace in a zone should see "cpu", "curpsinfo", et al 2916 DTrace in a zone should be able to access fds[] 2917 DTrace in a zone should have limited provider access MFC after: 2 weeks
* Continue the crusade towards a dev_clone()-free kernel, removing itsdavide2014-06-254-84/+1
| | | | | | | | | usage from dtrace. The dtrace code already uses cdevpriv(9) since FreeBSD 8, so this change should be quite harmless. Reviewed by: markj Approved by: markj MFC after: never
* Fix some bugs when fetching probe arguments in i386. Firstly ensure thatmarkj2014-06-232-10/+5
| | | | | | | | | | | the 4 byte-aligned dtrace_invop_callsite can be found and that it immediately follows the call to dtrace_invop(). Secondly, fix some pointer arithmetic to account for differences between struct i386_frame and illumos' struct frame. Finally, ensure that dtrace_getarg() isn't inlined. It works by following a fixed number of frame pointers to the probe site, so inlining breaks it. MFC after: 3 weeks
* Fix a couple of bugs on amd64 when fetching probe arguments beyond themarkj2014-06-231-10/+11
| | | | | | | | | | | | | first five for probes entered through a UD fault (i.e. FBT probes). Specifically, handle the fact that dtrace_invop_callsite must be 16 byte-aligned and thus may not immediately follow the call to dtrace_invop() in dtrace_invop_start(). Also fetch register arguments and the stack pointer through a struct trapframe instead of a struct reg. PR: 191260 Submitted by: luke.tw@gmail.com MFC after: 3 weeks
* Update dis_tables.c to the latest Illumos version.grehan2014-05-151-17/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | This includes decodes of recent Intel instructions, in particular VT-x and related instructions. This allows the FBT provider to locate the exit points of routines that include these new instructions. Illumos issues: 3414 Need a new word of AT_SUN_HWCAP bits 3415 Add isainfo support for f16c and rdrand 3416 Need disassembler support for rdrand and f16c 3413 isainfo -v overflows 80 columns 3417 mdb disassembler confuses rdtscp for invlpg 1518 dis should support AMD SVM/AMD-V/Pacifica instructions 1096 i386 disassembler should understand complex nops 1362 add kvmstat for monitoring of KVM statistics 1363 add vmregs[] variable to DTrace 1364 need disassembler support for VMX instructions 1365 mdb needs 16-bit disassembler support This corresponds to Illumos-gate (github) version eb23829ff08a873c612ac45d191d559394b4b408 Reviewed by: markj MFC after: 1 week
* DTrace's pid provider works by inserting breakpoint instructions at probemarkj2014-04-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Expose a few DTrace parameters as sysctls under kern.dtrace and addmarkj2014-03-012-3/+14
| | | | | | | | descriptions for several existing sysctls. PR: 187027 Submitted by: Fedor Indutny <fedor@indutny.com> (original version) MFC after: 2 weeks
* Fix the struct reg mappings for i386 and amd64, which differ between illumosmarkj2014-02-271-0/+51
| | | | | | | and FreeBSD. Submitted by: Prashanth Kumar <pra_udupi@yahoo.co.in> MFC after: 2 weeks
* Move some files that are identical on i386 and amd64 to an x86 subdirectorymarkj2014-02-276-5078/+0
| | | | | | | rather than keeping duplicate copies. Discussed with: avg MFC after: 1 week
* Allocate the probe ID unrhdr before the DTrace kld_* event handlers aremarkj2013-12-311-2/+2
| | | | | | | registered. Otherwise there is a small window during which probe IDs may be allocated before the unrhdr is allocated. MFC after: 2 weeks
* Revert r260091. The vmem calls seem to be slower than the *_unr() calls thatmarkj2013-12-312-4/+3
| | | | | they replaced, which is important considering that probe IDs are allocated during process startup for USDT probes.
* Now that vmem(9) is available, use vmem arenas to allocate probe andmarkj2013-12-302-3/+4
| | | | | | | | aggregation IDs, as is done in the upstream illumos code. This still requires some FreeBSD-specific code, as our vmem API is not identical to the one in illumos. Submitted by: Mike Ma <mikemandarine@gmail.com>
* dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINEavg2013-11-261-1/+1
| | | | | | | | In its stead use the Solaris / illumos approach of emulating '-' (dash) in probe names with '__' (two consecutive underscores). Reviewed by: markj MFC after: 3 weeks
* - For kernel compiled only with KDTRACE_HOOKS and not any lock debuggingattilio2013-11-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | option, unbreak the lock tracing release semantic by embedding calls to LOCKSTAT_PROFILE_RELEASE_LOCK() direclty in the inlined version of the releasing functions for mutex, rwlock and sxlock. Failing to do so skips the lockstat_probe_func invokation for unlocking. - As part of the LOCKSTAT support is inlined in mutex operation, for kernel compiled without lock debugging options, potentially every consumer must be compiled including opt_kdtrace.h. Fix this by moving KDTRACE_HOOKS into opt_global.h and remove the dependency by opt_kdtrace.h for all files, as now only KDTRACE_FRAMES is linked there and it is only used as a compile-time stub [0]. [0] immediately shows some new bug as DTRACE-derived support for debug in sfxge is broken and it was never really tested. As it was not including correctly opt_kdtrace.h before it was never enabled so it was kept broken for a while. Fix this by using a protection stub, leaving sfxge driver authors the responsibility for fixing it appropriately [1]. Sponsored by: EMC / Isilon storage division Discussed with: rstone [0] Reported by: rstone [1] Discussed with: philip
* Remove references to an unused fasttrap probe hook, and remove themarkj2013-10-311-8/+0
| | | | | | | | corresponding x86 trap type. Userland DTrace probes are currently handled by the other fasttrap hooks (dtrace_pid_probe_ptr and dtrace_return_probe_ptr). Discussed with: rpaulo
* ELF PowerPC64 ABI puts the LR save word at 16 byte offset, not 8.jhibbits2013-10-251-1/+2
|
* When fetching function arguments out of a frame on amd64, explicitly selectmarkj2013-10-211-1/+21
| | | | | | | | | | the register based on the argument index rather than relying on the fields in struct reg to be in the right order. This assumption is incorrect on FreeBSD and generally led to bogus argument values for the sixth argument of PID and USDT probes; the first five are passed directly to dtrace_probe() via the fasttrap trap handler and so were correctly handled. MFC after: 2 weeks
* Add a function, memstr, which can be used to convert a buffer ofmarkj2013-10-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | null-separated strings to a single string. This can be used to print the full arguments of a process using execsnoop (from the DTrace toolkit) or with the following one-liner: dtrace -n 'syscall::execve:return {trace(curpsinfo->pr_psargs);}' Note that this relies on the process arguments being cached via the struct proc, which means that it will not work for argvs longer than kern.ps_arg_cache_limit. However, the following rather non-portable script can be used to extract any argv at exec time: fbt::kern_execve:entry { printf("%s", memstr(args[1]->begin_argv, ' ', args[1]->begin_envv - args[1]->begin_argv)); } The debug.dtrace.memstr_max sysctl limits the maximum argument size to memstr(). Thanks to Brendan Gregg for helpful comments on freebsd-dtrace. Tested by: Fabian Keil (earlier version) MFC after: 2 weeks
* Initialize and free the DTrace taskqueue in the dtrace module load/unloadmarkj2013-10-082-0/+4
| | | | | | | | | | | | handlers rather than in the dtrace device open/close methods. The current approach can cause a panic if the device is closed which the taskqueue thread is active, or if a kernel module containing a provider is unloaded while retained enablings are present and the dtrace device isn't opened. Submitted by: gibbs (original version) Reviewed by: gibbs Approved by: re (glebius) MFC after: 2 weeks
* - Use make_dev_credf(MAKEDEV_REF) instead of the race-prone make_dev()+davide2013-09-071-5/+1
| | | | | | | | dev_ref() in the clone handlers that still use it. - Don't set SI_CHEAPCLONE flag, it's not used anywhere neither in devfs (for anything real) Reviewed by: kib
* Whitespace cleanup.jhibbits2013-09-021-48/+48
|
* Fixes for DTrace on PowerPC:jhibbits2013-08-312-88/+207
| | | | | | - Implement dtrace_getarg() - Sync fbt with x86, and fix a typo. - Pull in the time synchronization code from amd64.
* Rename the kld_unload event handler to kld_unload_try, and add a newmarkj2013-08-242-3/+3
| | | | | | | | | | | | | | kld_unload event handler which gets invoked after a linker file has been successfully unloaded. The kld_unload and kld_load event handlers are now invoked with the shared linker lock held, while kld_unload_try is invoked with the lock exclusively held. Convert hwpmc(4) to use these event handlers instead of having kern_kldload() and kern_kldunload() invoke hwpmc(4) hooks whenever files are loaded or unloaded. This has no functional effect, but simplifes the linker code somewhat. Reviewed by: jhb
* Make dtrace_copy() actually work on PowerPC. Although unused currently,jhibbits2013-08-221-4/+4
| | | | it may be used in the future by dtrace.
* Fix some ppc64 dtrace bugs, and enable systrace_freebsd32 for ppc64.jhibbits2013-08-192-0/+15
|
* Use kld_{load,unload} instead of mod_{load,unload} for the linker file loadmarkj2013-08-142-7/+7
| | | | | | | and unload event handlers added in r254266. Reported by: jhb X-MFC with: r254266
* FreeBSD's DTrace implementation has a few problems with respect to handlingmarkj2013-08-132-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | probes declared in a kernel module when that module is unloaded. In particular, * Unloading a module with active SDT probes will cause a panic. [1] * A module's (FBT/SDT) probes aren't destroyed when the module is unloaded; trying to use them after the fact will generally cause a panic. This change fixes both problems by porting the DTrace module load/unload handlers from illumos and registering them with the corresponding EVENTHANDLER(9) handlers. This allows the DTrace framework to destroy all probes defined in a module when that module is unloaded, and to prevent a module unload from proceeding if some of its probes are active. The latter problem has already been fixed for FBT probes by checking lf->nenabled in kern_kldunload(), but moving the check into the DTrace framework generalizes it to all kernel providers and also fixes a race in the current implementation (since a probe may be activated between the check and the call to linker_file_unload()). Additionally, the SDT implementation has been reworked to define SDT providers/probes/argtypes in linker sets rather than using SYSINIT/SYSUNINIT to create and destroy SDT probes when a module is loaded or unloaded. This simplifies things quite a bit since it means that pretty much all of the SDT code can live in sdt.ko, and since it becomes easier to integrate SDT with the DTrace framework. Furthermore, this allows FreeBSD to be quite flexible in that SDT providers spanning multiple modules can be created on the fly when a module is loaded; at the moment it looks like illumos' SDT implementation requires all SDT probes to be statically defined in a single kernel table. PR: 166927, 166926, 166928 Reported by: davide [1] Reviewed by: avg, trociny (earlier version) MFC after: 1 month
* opensolaris code: translate INVARIANTS to DEBUG and ZFS_DEBUGavg2013-08-062-0/+4
| | | | | | | | | | | | | | | | Do this by forcing inclusion of sys/cddl/compat/opensolaris/sys/debug_compat.h via -include option into all source files from OpenSolaris. Note that this -include option must always be after -include opt_global.h. Additionally, remove forced definition of DEBUG for some modules and fix their build without DEBUG. Also, meaning of DEBUG was overloaded to enable WITNESS support for some OpenSolaris (primarily ZFS) locks. Now this overloading is removed and that use of DEBUG is replaced with a new option OPENSOLARIS_WITNESS. MFC after: 17 days
* dtrace disassembler: take the latest/last CDDL code from OpenSolarisavg2013-07-294-388/+3680
| | | | | | | | | | | OpenSolaris version is: 13108:33bb8a0301ab 6762020 Disassembly support for Intel Advanced Vector Extensions (AVX) This corresponds to Illumos-gate (github) version ab47273fedff893c8ae22ec39ffc666d4fa6fc8b MFC after: 3 weeks
* Hide references to mod_lock. In FreeBSD it is always acquired with themarkj2013-07-053-9/+8
| | | | provider lock held, so its use has no effect.
* SDT probes can directly pass up to five arguments as arguments tomarkj2013-06-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dtrace_probe(). Arguments beyond these five must be obtained in an architecture-specific way; this can be done through the getargval provider method, and through dtrace_getarg() if getargval isn't overridden. This change fixes two off-by-one bugs in the way these arguments are fetched in FreeBSD's DTrace implementation. First, the SDT provider must set the aframes parameter to 1 when creating a probe. The aframes parameter controls the number of frames that dtrace_getarg() will step over in order to find the frame containing the extra arguments. On FreeBSD, dtrace_getarg() is called in SDT probe context via dtrace_probe()->dtrace_dif_emulate()->dtrace_dif_variable->dtrace_getarg() so aframes must be 3 since the arguments are in dtrace_probe()'s frame; it was previously being called with a value of 2 instead. illumos uses a different aframes value for SDT probes, but this is because illumos SDT probes fire by triggering the #UD fault handler rather than calling dtrace_probe() directly. The second bug has to do with the way arguments are grabbed out dtrace_probe()'s frame on amd64. The code currently jumps over the first stack argument and retrieves the rest of them using a pointer into the stack. This works on i386 because all of dtrace_probe()'s arguments will be on the stack and the first argument is the probe ID, which should be ignored. However, it is incorrect to ignore the first stack argument on amd64, so we correct the pointer used to access the arguments. MFC after: 2 weeks
* Port the SDT test now that it's possible to create SDT probes that takemarkj2013-06-021-0/+37
| | | | | | | | | | | | seven arguments. The original test uses Solaris' uadmin system call to trigger the test probe; this change adds a sysctl to the dtrace_test module and gets the test program to trigger the test probe via the sysctl handler. The test is currently failing on amd64 because of some bugs in the way that probe arguments beyond the first five are obtained - these bugs will be fixed in a separate change.
* Bring back part of r249367 by adding DTrace's temporal option, which allowsmarkj2013-05-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | users to guarantee that the output of DTrace scripts will be time-ordered. This option is enabled by adding the line #pragma D option temporal to the beginning of a script, or by adding '-x temporal' to the arguments of dtrace(1). This change fixes a bug in the original port of the temporal option. This bug was causing some assertions to fail, so they had been disabled; in this revision the assertions are working properly and are enabled. The DTrace version number has been bumped from 1.9.0 to 1.9.1 to reflect the language change that's being introduced. This change corresponds to part of illumos-gate commit e5803b76927480: 3021 option for time-ordered output from dtrace(1M) Reviewed by: pfg Obtained from: illumos MFC after: 1 month
* Add FBT for PowerPC DTrace. Also, clean up the DTrace assembly code,jhibbits2013-03-183-43/+101
| | | | | | | | | | | much of which is not necessary for PowerPC. The FBT module can likely be factored into 3 separate files: common, intel, and powerpc, rather than duplicating most of the code between the x86 and PowerPC flavors. All DTrace modules for PowerPC will be MFC'd together once Fasttrap is completed.
* Fix warning: comparison of unsigned expression < 0 is always false.pluknet2013-02-081-1/+1
| | | | Reported by: clang
* Fix the PowerPC DTrace copy functions. The kernel doesn't hold the same view tojhibbits2013-02-032-66/+61
| | | | | | the user map, so use the md copy in/out functions provided by the kernel. MFC with: r242723
* Correct a series of errors in the hand-rolled locking for drace_debug.c:rstone2012-12-231-44/+54
| | | | | | | | | | | | | | | | | | | | | - Use spinlock_enter()/spinlock_exit() to prevent a thread holding a debug lock from being preempted to prevent other threads waiting on that lock from starvation. - Handle the possibility of CPU migration in between the fetch of curcpu and the call to spinlock_enter() by saving curcpu in a local variable. - Use memory barriers to prevent reordering of loads and stores of the data protected by the lock outside of the critical section - Eliminate false sharing of the locks by moving them into the structures that they protect and aligning them to a cacheline boundary. - Record the owning thread in the lock to make debugging future problems easier. Reviewed by: rpaulo (initial version) MFC after: 2 weeks
* Implement DTrace for PowerPC. This includes both 32-bit and 64-bit.jhibbits2012-11-074-0/+1067
| | | | | | | | | | | There is one known issue: Some probes will display an error message along the lines of: "Invalid address (0)" I tested this with both a simple dtrace probe and dtruss on a few different binaries on 32-bit. I only compiled 64-bit, did not run it, but I don't expect problems without the modules loaded. Volunteers are welcome. MFC after: 1 month
* Change UL to ULL since time is 32 bits.gnn2012-07-172-2/+2
| | | | | Pointed out by: avg@ MFC after: 2 weeks
* Add support for walltimestamp in DTrace.gnn2012-07-162-4/+14
| | | | | Submitted by: Fabian Keil MFC after: 2 weeks
* r237748 continuation: fix nopw (0f 1f) behavior with respect to modifiersavg2012-07-062-2/+2
| | | | | | | | | To do: proper merge with Illumos vendor area. Reported by: emaste Tested by: emaste Obtained from: Illumos commit 13442:4adbe6de60c8 MFC after: 5 days
* r237748 continuation: segment-override prefixes are not invalid in long modeavg2012-07-062-8/+8
| | | | | | | | | | | | | Update DTrace disassembler accordingly. The code to treat the prefixes as null prefixes was already in place. Although in practice compilers seem to generate only cs-prefix for use in long NOPs, the same treatment is applied to all of cs, ds, es, ss for consistency. Reported by: emaste Tested by: emaste Obtained from: Illumos commit 13442:4adbe6de60c8 (+ local changes) MFC after: 5 days
* dtrace instruction decoder: add 0x0f 0x1f NOP opcode supportavg2012-06-292-2/+2
| | | | | | | | | | | | | | | | According to the AMD manual the whole range from 0x09 to 0x1f are NOPs. Intel manual mentions only 0x1f. Use only Intel one for now, it seems to be the one actually generated by compilers. Use gdb mnemonic for the operation: "nopw". [1] AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions [2] Software Optimization Guide for AMD Family 10h Processors [3] Intel(R) 64 and IA-32 Architectures Software Developer’s Manual Volume 2 (2A, 2B & 2C): Instruction Set Reference, A-Z Tested by: Fabian Keil <freebsd-listen@fabiankeil.de> (earlier version) MFC after: 3 days
* Integrate a fix for a very odd signal delivery problem foundgnn2012-06-042-14/+24
| | | | | | | by Bryan Cantril and others in the Solaris/Illumos version of DTrace. Obtained from: https://www.illumos.org/issues/789 MFC after: 2 weeks
* Fix DTrace TSC skew calculation:zml2012-06-042-2/+2
| | | | | | | | | | | The skew calculation here is exactly backwards. We were able to repro it on a multi-package ESX server running a FreeBSD VM, where the TSCs can be pretty evil. MFC after: 1 week Submitted by: Jeff Ford <jeffrey.ford2@isilon.com> Reviewed by: avg, gnn
OpenPOWER on IntegriCloud