4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 #include <sys/dtrace_impl.h>
24 #include <sys/sysctl.h>
26 #define CLOSURE(s) #s,
27 #define CRITICAL(s) #s,
30 #define KASAN_ONLY(s) #s,
35 #if defined(__arm__) || defined(__arm64__)
36 #define ARM_ONLY(s) #s,
39 #endif /* defined(__arm__) || defined(__arm64__) */
40 #if defined(__x86_64__)
41 #define X86_ONLY(s) #s,
44 #endif /* defined(__x86_64__) */
47 * Routine prefixes that must not be probed, either because they are used in
48 * the exception path, by dtrace code in probe context, or are general
49 * critical routines that must never be probed.
51 * All routines whose name start with one of these will be ignored.
53 * This must be kept in asciibetical order for purposes of bsearch().
55 const char * fbt_blacklist
[] =
57 CRITICAL(Call_DebuggerC
)
60 CRITICAL(IOCPURunPlatformPanicActions
)
61 CLOSURE(IS_64BIT_PROCESS
)
64 CLOSURE(OSCompareAndSwap
)
67 CRITICAL(PEARMDebugPanicHook
)
68 CRITICAL(PEHaltRestart
)
70 CRITICAL(SavePanicInfo
)
73 CRITICAL(_ZN15OSMetaClassBase12safeMetaCastEPKS_PK11OSMetaClass
) /* OSMetaClassBase::safeMetaCast */
74 CRITICAL(_ZN16IOPlatformExpert11haltRestartEj
) /* IOPlatformExpert::haltRestart */
75 CRITICAL(_ZN18IODTPlatformExpert11haltRestartEj
) /* IODTPlatformExpert::haltRestart */
76 ARM_ONLY(_ZN8ASPNVRAM4syncEv
) /* ASPNVRAM::sync */
77 CRITICAL(_ZN9IODTNVRAM13savePanicInfoEPhy
) /* IODTNVRAM::savePanicInfo */
78 CRITICAL(_ZN9IOService14newTemperatureElPS_
) /* IOService::newTemperature */
79 CRITICAL(_ZN9IOService26temperatureCriticalForZoneEPS_
) /* IOService::temperatureCriticalForZone */
80 CRITICAL(_ZNK11OSMetaClass13checkMetaCastEPK15OSMetaClassBase
) /* OSMetaClass::checkMetaCast */
81 CRITICAL(_ZNK15OSMetaClassBase8metaCastEPK11OSMetaClass
) /* OSMetaClassBase::metaCast */
82 CRITICAL(_ZNK6OSData14getBytesNoCopyEv
) /* Data::getBytesNoCopy, IOHibernateSystemWake path */
85 CLOSURE(__dtrace_probe
)
88 CRITICAL(__strlcpy_chk
)
91 CRITICAL(_disable_preemption
)
92 CRITICAL(_enable_preemption
)
93 CLOSURE(absolutetime_to_microtime
)
96 CLOSURE(act_set_astbsd
)
97 ARM_ONLY(alternate_debugger_enter
)
98 ARM_ONLY(arm_init_idle_cpu
)
99 CLOSURE(ast_dtrace_on
)
102 CLOSURE(clean_dcache
)
103 CLOSURE(clean_mmu_dcache
)
106 CRITICAL(console_cpu_alloc
)
107 CRITICAL(console_cpu_free
)
111 CLOSURE(current_proc
)
112 CLOSURE(current_processor
)
113 CLOSURE(current_task
)
114 CLOSURE(current_thread
)
118 CRITICAL(enter_lohandler
)
121 CRITICAL(fbt_perfCallback
)
122 CLOSURE(find_user_regs
)
124 CLOSURE(flush_dcache
)
125 ARM_ONLY(flush_mmu_tlb_
)
128 CLOSURE(get_bsdtask_info
)
129 CLOSURE(get_bsdthread_info
)
130 CRITICAL(get_preemption_level
)
131 CRITICAL(get_threadtask
)
132 ARM_ONLY(get_vfp_enabled
)
134 CRITICAL(handle_pending_TLB_flushes
)
140 CRITICAL(invalidate_mmu_icache
)
141 CRITICAL(is_saved_state32
)
143 CLOSURE(kauth_cred_get
)
144 CLOSURE(kauth_getgid
)
145 CLOSURE(kauth_getuid
)
148 CRITICAL(kernel_preempt_check
)
149 CRITICAL(kernel_trap
)
154 CRITICAL(lo_alltraps
)
155 CRITICAL(lock_debugger
)
156 CLOSURE(mach_absolute_time
)
159 CRITICAL(mca_cpu_alloc
)
160 CRITICAL(mca_cpu_init
)
164 CLOSURE(mt_core_snap
)
165 CLOSURE(mt_cur_cpu_cycles
)
166 CLOSURE(mt_cur_cpu_instrs
)
167 CLOSURE(mt_cur_thread_cycles
)
168 CLOSURE(mt_cur_thread_instrs
)
169 CLOSURE(mt_fixed_counts
)
170 CLOSURE(mt_fixed_counts_internal
)
171 CLOSURE(mt_mtc_update_count
)
172 CLOSURE(mt_update_thread
)
173 CRITICAL(nanoseconds_to_absolutetime
)
174 CRITICAL(nanotime_to_absolutetime
)
183 X86_ONLY(pmKextRegister
)
184 X86_ONLY(pmMarkAllCPUsOff
)
186 X86_ONLY(pmTimerRestore
)
187 X86_ONLY(pmTimerSave
)
188 X86_ONLY(pmUnRegister
)
189 X86_ONLY(pmap64_pdpt
)
190 CLOSURE(pmap_find_phys
)
191 CLOSURE(pmap_get_mapwindow
)
193 CLOSURE(pmap_pde_internal0
)
194 CLOSURE(pmap_pde_internal1
)
196 CLOSURE(pmap_pte_internal
)
197 CLOSURE(pmap_put_mapwindow
)
198 CLOSURE(pmap_valid_page
)
200 CRITICAL(power_management_init
)
201 CRITICAL(preemption_underflow_panic
)
203 CLOSURE(proc_is64bit
)
204 CLOSURE(proc_selfname
)
205 CRITICAL(register_cpu_setup_func
)
207 CRITICAL(ret_to_user
)
208 CRITICAL(return_to_kernel
)
209 CRITICAL(return_to_user
)
212 CRITICAL(saved_state64
)
213 CLOSURE(sdt_getargdesc
)
223 X86_ONLY(sync_iss_to_iks_unconditionally
)
224 CLOSURE(systrace_stub
)
227 ARM_ONLY(timer_state_event
)
229 CRITICAL(trap_from_kernel
)
232 CRITICAL(unlock_debugger
)
234 CRITICAL(unregister_cpu_setup_func
)
239 #define BLACKLIST_COUNT (sizeof(fbt_blacklist)/sizeof(fbt_blacklist[0]))
242 * Modules that should not be probed.
244 * This must be kept in asciibetical order for purposes of bsearch().
246 static const char* fbt_module_blacklist
[] = {
247 X86_ONLY(com
.apple
.driver
.AppleACPIEC
)
248 X86_ONLY(com
.apple
.driver
.AppleACPIPlatform
)
249 ARM_ONLY(com
.apple
.driver
.AppleARMPlatform
)
250 X86_ONLY(com
.apple
.driver
.AppleEFI
)
251 X86_ONLY(com
.apple
.driver
.AppleIntelCPUPowerManagement
)
252 ARM_ONLY(com
.apple
.driver
.AppleInterruptController
)
253 X86_ONLY(com
.apple
.driver
.AppleRTC
)
254 X86_ONLY(com
.apple
.iokit
.IOACPIFamily
)
256 #define MODULE_BLACKLIST_COUNT (sizeof(fbt_module_blacklist)/sizeof(fbt_module_blacklist[0]))
258 int ignore_fbt_blacklist
= 0;
259 extern int dtrace_kernel_symbol_mode
;
261 #pragma clang diagnostic push
262 #pragma clang diagnostic ignored "-Wcast-qual"
264 _cmp(const void *a
, const void *b
)
266 const char *v
= *(const char **)b
;
267 return strncmp((const char *)a
, v
, strlen(v
));
271 #pragma clang diagnostic pop
276 fbt_module_excluded(struct modctl
* ctl
)
278 const char *excluded
;
280 ASSERT(!MOD_FBT_DONE(ctl
));
282 if (ctl
->mod_address
== 0 || ctl
->mod_size
== 0 || !ctl
->mod_loaded
) {
286 if (ignore_fbt_blacklist
) {
290 excluded
= bsearch(ctl
->mod_modname
, fbt_module_blacklist
,
291 MODULE_BLACKLIST_COUNT
, sizeof(fbt_module_blacklist
[0]), _cmp
);
296 * FBT probe name validation
299 fbt_excluded(const char* name
)
301 const char *excluded
;
303 if (ignore_fbt_blacklist
) {
307 excluded
= bsearch(name
, fbt_blacklist
, BLACKLIST_COUNT
, sizeof(name
),
312 SYSCTL_DECL(_kern_dtrace
);
315 sysctl_dtrace_ignore_fbt_blacklist SYSCTL_HANDLER_ARGS
317 #pragma unused(oidp, arg2)
319 int value
= *(int*)arg1
;
321 err
= sysctl_io_number(req
, value
, sizeof(value
), &value
, NULL
);
326 if (!(value
== 0 || value
== 1)) {
331 * We do not allow setting the blacklist back to on, as we have no way
332 * of knowing if those unsafe probes are still used.
334 * If we are using kernel symbols, we also do not allow any change,
335 * since the symbols are jettison'd after the first pass.
337 * We do not need to take any locks here because those symbol modes
338 * are permanent and do not change after boot.
340 if (value
!= 1 || dtrace_kernel_symbol_mode
== DTRACE_KERNEL_SYMBOLS_NEVER
||
341 dtrace_kernel_symbol_mode
== DTRACE_KERNEL_SYMBOLS_ALWAYS_FROM_KERNEL
) {
345 ignore_fbt_blacklist
= 1;
351 SYSCTL_PROC(_kern_dtrace
, OID_AUTO
, ignore_fbt_blacklist
,
352 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
353 &ignore_fbt_blacklist
, 0,
354 sysctl_dtrace_ignore_fbt_blacklist
, "I", "fbt provider ignore blacklist");
357 fbt_blacklist_init(void)
359 PE_parse_boot_argn("IgnoreFBTBlacklist", &ignore_fbt_blacklist
, sizeof(ignore_fbt_blacklist
));
360 #if DEBUG || DEVELOPMENT
361 for (size_t i
= 1; i
< BLACKLIST_COUNT
; i
++) {
362 if (strcmp(fbt_blacklist
[i
- 1], fbt_blacklist
[i
]) > 0) {
363 panic("unordered fbt blacklist %s > %s", fbt_blacklist
[i
- 1], fbt_blacklist
[i
]);
366 #endif /* DEBUG || DEVELOPMENT */