summaryrefslogtreecommitdiffstats
path: root/sys/cddl/dev
Commit message (Collapse)AuthorAgeFilesLines
* MFC r264434:markj2014-07-311-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* MFC r264435:markj2014-07-291-1/+7
| | | | | Ensure that all eight syscall arguments are available to dtrace_probe(), rather than just the first five.
* MFC 267929, 267937, 267939, 267940, 267941, 267942, 267987, 268006:rpaulo2014-07-121-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 4477 DTrace should speak JSON Add stubs for CTF functions which are not yet implemented. 4474 DTrace Userland CTF Support 4475 DTrace userland Keyword 4476 DTrace tests should be better citizens 4479 pid provider types 4480 dof emulation is missing checks 4471 DTrace count() with histogram 4472 DTrace full width distribution histograms 4473 DTrace frequency trails
* MFC r262665:markj2014-05-152-2/+12
| | | | | | | Expose a few DTrace parameters as sysctls under kern.dtrace and add descriptions for several existing sysctls. PR: 187027
* MFC r262543:markj2014-05-031-0/+51
| | | | | Fix the struct reg mappings for i386 and amd64, which differ between illumos and FreeBSD.
* MFC r262542:markj2014-05-036-5078/+0
| | | | | Move some files that are identical on i386 and amd64 to an x86 subdirectory rather than keeping duplicate copies.
* MFC r260132: Allocate the probe ID unrhdr before the DTrace kld_* eventavg2014-02-171-2/+2
| | | | handlers are registered
* MFC r257417: Remove references to an unused fasttrap probe hookavg2014-02-171-8/+0
|
* MFC r257152: Do some cleanup of the SDT codeavg2014-02-171-71/+68
|
* MFC r258622: dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINEavg2014-01-172-2/+15
|
* MFC r256543,r259245,r259421,r259668,r259674jhibbits2014-01-151-2/+2
| | | | | | | | | | | | | | | | | | | r256543: Add fasttrap for PowerPC. This is the last piece of the DTrace/ppc puzzle. It's incomplete, it doesn't contain full instruction emulation, but it should be sufficient for most cases. r259245,r259421: (FBT) FBT now does work fully on PowerPC. Save r3 before using it for the trap check, else we end up saving the new r3, containing the trap instruction encoding (0x7c810808), and restoring it back with the frame on return. This caused it to panic on my ppc32 machine. r259668,r259674: Fix a typo in the FBT code.
* 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-313-112/+261
| | | | | | - 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-243-9/+9
| | | | | | | | | | | | | | 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
* fbt: drop a local write-only variableavg2013-08-231-6/+0
| | | | | Discovered with: gcc46 MFC after: 4 days
* 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
|
* Add a "translated type" argument to SDT_PROBE_ARGTYPE() and add some macrosmarkj2013-08-171-2/+6
| | | | | | | | | | | which allow one to define SDT probes that specify translated types. The idea is to make it easy to write SDT probe definitions that can work across multiple operating systems. In particular, this makes it possible to port illumos SDT probes to FreeBSD without changing their argument types, so long as the appropriate translators are defined. Then DTrace scripts written for Solaris/illumos will work on FreeBSD without any changes. MFC after: 1 week
* Use kld_{load,unload} instead of mod_{load,unload} for the linker file loadmarkj2013-08-143-23/+23
| | | | | | | 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-134-79/+227
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* The dtmalloc provider uses the short description of a malloc type as themarkj2013-06-281-0/+10
| | | | | | | | function name of its corresponding DTrace probes. These descriptions may contain whitespace, but probe names cannot, so just replace any whitespace with underscores when creating probes. MFC after: 1 week
* SDT probes can directly pass up to five arguments as arguments tomarkj2013-06-022-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* fbt_getargdesc: correctly handle types for return probesavg2013-03-231-5/+17
| | | | MFC after: 6 days
* fbt_typoff_init: fix an off by one in determining required memory sizeavg2013-03-231-0/+2
| | | | | | | | | | | This issue would be silent most of the time, but if the requested memory is a multiple of a page size, then accessing one element beyond the end would lead to a kernel page fault. Otherwise, the unlucky last type would just be inaccessible. Reported by: glebius Tested by: glebius MFC after: 6 days
* Add FBT for PowerPC DTrace. Also, clean up the DTrace assembly code,jhibbits2013-03-184-43/+1422
| | | | | | | | | | | 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-076-1/+1076
| | | | | | | | | | | 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
* Instead of only iterating over the set of known SDT probes when sdt.ko isrstone2012-03-271-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | loaded and unloaded, also have sdt.ko register callbacks with kern_sdt.c that will be called when a newly loaded KLD module adds more probes or a module with probes is unloaded. This fixes two issues: first, if a module with SDT probes was loaded after sdt.ko was loaded, those new probes would not be available in DTrace. Second, if a module with SDT probes was unloaded while sdt.ko was loaded, the kernel would panic the next time DTrace had cause to try and do anything with the no-longer-existent probes. This makes it possible to create SDT probes in KLD modules, although there are still two caveats: first, any SDT probes in a KLD module must be part of a DTrace provider that is defined in that module. At present DTrace only destroys probes when the provider is destroyed, so you can still panic the system if a KLD module creates new probes in a provider from a different module(including the kernel) and then unload the the first module. Second, the system will panic if you unload a module containing SDT probes while there is an active D script that has enabled those probes. MFC after: 1 month
* - For o32 ABI get arguments from the stackgonzo2012-03-261-0/+28
| | | | | - Clear CPU_DTRACE_FAULT flag in userland backtrace routine. It just means we hit wrong memory region and should stop.
* Properly cast 64-bit dofhp_dof to pointer.gonzo2012-03-261-5/+1
| | | | | For i386 this change is no-op. For AMD64 it was tested with DTrace test suite: results are the same from the test run before the change and after
* Use macroses to load/store pointers and increase indexes instead ofgonzo2012-03-261-11/+11
| | | | hardcoded MIPS64 instructions
* Add device part of DTrace/MIPS codegonzo2012-03-246-1/+1274
|
* Correct the types of the arguments to return probes of the syscallrstone2011-11-111-2/+7
| | | | | | | | provider. Previously we were erroneously supplying the argument types of the corresponding entry probe. Reviewed by: rpaulo MFC after: 1 week
* On i386, fbt probes are implemented by writing an invalid opcode overrstone2011-11-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | certain instructions in a function prologue or epilogue. DTrace has a hook into the invalid opcode fault handler that checks whether the fault was due to an probe and if so, runs the DTrace magic. Upon returning from an invalid opcode fault caused by a probe, DTrace must emulate the instruction that was replaced with the invalid opcode and then return control to the instruction following the invalid opcode. There were a pair of related bugs in the emulation for the leave instruction. The leave instruction is used to pop off a stack frame prior to returning from a function. The emulation for this instruction must move the trap frame for the invalid opcode fault down the stack to the bottom of the stack frame that is being removed, and then execute an iret. At two points in this process, the emulation code was storing values above the current value of the stack pointer. This opened up a window in which if we were two take an interrupt, the trap frame for the interrupt would overwrite the values stored on the stack, causing the system to panic later. The first bug was that at one point the emulation code saves the new value for $esp above the current stack pointer value. The fix is to save this value instead inside of the original trap frame. At this point we do not need the original trap frame so this is safe. The second bug is that when the emulate code loads $esp from the stack, it points part-way through the new trap frame instead of at its beginning. The emulation code adjusts the stack pointer to the correct value immediately afterwards, but this still leaves a one instruction window in which an interrupt would corrupt this trap frame. Fix this by adjusting the stack frame value before loading it into $esp. This fixes panics in invop_leave on i386 when using fbt return probes. Reviewed by: rpaulo, attilio MFC after: 1 week
OpenPOWER on IntegriCloud