Commit Graph

2433 Commits

Author SHA1 Message Date
Warner Losh
2063df1471 sys: Remove $FreeBSD$: one-line catalog
Remove /^\s*\$\s*\$FreeBSD\$$\n/
2023-08-16 11:55:22 -06:00
Warner Losh
78d146160d sys: Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:17 -06:00
Warner Losh
685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh
71625ec9ad sys: Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:24 -06:00
Warner Losh
2ff63af9b8 sys: Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:18 -06:00
Warner Losh
95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Christos Margiolis
02402ec888 kinst.h: make pointer to probe in kinst_cpu_state const
Fixes: 5b701ed19c ("kinst: start moving towards per-probe
trampolines")

Sponsored by: The FreeBSD Foundation
2023-07-19 19:57:44 +03:00
Christos Margiolis
e967a9a5d5 Revert "dtrace: cache current probe in kdtrace_thread_t"
This reverts commit 22508c8b6c.

The t_kinst_curprobe field is no longer needed by kinst.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41031
2023-07-19 17:58:49 +03:00
Christos Margiolis
07864a8a24 kinst: port to arm64
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40337
2023-07-19 17:58:18 +03:00
Christos Margiolis
2517b2085b kinst: use per-probe trampolines in riscv
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40963
2023-07-19 17:57:59 +03:00
Christos Margiolis
5b701ed19c kinst: start moving towards per-probe trampolines
Using per-CPU and per-thread trampolines is expensive and error-prone,
since we're rewriting the same memory blocks constantly. Per-probe
trampolines solve this problem by giving each probe its own block of
executable memory, which more or less remains the same after the initial
write.

What this patch does, is get rid of the initialization code which
allocates a trampoline for each thread, and instead let each port of
kinst allocate a trampoline for each new probe created. It also sets up
the infrastructure needed to support the new trampoline scheme.

This change is not currently supported on amd64, as the amd64 port needs
further changes to work, so this is a temporary/gradual patch to fix the
riscv and arm64 ports.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40962
2023-07-19 17:57:21 +03:00
Christos Margiolis
eb1413c9a6 kinst: exclude cpu_switch
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40985
2023-07-19 17:56:29 +03:00
Christos Margiolis
ea89133dbc kinst: check for 'push %rbp' anywhere in the function
Currently kinst checks if only the first instruction is 'push %rbp',
essentially excluding functions that do push RBP, but not in the first
instruction. This patch modifies kinst to check for 'push %rbp', as
well, as a following 'pop %rbp', anywhere in the function. This behavior
also matches that of FBT.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40283
2023-07-19 17:53:08 +03:00
Christos Margiolis
8ada3f78e6 kinst.h: reorder function declarations based on implementation file
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41032
2023-07-19 17:50:24 +03:00
Jessica Clarke
c63c4e694c Don't bother to check COMPAT_32BIT when __LP64__ is defined
Under COMPAT_32BIT we are compiling 32-bit code and so __LP64__ is not
defined, __ILP32__ is, and thus the check is completely redundant.

Reviewed by:	brooks, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D40917
2023-07-09 18:45:32 +01:00
Doug Moore
e087768130 inline_fls: remove redundant INLINE_FLS test
HAS_INLINE_FLS and similar macros are defined always.
Removes the redundant tests for these always-true conditions.
Reviewed by:	mhorne
Differential Revision:	https://reviews.freebsd.org/D40707
2023-07-06 13:29:13 -05:00
Christos Margiolis
9310bf5404 kinst: update LICENSE headers
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40875
2023-07-04 18:38:25 +03:00
Christos Margiolis
2d7bb03adb kinst: port to riscv
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39884
2023-07-04 18:38:01 +03:00
Christos Margiolis
22508c8b6c dtrace: cache current probe in kdtrace_thread_t
Needed by the forthcoming RISC-V and ARM64 ports.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40872
2023-07-04 18:37:55 +03:00
Mark Johnston
6281147a96 dtrace/arm64: Fix user memory access routines
Use unprivileged loads to access user memory.  Without this, the
accesses trap and various dtrace actions such as ustack() fail.

Reviewed by:	andrew
MFC after:	1 week
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40540
2023-06-15 12:39:21 -04:00
Mark Johnston
91522683d4 dtrace/arm64: Store the fault address when suppressing a page fault
Reviewed by:	andrew
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40539
2023-06-15 12:38:45 -04:00
Mark Johnston
d325184232 arm64: Remove struct arm64_frame
It was used in one place and was added specifically to support dtrace
stack unwinding code.  Write an equivalent expression using struct
unwind_state instead.  No functional change intended.

Reviewed by:	andrew
MFC after:	1 week
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40538
2023-06-15 12:38:45 -04:00
Christos Margiolis
1aa4862187 kinst: rename t_kinst to t_kinst_tramp
The forthcoming RISC-V and ARM64 ports of kinst introduce a new field
named "t_kinst_curprobe", so "t_kinst" (which points to a trampoline)
becomes a misleading name.

No functional change intended.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40507
2023-06-13 15:46:45 +03:00
Christos Margiolis
333731274f kinst: hide KINST_TRAMPCHUNK_SIZE from ISA-specific headers
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40505
2023-06-13 15:46:33 +03:00
Christos Margiolis
47a5d58e3b kinst: fix kinst_probe_md field indentation
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40411
2023-06-03 23:03:14 +03:00
Christos Margiolis
d434607b3d kinst: use bool where appropriate
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40412
2023-06-03 23:02:53 +03:00
Christos Margiolis
9b091f1200 kinst: simplify trampoline fill definitions
Centralize KINST_TRAMP_FILL_PATTERN and KINST_TRAMP_FILL_SIZE to reduce
redefinitions, and use the architecture-dependent kinst_patchval_t as
their size.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40406
2023-06-03 20:04:57 +03:00
Christos Margiolis
980746e5cb fbt: simplify arm64 function-prologue parsing
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40364
2023-06-03 20:04:33 +03:00
Christos Margiolis
bab7781e78 dtrace: deduplicate arm64 breakpoint definition
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40363
2023-06-03 20:04:10 +03:00
Christos Margiolis
7a8cf053d1 dtrace: deduplicate some RISC-V functions
match_opcode() is defined in FBT, kinst, and dtrace_subr.c. The function
prologue-checking functions are defined in FBT and kinst.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40335
2023-05-30 18:07:18 +03:00
Christos Margiolis
5c134fba22 kinst: fix memcpy() tracing crash
Tracing memcpy() would crash the kernel, because we'd also trace the
memcpy() calls from kinst_invop(). To fix this, introduce kinst_memcpy()
whose arguments are 'volatile', so that we avoid having the compiler
replace it with a regular memcpy().

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40284
2023-05-26 18:43:37 +03:00
Christos Margiolis
9c80ad6839 kinst: add kinst_excluded()
Exclude functions that are not safe-to-trace.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
ifferential Revision:	https://reviews.freebsd.org/D39229
2023-05-26 16:54:08 +03:00
Christos Margiolis
855ade9e72 kinst: be explicit about trampoline placement
The current implementation and comment was specific to amd64. Even
though in the case of kinst's supported architectures (RISC-V and ARM64)
VM_MIN_KERNEL_ADDRESS is equal to KERNBASE, it's better to be explicit.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40266
2023-05-25 23:40:46 +03:00
Christos Margiolis
ff624eb636 kinst: use dtrace_dis_get_byte() instead of own copy
No functional change intended.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39872
2023-05-23 18:12:18 +03:00
Christos Margiolis
98ab9802af dtrace: rename rp to frame in dtrace_getreg()
Reviewed by:	mhorne, markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40231
2023-05-23 17:44:47 +03:00
Christos Margiolis
21a16d55cc dtrace: add register bindings for arm64
Reviewed by:	mhorne, markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39956
2023-05-23 17:19:25 +03:00
Christos Margiolis
db05f9fbfb dtrace: implement dtrace_instr_size() for arm64
Reviewed by:	markj
Approved by;	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39955
2023-05-23 17:19:15 +03:00
Christos Margiolis
27ff920e6a dtrace: remove ifdef around dtrace_instr_size()
Architectures that are not included in the #ifdef won't be able to
compile libdtrace. This was tested on an ARM64 build. If the ifdef is
removed, libdtrace can be compiled with no problems, otherwise it fails
at libdtrace.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39948
2023-05-23 17:19:04 +03:00
Christos Margiolis
ecca318085 kinst: replace KINST_TRAMP_INIT
The current implementation of KINST_TRAMP_INIT is working only on amd64,
where the breakpoint instruction is one byte long, which might not be
the case for other architectures (e.g in RISC-V it's either 2 or 4
bytes). This patch introduces two machine-dependent constants,
KINST_TRAMP_FILL_PATTERN and KINST_TRAMP_FILL_SIZE, which hold the fill
instruction and the size of that instruction in bytes respectively.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39504
2023-05-23 16:58:36 +03:00
Christos Margiolis
cef2565587 dtrace: export dtrace_dis_get_byte()
kinst uses this function as well, but because it is not exported, it
implements its own copy of it. The patch also exposes the function to
userland, so programs that need to use dtrace_disx86() can use this
function instead of rolling their own copies.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39871
2023-05-22 23:21:25 +03:00
Chuck Silvers
9095169520 fbt/x86: update FBT_AFRAMES to match the trap handlers
Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D40054
2023-05-11 10:50:15 -07:00
Warner Losh
96b119340e stand: remove ZFS warning about computered but unused variable
Toss a __unused on the unexpected_errors variable. We compute it, but
never use it.

Sponsored by:		Netflix
2023-05-01 15:02:54 -06:00
Christos Margiolis
e11d11c543 kinst: test lock in kinst_trampoline_dealloc_locked()
Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39883
2023-05-01 11:40:29 -04:00
Christos Margiolis
aad1685066 fbt: get rid of redundant defines
No functional change intended.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39882
2023-05-01 11:40:29 -04:00
Christos Margiolis
b999f2458c kinst: do not use DPCPU_ID_GET if we already have the trampoline
No functional change intended.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39870
2023-04-28 11:11:10 -04:00
Mark Johnston
722b2e2f9a dtrace: Sync dis_tables.c with illumos
This brings in the following commits:

    commit 584b574a3b16c6772c8204ec1d1c957c56f22a87
    12174 i86pc: variable may be used uninitialized
    Author: Toomas Soome <tsoome@me.com>
    Reviewed by: John Levon <john.levon@joyent.com>
    Reviewed by: Andrew Stormont <astormont@racktopsystems.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

    commit a25e615d76804404e5fc63897a9196d4f92c3f5e
    12371 dis x86 EVEX prefix mishandled
    12372 dis EVEX encoding SIB mishandled
    12373 dis support for EVEX vaes instructions
    12374 dis support for EVEX vpclmulqdq instructions
    12375 dis support for gfni instructions
    Author: Robert Mustacchi <rm@fingolfin.org>
    Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Approved by: Joshua M. Clulow <josh@sysmgr.org>

    commit c1e9bf00765d7ac9cf1986575e4489dd8710d9b1
    12369 dis WBNOINVD support
    Author: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
    Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

    commit e4f6ce7088a7dd335b9edf4774325f888692e5fb
    10893 Need support for new Cascade Lake Instructions
    Author: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
    Reviewed by: Dan McDonald <danmcd@joyent.com>
    Reviewed by: Richard Lowe <richlowe@richlowe.net>
    Approved by: Gordon Ross <gwr@nexenta.com>

    commit cff040f3ef42d16ae655969398f5a5e6e700b85e
    10226 Need support for new EPYC ISA extensions
    Author: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
    Reviewed by: Jason King <jason.king@joyent.com>
    Reviewed by: Richard Lowe <richlowe@richlowe.net>
    Approved by: Dan McDonald <danmcd@joyent.com>

    commit d242cdf5288b86d9070d88791c8ee696612becdc
    8492 AVX512 dis - legacy logical instructions
    Author: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

    commit 81b505b772ab015c588c56bb116239ee549b6eee
    8384 AVX512 dis - EVEX prefix support
    8385 32-bit avx dis test mishandles EVEX prefix
    8386 32-bit bound dis is incorrect
    Author: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

    commit 92381362ae635a3bea638d87b7119f1623b6212e
    8319 dis support for new xsave instructions
    Author: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

    commit a4e73d5d60e566669c550027fae2b1d87b4be2b4
    8240 AVX512 dis - opmask instruction support
    Author: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Approved by: Gordon Ross <gordon.w.ross@gmail.com>

    959b2dfd39979fe8a9a315a52741d009eb168822
    7825 want avx dis tests
    7826 PCLMULQDQ psuedo-ops aren't properly described in dis
    7827 dis tests for f16c, movbe, cpuid, msr, tsc, fence instrs
    7828 sysenter and sysexit dis should be allowed in 64-bit x86
    Author: Robert Mustacchi <rm@joyent.com>
    Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

MFC after:	2 weeks
2023-04-25 10:46:10 -04:00
Christos Margiolis
1fef7abdc7 dtrace: add register bindings for RISC-V
Reviewed by:	mhorne, markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39611
2023-04-20 13:35:57 -04:00
Christos Margiolis
75081b9ed8 dtrace: use dtrace_instr_size() in the riscv dtrace_subr.c
No functional change intended.

Reviewed by:	mhorne, markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39652
2023-04-20 13:35:57 -04:00
Christos Margiolis
080e56a6c9 dtrace: expose dtrace_instr_size() to userland and implement it for riscv
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
2023-04-20 13:35:57 -04:00
Christos Margiolis
1a149d65ba dtrace: get rid of uchar_t types
Callers are specifying uint8_t anyway and this slightly reduces
dependencies on compatibility typedefs.  No functional change intended.

Reviewed by:	markj, mhorne
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39490
2023-04-20 13:35:56 -04:00