aboutsummaryrefslogtreecommitdiff
path: root/sys/cddl/dev/dtrace
Commit message (Collapse)AuthorAgeFilesLines
* Check that the frame pointer is within the current stack.John Baldwin2020-12-081-12/+7
| | | | | | | | | | | | | | This same check is used on other architectures. Previously this would permit a stack frame to unwind into any arbitrary kernel address (including unmapped addresses). Reviewed by: andrew, markj Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27362 Notes: svn path=/head/; revision=368455
* Stack unwinding robustness fixes for RISC-V.John Baldwin2020-12-081-4/+4
| | | | | | | | | | | | | | | | - Push the kstack_contains check down into unwind_frame() so that it is honored by DDB and DTrace. - Check that the trapframe for an exception frame is contained in the traced thread's kernel stack for DDB traces. Reviewed by: markj Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27357 Notes: svn path=/head/; revision=368454
* Fix syntaxKonstantin Belousov2020-12-011-2/+3
| | | | Notes: svn path=/head/; revision=368269
* Fix syntaxKonstantin Belousov2020-12-011-2/+2
| | | | Notes: svn path=/head/; revision=368263
* Use uintptr_t instead of uint64_t for pointers in stack frames.John Baldwin2020-12-011-4/+4
| | | | | | | | | | Reviewed by: andrew Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27361 Notes: svn path=/head/; revision=368245
* Use uintptr_t for pointers in stack frames.John Baldwin2020-12-011-4/+4
| | | | | | | | | | | | This catches up to the changes made to struct unwind_state in r364180. Reviewed by: mhorne Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27360 Notes: svn path=/head/; revision=368242
* Add a kstack_contains() helper function.John Baldwin2020-12-012-22/+10
| | | | | | | | | | | | | This is useful for stack unwinders which need to avoid out-of-bounds reads of a kernel stack which can trigger kernel faults. Reviewed by: kib, markj Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27356 Notes: svn path=/head/; revision=368240
* Fix build after r367020Mitchell Horne2020-10-241-3/+3
| | | | | | | | | DTrace also relies on these definitions. Reported by: jenkins Notes: svn path=/head/; revision=367033
* dtrace: fix fbt return probes on RISC-VKristof Provost2020-09-111-4/+4
| | | | | | | | | | | | | | | | Return values are passed in a0, so read it from there. We also pass a1 through to userspace, as the ABI allows small structs to be returned in registers a0/a1. While here read the register values directly from the trapframe rather than rtval, and remove the now unneeded argument from dtrace_invop(). Set fbtp_roffset so that we get the correct return location in arg0. Reviewed by: markj Sponsored by: Axiado Differential Revision: https://reviews.freebsd.org/D26389 Notes: svn path=/head/; revision=365626
* Tighten frame pointer checking in DTrace's amd64 stack unwinder.Mark Johnston2020-09-011-5/+9
| | | | | | | | | | | | Avoid assuming that the kernel was compiled with -fno-omit-frame-pointer. MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Notes: svn path=/head/; revision=365048
* Merge OpenZFS support in to HEAD.Matt Macy2020-08-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* amd64 pmap: LA57 AKA 5-level pagingKonstantin Belousov2020-08-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since LA57 was moved to the main SDM document with revision 072, it seems that we should have a support for it, and silicons are coming. This patch makes pmap support both LA48 and LA57 hardware. The selection of page table level is done at startup, kernel always receives control from loader with 4-level paging. It is not clear how UEFI spec would adapt LA57, for instance it could hand out control in LA57 mode sometimes. To switch from LA48 to LA57 requires turning off long mode, requesting LA57 in CR4, then re-entering long mode. This is somewhat delicate and done in pmap_bootstrap_la57(). AP startup in LA57 mode is much easier, we only need to toggle a bit in CR4 and load right value in CR3. I decided to not change kernel map for now. Single PML5 entry is created that points to the existing kernel_pml4 (KML4Phys) page, and a pml5 entry to create our recursive mapping for vtopte()/vtopde(). This decision is motivated by the fact that we cannot overcommit for KVA, so large space there is unusable until machines start providing wider physical memory addressing. Another reason is that I do not want to break our fragile autotuning, so the KVA expansion is not included into this first step. Nice side effect is that minidumps are compatible. On the other hand, (very) large address space is definitely immediately useful for some userspace applications. For userspace, numbering of pte entries (or page table pages) is always done for 5-level structures even if we operate in 4-level mode. The pmap_is_la57() function is added to report the mode of the specified pmap, this is done not to allow simultaneous 4-/5-levels (which is not allowed by hw), but to accomodate for EPT which has separate level control and in principle might not allow 5-leve EPT despite x86 paging supports it. Anyway, it does not seems critical to have 5-level EPT support now. Tested by: pho (LA48 hardware) Reviewed by: alc Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D25273 Notes: svn path=/head/; revision=364527
* dtrace/fbt: fix return probe arguments on armAndriy Gapon2020-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | arg0 should be an offset of the return point within the function, arg1 should be the return value. Previously the return probe had arguments as if for the entry probe. Tested on armv7. andrew noted that the same problem seems to be present on arm64, mips, and riscv. I am not sure if I will get around to fixing those. So, platform users or anyone looking to make a contribution please be aware of this opportunity. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25685 Notes: svn path=/head/; revision=363383
* Don't overflow the trap frame when accessing lr or xzr.Andrew Turner2020-07-171-4/+29
| | | | | | | | | | | | | | | | When emulating a load pair or store pair in dtrace on arm64 we need to copy the data between the stack and trap frame. When the registers are either the link register or the zero register we will access memory past the end of the trap frame as these are encoded as registers 30 and 31 respectively while the array they access only has 30 entries. Fix this by creating 2 helper functions to perform the operation with special cases for these registers. Sponsored by: Innovate UK Notes: svn path=/head/; revision=363272
* Fix entering KDB with dtrace-enabled kernel.Ruslan Bukin2020-05-261-0/+6
| | | | | | | | Reviewed by: markj, jhb Differential Revision: https://reviews.freebsd.org/D24018 Notes: svn path=/head/; revision=361533
* Handle non-dtrace-triggered kernel breakpoint traps in mips.John Baldwin2020-04-211-0/+3
| | | | | | | | | | | | | | | | | If DTRACE is enabled at compile time, all kernel breakpoint traps are first given to dtrace to see if they are triggered by a FBT probe. Previously if dtrace didn't recognize the trap, it was silently ignored breaking the handling of other kernel breakpoint traps such as the debug.kdb.enter sysctl. This only returns early from the trap handler if dtrace recognizes the trap and handles it. Submitted by: Nicolò Mazzucato <nicomazz97@gmail.com> Reviewed by: markj Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D24478 Notes: svn path=/head/; revision=360168
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-262-3/+7
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* dtrace: add missing CLTFLAG_MPSAFE annotationsMateusz Guzik2020-01-122-4/+6
| | | | Notes: svn path=/head/; revision=356652
* Remove scary-looking printf output that happens when you kldload dtrace onIan Lepore2020-01-091-1/+12
| | | | | | | | arm. Replace it with a comment block explaining why the function is empty on 32-bit arm. Notes: svn path=/head/; revision=356574
* dtrace: 64-bits registers supportMariusz Zaborski2019-10-041-0/+4
| | | | | | | | | | | | | The registers in ilumos and FreeBSD have a different number. In the illumos, last 32-bits register defined is SS an in FreeBSD is GS. While translating register we should comper it to the highest one. PR: 240358 Reported by: lwhsu@ MFC after: 2 weeks Notes: svn path=/head/; revision=353107
* Implement x86 dtrace_invop_(un)init() in C.Mark Johnston2019-09-234-34/+38
| | | | | | | | | | | | There is no reason for these routines to be written in assembly. In the ports of DTrace to other platforms, they are already written in C. No functional change intended. MFC after: 1 week Sponsored by: Netflix Notes: svn path=/head/; revision=352627
* dtrace: 64-bits registers supportMariusz Zaborski2019-06-051-0/+4
| | | | | | | | | | | | | | The registers in ilumos and FreeBSD have a different number. In the illumos, last 32-bits register defined is SS an in FreeBSD is GS. This off-by-one caused the uregs array to returns the wrong 64-bits register on amd64. Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20363 Notes: svn path=/head/; revision=348705
* powerpc/dtrace: Actually fix stack tracesJustin Hibbits2019-05-172-22/+25
| | | | | | | | | | | | | Fix stack unwinding such that requesting N stack frames in lockstat will actually give you N frames, not anywhere from 0-3 as had been before. lockstat prints the mutex function instead of the caller as the reported locker, but the stack frame is detailed enough to find the real caller. MFC after: 2 weeks Notes: svn path=/head/; revision=347943
* Remove resolver_qual from DEFINE_IFUNC/DEFINE_UIFUNC macros.Konstantin Belousov2019-05-161-7/+7
| | | | | | | | | | | | | In all practical situations, the resolver visibility is static. Requested by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: so (emaste) Differential revision: https://reviews.freebsd.org/D20281 Notes: svn path=/head/; revision=347895
* powerpc/dtrace: Fix dtrace powerpc asm, and simplify stack walkingJustin Hibbits2019-04-132-42/+22
| | | | | | | | | | | | | | | | | Fix some execution bugs in the dtrace powerpc asm. addme pulls in the carry flag which we don't want, and the result wasn't recorded anyways, so the following beq to check for exit condition wasn't checking the right condition. Simplify the stack walking in dtrace_isa.c, so there's only a single walker that handles both pc and sp. This should make it easier to follow, and any bugfix that may be needed for walking only needs to be made in one place instead of two now. MFC after: 2 weeks Notes: svn path=/head/; revision=346173
* Use an explicit comparison with VM_GUEST_NO.Mark Johnston2019-03-212-2/+2
| | | | | | | | | Reported by: jhb MFC with: r345359 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345384
* Don't attempt to measure TSC skew when running as a VM guest.Mark Johnston2019-03-212-0/+6
| | | | | | | | | | | | | It simply doesn't work in general since VCPUs may migrate between physical cores. The approach used to measure skew also doesn't make much sense in a VM. PR: 218452 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345359
* Fix a tracepoint lookup race in fasttrap_pid_probe().Mark Johnston2019-02-211-1/+4
| | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=344452
* dtrace: fix userspace access on boxes with SMAPMateusz Guzik2018-12-132-14/+161
| | | | | | | | | | | | | | dtrace has its own routines which were not updated after SMAP support got implemented. Use ifunc just like for other routines. This in particular fixes ustack(). Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D18542 Notes: svn path=/head/; revision=342053
* powerpc/dtrace: Use explicit bit numbers to mask out PSL_EEJustin Hibbits2018-10-211-1/+1
| | | | | | | | | | There seems to be a race in CI, such that dtrace_asm.S might be assembled before the genassym is completed. This causes a build failure when PSL_EE doesn't exist, and is read as 0. Get around this by explicitly specifying the bits in the mask instead. Notes: svn path=/head/; revision=339516
* Add support for 'C'-compressed ISA extension to DTrace FBT provider.Ruslan Bukin2018-09-031-14/+42
| | | | | | | | Approved by: re (kib) Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=338444
* dtrace/powerpc: Correct register indices for non-indexed registers in the ↵Justin Hibbits2018-07-161-7/+7
| | | | | | | | | | trapframe Fix an off-by-one error, LR starts at index 32, not index 33, and the others follow suit. Notes: svn path=/head/; revision=336355
* Protect dtrace_getpcstack() from a NULL stack pointer in a trap frameJustin Hibbits2018-05-301-1/+5
| | | | | | | | Found when trying to use lockstat on a POWER9, the stack pointer (r1) could be NULL, and result in a NULL pointer dereference, crashing the kernel. Notes: svn path=/head/; revision=334370
* DTrace aarch64: Avoid calling unwind_frame() in the probe context.Mark Johnston2018-05-121-4/+8
| | | | | | | | | | | | | | | unwind_frame() may be instrumented by FBT, leading to recursion into dtrace_probe(). Manually inline unwind_frame() as we do with stack unwinding code for other architectures. Submitted by: Domagoj Stolfa Reviewed by: manu MFC after: 1 week Sponsored by: DARPA / AFRL Differential Revision: https://reviews.freebsd.org/D15359 Notes: svn path=/head/; revision=333570
* Assert that dtrace_probe() doesn't re-enter itself.Mark Johnston2018-04-101-0/+2
| | | | | | | | | | | | | This helps catch cases where an instrumented function is called while in probe context. Submitted by: Domagoj Stolfa <domagoj.stolfa@gmail.com> MFC after: 2 weeks Sponsored by: DARPA/AFRL Differential Revision: https://reviews.freebsd.org/D14863 Notes: svn path=/head/; revision=332364
* Remove very old and unused signal information codes.John Baldwin2018-03-272-0/+2
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=331650
* Rename assym.s to assym.incEd Maste2018-03-206-6/+6
| | | | | | | | | | | | 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
* Avoid CPU migration in dtrace_gethrtime() on x86.Mark Johnston2017-12-182-6/+12
| | | | | | | | | | | | | | dtrace_gethrtime() may be called outside of probe context, and in particular, from the DTRACEIOC_BUFSNAP handler. Disable interrupts rather than using sched_pin() to help ensure that we don't call any external functions when in probe context. PR: 218452 MFC after: 1 week Notes: svn path=/head/; revision=326935
* Don't use pcpu_find() to determine if a CPU ID is valid.Mark Johnston2017-11-271-8/+2
| | | | | | | | | This addresses assertion failures after r326218. MFC after: 1 week Notes: svn path=/head/; revision=326286
* Enable dtrace support for mips64 and the ERL kernel configKurt Lidl2017-09-062-2/+2
| | | | | | | | | | | | | | 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
* Follow up r313841 on powerpcJustin Hibbits2017-06-091-1/+6
| | | | | | | | | | | | Close a potential race in reading the CPU dtrace flags, where a thread can start on one CPU, and partway through retrieving the flags be swapped out, while another thread traps and sets the CPU_DTRACE_NOFAULT. This could cause the first thread to return without handling the fault. Discussed with: markj@ Notes: svn path=/head/; revision=319759
* Fix stack tracing in dtrace for powerpcJustin Hibbits2017-05-111-30/+27
| | | | | | | | | | | | | | | The current method only sort of works, and usually doesn't work reliably. Also, on Book-E the return address from DEBUG exceptions is not the sentinel addresses, so it won't exit the loop correctly. Fix this by better handling trap frames during unwinding, and using the common trap handler for debug traps, as the code in that segment is identical between the two. MFC after: 1 week Notes: svn path=/head/; revision=318167
* Fix a harmless LOR in dtrace_load().Mark Johnston2017-05-011-9/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=317654
* Corrected misspelled versions of rendezvous.Patrick Kelsey2017-04-097-17/+17
| | | | | | | | | | | | The MFC will include a compat definition of smp_no_rendevous_barrier() that calls smp_no_rendezvous_barrier(). Reviewed by: gnn, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D10313 Notes: svn path=/head/; revision=316648
* Fix a backwards comparison in the code to dump a DTrace debug buffer.Mark Johnston2017-03-131-1/+1
| | | | | | | | PR: 217739 MFC after: 1 week Notes: svn path=/head/; revision=315208
* Directly include needed headers rather than relying on pollution.Mark Johnston2017-02-172-0/+4
| | | | | | | | | | | We get machine/cpu.h via kmem.h -> proc.h -> _vm_domain.h -> seq.h. Reported by: Ryan Libby Sponsored by: Dell EMC Isilon X-MFC with: r313841 Notes: svn path=/head/; revision=313850
* Prevent CPU migration when checking the DTrace nofault flag on x86.Mark Johnston2017-02-162-2/+16
| | | | | | | | | | | | | | | | | dtrace_trap() consumes page and protection faults triggered by code running in DTrace probe context. Such faults occur with interrupts disabled and are detected using a per-CPU flag. Regular faults cause dtrace_trap() to be called with interrupts enabled, and nothing was ensuring that the flag was read from the correct CPU. This may result in dtrace_trap() consuming unrelated page and protection faults when DTrace is enabled, causing the fault handler to return without actually having handled the fault. Diagnosed by: Ryan Libby <rlibby@gmail.com> MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=313841
* Use PC-relative relocations for USDT probe sites on i386 and amd64.Mark Johnston2017-02-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | When recording probe site addresses in the output DOF file, dtrace -G needs to emit relocations for the .SUNW_dof section in order to obtain the addresses of functions containing probe sites. DTrace expects the addresses to be relative to the base address of the final ELF file, and the amd64 USDT implementation was relying on some unspecified and incorrect behaviour in the base system GNU ld to achieve this. This change reimplements the probe site relocation handling to allow USDT to be used with lld and newer GNU binutils. Specifically, it makes use of R_X86_64_PC64/R_386_PC32 relocations to obtain the probe site address relative to the DOF file address, and adds and uses a new DOF relocation type which computes the final probe site address using these relative offsets. Reported by and discussed with: Rafael Espíndola MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D9374 Notes: svn path=/head/; revision=313262
* Sync the x86 dis_tables.c with upstream.Mark Johnston2017-02-032-53/+639
| | | | | | | | | | | | | | | | | | | | This corresponds to the following illumos issues: 5755 want support for Intel FMA instrs 5756 want support for Intel BMI1 instrs 5757 want support for Intel BMI2 instrs 5758 want support for Intel AVX2 instrs 7204 Want broadwell rdseed and adx support 7208 Want stac/clac disasm support 7733 Need SHA Instruction dis support 7756 dis can't handle x86 SSE 3 instructions 7757 want avx2 disasm tests 7758 want SSE 4.1 disasm tests MFC after: 2 weeks Notes: svn path=/head/; revision=313133
* Fix initialization of "p" after r312658.Mark Johnston2017-01-251-1/+1
| | | | | | | CID: 1369410 Notes: svn path=/head/; revision=312763