4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* #pragma ident "@(#)fbt.c 1.15 05/09/19 SMI" */
31 #define _KERNEL /* Solaris vs. Darwin */
35 #define MACH__POSIX_C_SOURCE_PRIVATE 1 /* pulls in suitable savearea from mach/ppc/thread_status.h */
36 #include <kern/thread.h>
37 #include <mach/thread_status.h>
38 #include <mach/vm_param.h>
39 #include <mach-o/loader.h>
40 #include <mach-o/nlist.h>
42 extern struct mach_header _mh_execute_header
; /* the kernel's mach header */
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/errno.h>
48 #include <sys/ioctl.h>
50 #include <sys/fcntl.h>
51 #include <miscfs/devfs/devfs.h>
53 #include <sys/dtrace.h>
54 #include <sys/dtrace_impl.h>
57 #include <sys/dtrace_glue.h>
59 #define DTRACE_INVOP_NOP_SKIP 1
60 #define DTRACE_INVOP_MOVL_ESP_EBP 10
61 #define DTRACE_INVOP_MOVL_ESP_EBP_SKIP 2
62 #define DTRACE_INVOP_LEAVE_SKIP 1
64 #define FBT_PUSHL_EBP 0x55
65 #define FBT_MOVL_ESP_EBP0_V0 0x8b
66 #define FBT_MOVL_ESP_EBP1_V0 0xec
67 #define FBT_MOVL_ESP_EBP0_V1 0x89
68 #define FBT_MOVL_ESP_EBP1_V1 0xe5
69 #define FBT_REX_RSP_RBP 0x48
71 #define FBT_POPL_EBP 0x5d
73 #define FBT_RET_IMM16 0xc2
74 #define FBT_LEAVE 0xc9
75 #define FBT_JMP_SHORT_REL 0xeb /* Jump short, relative, displacement relative to next instr. */
76 #define FBT_JMP_NEAR_REL 0xe9 /* Jump near, relative, displacement relative to next instr. */
77 #define FBT_JMP_FAR_ABS 0xea /* Jump far, absolute, address given in operand */
79 #define FBT_RET_IMM16_LEN 3
80 #define FBT_JMP_SHORT_REL_LEN 2
81 #define FBT_JMP_NEAR_REL_LEN 5
82 #define FBT_JMP_FAR_ABS_LEN 5
84 #define FBT_PATCHVAL 0xf0
85 #define FBT_AFRAMES_ENTRY 7
86 #define FBT_AFRAMES_RETURN 6
88 #define FBT_ENTRY "entry"
89 #define FBT_RETURN "return"
90 #define FBT_ADDR2NDX(addr) ((((uintptr_t)(addr)) >> 4) & fbt_probetab_mask)
92 extern dtrace_provider_id_t fbt_id
;
93 extern fbt_probe_t
**fbt_probetab
;
94 extern int fbt_probetab_mask
;
97 * Critical routines that must not be probed. PR_5221096, PR_5379018.
100 static const char * critical_blacklist
[] =
119 "cpu_processor_alloc",
120 "cpu_processor_free",
121 "cpu_signal_handler",
130 "cpu_topology_start",
134 "handle_pending_TLB_flushes",
135 "hw_compare_and_store",
136 "machine_idle_cstate",
142 "pmap_cpu_high_map_vaddr",
143 "pmap_cpu_high_shared_remap",
145 "register_cpu_setup_func",
146 "unregister_cpu_setup_func"
148 #define CRITICAL_BLACKLIST_COUNT (sizeof(critical_blacklist)/sizeof(critical_blacklist[0]))
151 * The transitive closure of entry points that can be reached from probe context.
152 * (Apart from routines whose names begin with dtrace_ or dtxnu_.)
154 static const char * probe_ctx_closure
[] =
158 "absolutetime_to_microtime",
160 "clock_get_calendar_nanotime_nowait",
175 "get_bsdthread_info",
180 "kernel_preempt_check",
181 "mach_absolute_time",
182 "max_valid_stack_address",
183 "ml_at_interrupt_context",
184 "ml_phys_write_byte_64",
185 "ml_phys_write_half_64",
186 "ml_phys_write_word_64",
187 "ml_set_interrupts_enabled",
192 "pmap_get_mapwindow",
195 "pmap_put_mapwindow",
205 "sync_iss_to_iks_unconditionally",
208 #define PROBE_CTX_CLOSURE_COUNT (sizeof(probe_ctx_closure)/sizeof(probe_ctx_closure[0]))
211 static int _cmp(const void *a
, const void *b
)
213 return strcmp((const char *)a
, *(const char **)b
);
216 static const void * bsearch(
217 register const void *key
,
220 register size_t size
,
221 register int (*compar
)(const void *, const void *)) {
223 register const char *base
= base0
;
226 register const void *p
;
228 for (lim
= nmemb
; lim
!= 0; lim
>>= 1) {
229 p
= base
+ (lim
>> 1) * size
;
230 cmp
= (*compar
)(key
, p
);
233 if (cmp
> 0) { /* key > p: move right */
234 base
= (const char *)p
+ size
;
236 } /* else move left */
242 fbt_invop(uintptr_t addr
, uintptr_t *stack
, uintptr_t rval
)
244 uintptr_t stack0
= 0, stack1
= 0, stack2
= 0, stack3
= 0, stack4
= 0;
245 fbt_probe_t
*fbt
= fbt_probetab
[FBT_ADDR2NDX(addr
)];
247 for (; fbt
!= NULL
; fbt
= fbt
->fbtp_hashnext
) {
248 if ((uintptr_t)fbt
->fbtp_patchpoint
== addr
) {
250 if (fbt
->fbtp_roffset
== 0) {
252 if (CPU_ON_INTR(CPU
))
253 stacktop
= (uintptr_t *)dtrace_get_cpu_int_stack_top();
255 stacktop
= (uintptr_t *)(dtrace_get_kernel_stack(current_thread()) + KERNEL_STACK_SIZE
);
257 stack
+= 1; /* skip over the target's pushl'd %ebp */
259 if (stack
<= stacktop
)
260 CPU
->cpu_dtrace_caller
= *stack
++;
261 if (stack
<= stacktop
)
263 if (stack
<= stacktop
)
265 if (stack
<= stacktop
)
267 if (stack
<= stacktop
)
269 if (stack
<= stacktop
)
272 dtrace_probe(fbt
->fbtp_id
, stack0
, stack1
, stack2
, stack3
, stack4
);
273 CPU
->cpu_dtrace_caller
= 0;
275 dtrace_probe(fbt
->fbtp_id
, fbt
->fbtp_roffset
, rval
, 0, 0, 0);
276 CPU
->cpu_dtrace_caller
= 0;
279 return (fbt
->fbtp_rval
);
286 #define IS_USER_TRAP(regs) (regs && (((regs)->cs & 3) != 0))
287 #define T_INVALID_OPCODE 6
288 #define FBT_EXCEPTION_CODE T_INVALID_OPCODE
293 x86_saved_state_t
*tagged_regs
,
294 __unused
int unused1
,
295 __unused
int unused2
)
297 kern_return_t retval
= KERN_FAILURE
;
298 x86_saved_state32_t
*saved_state
= saved_state32(tagged_regs
);
299 struct x86_saved_state32_from_kernel
*regs
= (struct x86_saved_state32_from_kernel
*)saved_state
;
301 if (FBT_EXCEPTION_CODE
== trapno
&& !IS_USER_TRAP(saved_state
)) {
302 boolean_t oldlevel
, cpu_64bit
;
303 uint32_t esp_probe
, *ebp
, edi
, fp
, *pDst
, delta
= 0;
306 cpu_64bit
= ml_is64bit();
307 oldlevel
= ml_set_interrupts_enabled(FALSE
);
309 /* Calculate where the stack pointer was when the probe instruction "fired." */
311 esp_probe
= saved_state
->uesp
; /* Easy, x86_64 establishes this value in idt64.s */
313 esp_probe
= (uint32_t)&(regs
[1]); /* Nasty, infer the location above the save area */
316 emul
= dtrace_invop( saved_state
->eip
, (uintptr_t *)esp_probe
, saved_state
->eax
);
317 __asm__
volatile(".globl _dtrace_invop_callsite");
318 __asm__
volatile("_dtrace_invop_callsite:");
321 case DTRACE_INVOP_NOP
:
322 saved_state
->eip
+= DTRACE_INVOP_NOP_SKIP
; /* Skip over the patched NOP */
323 retval
= KERN_SUCCESS
;
326 case DTRACE_INVOP_MOVL_ESP_EBP
:
327 saved_state
->ebp
= esp_probe
; /* Emulate patched movl %esp,%ebp */
328 saved_state
->eip
+= DTRACE_INVOP_MOVL_ESP_EBP_SKIP
; /* Skip over the bytes of the patched movl %esp,%ebp */
329 retval
= KERN_SUCCESS
;
332 case DTRACE_INVOP_POPL_EBP
:
333 case DTRACE_INVOP_LEAVE
:
335 * Emulate first micro-op of patched leave: movl %ebp,%esp
336 * fp points just below the return address slot for target's ret
337 * and at the slot holding the frame pointer saved by the target's prologue.
339 fp
= saved_state
->ebp
;
340 /* Emulate second micro-op of patched leave: patched popl %ebp
341 * savearea ebp is set for the frame of the caller to target
342 * The *live* %esp will be adjusted below for pop increment(s)
344 saved_state
->ebp
= *(uint32_t *)fp
;
345 /* Skip over the patched leave */
346 saved_state
->eip
+= DTRACE_INVOP_LEAVE_SKIP
;
348 * Lift the stack to account for the emulated leave
349 * Account for words local in this frame
350 * (in "case DTRACE_INVOP_POPL_EBP:" this is zero.)
352 delta
= ((uint32_t *)fp
) - ((uint32_t *)esp_probe
);
353 /* Account for popping off the ebp (just accomplished by the emulation
359 saved_state
->uesp
+= (delta
<< 2);
361 /* XXX Fragile in the extreme. Obtain the value of %edi that our caller pushed
362 * (on behalf of its caller -- trap_from_kernel()). Ultimately,
363 * trap_from_kernel's stack pointer is restored from this slot.
364 * This is sensitive to the manner in which the compiler preserves %edi,
365 * and trap_from_kernel()'s internals.
367 ebp
= (uint32_t *)__builtin_frame_address(0);
368 ebp
= (uint32_t *)*ebp
;
370 /* Shift contents of stack */
371 for (pDst
= (uint32_t *)fp
;
372 pDst
> (((uint32_t *)edi
));
374 *pDst
= pDst
[-delta
];
375 /* Now adjust the value of %edi in our caller (kernel_trap)'s frame */
376 *(ebp
- 1) = edi
+ (delta
<< 2);
378 retval
= KERN_SUCCESS
;
382 retval
= KERN_FAILURE
;
385 ml_set_interrupts_enabled(oldlevel
);
393 __fbt_provide_module(void *arg
, struct modctl
*ctl
)
396 struct mach_header
*mh
;
397 struct load_command
*cmd
;
398 struct segment_command
*orig_ts
= NULL
, *orig_le
= NULL
;
399 struct symtab_command
*orig_st
= NULL
;
400 struct nlist
*sym
= NULL
;
402 uintptr_t instrLow
, instrHigh
;
406 int gIgnoreFBTBlacklist
= 0;
407 PE_parse_boot_argn("IgnoreFBTBlacklist", &gIgnoreFBTBlacklist
, sizeof (gIgnoreFBTBlacklist
));
409 mh
= (struct mach_header
*)(ctl
->address
);
410 modname
= ctl
->mod_modname
;
412 if (0 == ctl
->address
|| 0 == ctl
->size
) /* Has the linker been jettisoned? */
416 * Employees of dtrace and their families are ineligible. Void
420 if (strcmp(modname
, "com.apple.driver.dtrace") == 0)
423 if (strstr(modname
, "CHUD") != NULL
)
426 if (mh
->magic
!= MH_MAGIC
)
429 cmd
= (struct load_command
*) &mh
[1];
430 for (i
= 0; i
< mh
->ncmds
; i
++) {
431 if (cmd
->cmd
== LC_SEGMENT
) {
432 struct segment_command
*orig_sg
= (struct segment_command
*) cmd
;
434 if (strcmp(SEG_TEXT
, orig_sg
->segname
) == 0)
436 else if (strcmp(SEG_LINKEDIT
, orig_sg
->segname
) == 0)
438 else if (strcmp("", orig_sg
->segname
) == 0)
439 orig_ts
= orig_sg
; /* kexts have a single unnamed segment */
441 else if (cmd
->cmd
== LC_SYMTAB
)
442 orig_st
= (struct symtab_command
*) cmd
;
444 cmd
= (struct load_command
*) ((caddr_t
) cmd
+ cmd
->cmdsize
);
447 if ((orig_ts
== NULL
) || (orig_st
== NULL
) || (orig_le
== NULL
))
450 sym
= (struct nlist
*)orig_le
->vmaddr
;
451 strings
= ((char *)sym
) + orig_st
->nsyms
* sizeof(struct nlist
);
453 /* Find extent of the TEXT section */
454 instrLow
= (uintptr_t)orig_ts
->vmaddr
;
455 instrHigh
= (uintptr_t)(orig_ts
->vmaddr
+ orig_ts
->vmsize
);
457 for (i
= 0; i
< orig_st
->nsyms
; i
++) {
458 fbt_probe_t
*fbt
, *retfbt
;
459 machine_inst_t
*instr
, *limit
, theInstr
, i1
, i2
;
460 uint8_t n_type
= sym
[i
].n_type
& (N_TYPE
| N_EXT
);
461 char *name
= strings
+ sym
[i
].n_un
.n_strx
;
464 /* Check that the symbol is a global and that it has a name. */
465 if (((N_SECT
| N_EXT
) != n_type
&& (N_ABS
| N_EXT
) != n_type
))
468 if (0 == sym
[i
].n_un
.n_strx
) /* iff a null, "", name. */
471 /* Lop off omnipresent leading underscore. */
475 if (strstr(name
, "dtrace_") == name
&&
476 strstr(name
, "dtrace_safe_") != name
) {
478 * Anything beginning with "dtrace_" may be called
479 * from probe context unless it explitly indicates
480 * that it won't be called from probe context by
481 * using the prefix "dtrace_safe_".
486 if (strstr(name
, "dsmos_") == name
)
487 continue; /* Don't Steal Mac OS X! */
489 if (strstr(name
, "dtxnu_") == name
||
490 strstr(name
, "_dtrace") == name
)
491 continue; /* Shims in dtrace.c */
493 if (strstr(name
, "chud") == name
)
494 continue; /* Professional courtesy. */
496 if (strstr(name
, "hibernate_") == name
)
497 continue; /* Let sleeping dogs lie. */
499 if (0 == strcmp(name
, "ZN9IOService14newTemperatureElPS_") || /* IOService::newTemperature */
500 0 == strcmp(name
, "ZN9IOService26temperatureCriticalForZoneEPS_")) /* IOService::temperatureCriticalForZone */
501 continue; /* Per the fire code */
504 * Place no probes (illegal instructions) in the exception handling path!
506 if (0 == strcmp(name
, "t_invop") ||
507 0 == strcmp(name
, "enter_lohandler") ||
508 0 == strcmp(name
, "lo_alltraps") ||
509 0 == strcmp(name
, "kernel_trap") ||
510 0 == strcmp(name
, "i386_astintr"))
513 if (0 == strcmp(name
, "current_thread") ||
514 0 == strcmp(name
, "ast_pending") ||
515 0 == strcmp(name
, "fbt_perfCallback") ||
516 0 == strcmp(name
, "machine_thread_get_kern_state") ||
517 0 == strcmp(name
, "ml_set_interrupts_enabled") ||
518 0 == strcmp(name
, "dtrace_invop") ||
519 0 == strcmp(name
, "fbt_invop") ||
520 0 == strcmp(name
, "sdt_invop") ||
521 0 == strcmp(name
, "max_valid_stack_address"))
527 if (strstr(name
, "machine_stack_") == name
||
528 strstr(name
, "mapping_") == name
||
529 0 == strcmp(name
, "tmrCvt") ||
531 strstr(name
, "tsc_") == name
||
533 strstr(name
, "pmCPU") == name
||
534 0 == strcmp(name
, "Cstate_table_set") ||
535 0 == strcmp(name
, "pmKextRegister") ||
536 0 == strcmp(name
, "pmSafeMode") ||
537 0 == strcmp(name
, "pmUnregister") ||
538 strstr(name
, "pms") == name
||
539 0 == strcmp(name
, "power_management_init") ||
540 strstr(name
, "usimple_") == name
||
542 strstr(name
, "rtc_") == name
||
543 strstr(name
, "_rtc_") == name
||
544 strstr(name
, "rtclock_") == name
||
545 strstr(name
, "clock_") == name
||
546 strstr(name
, "absolutetime_to_") == name
||
547 0 == strcmp(name
, "setPop") ||
548 0 == strcmp(name
, "nanoseconds_to_absolutetime") ||
549 0 == strcmp(name
, "nanotime_to_absolutetime") ||
551 strstr(name
, "etimer_") == name
||
553 strstr(name
, "commpage_") == name
||
554 strstr(name
, "pmap_") == name
||
555 strstr(name
, "ml_") == name
||
556 strstr(name
, "PE_") == name
||
557 strstr(name
, "lapic_") == name
||
558 strstr(name
, "acpi_") == name
)
562 * Avoid machine_ routines. PR_5346750.
564 if (strstr(name
, "machine_") == name
)
567 if (0 == strcmp(name
, "handle_pending_TLB_flushes"))
571 * Place no probes on critical routines. PR_5221096
573 if (!gIgnoreFBTBlacklist
&&
574 bsearch( name
, critical_blacklist
, CRITICAL_BLACKLIST_COUNT
, sizeof(name
), _cmp
) != NULL
)
578 * Place no probes that could be hit in probe context.
580 if (!gIgnoreFBTBlacklist
&&
581 bsearch( name
, probe_ctx_closure
, PROBE_CTX_CLOSURE_COUNT
, sizeof(name
), _cmp
) != NULL
)
585 * Place no probes that could be hit on the way to the debugger.
587 if (strstr(name
, "kdp_") == name
||
588 strstr(name
, "kdb_") == name
||
589 strstr(name
, "kdbg_") == name
||
590 strstr(name
, "kdebug_") == name
||
591 0 == strcmp(name
, "kernel_debug") ||
592 0 == strcmp(name
, "Debugger") ||
593 0 == strcmp(name
, "Call_DebuggerC") ||
594 0 == strcmp(name
, "lock_debugger") ||
595 0 == strcmp(name
, "unlock_debugger") ||
596 0 == strcmp(name
, "SysChoked"))
600 * Place no probes that could be hit on the way to a panic.
602 if (NULL
!= strstr(name
, "panic_") ||
603 0 == strcmp(name
, "panic") ||
604 0 == strcmp(name
, "handleMck") ||
605 0 == strcmp(name
, "unresolved_kernel_trap"))
608 if (dtrace_probe_lookup(fbt_id
, modname
, name
, NULL
) != 0)
611 for (j
= 0, instr
= (machine_inst_t
*)sym
[i
].n_value
, theInstr
= 0;
612 (j
< 4) && ((uintptr_t)instr
>= instrLow
) && (instrHigh
> (uintptr_t)(instr
+ 2));
615 if (theInstr
== FBT_PUSHL_EBP
|| theInstr
== FBT_RET
|| theInstr
== FBT_RET_IMM16
)
618 if ((size
= dtrace_instr_size(instr
)) <= 0)
624 if (theInstr
!= FBT_PUSHL_EBP
)
630 limit
= (machine_inst_t
*)instrHigh
;
632 if ((i1
== FBT_MOVL_ESP_EBP0_V0
&& i2
== FBT_MOVL_ESP_EBP1_V0
) ||
633 (i1
== FBT_MOVL_ESP_EBP0_V1
&& i2
== FBT_MOVL_ESP_EBP1_V1
)) {
634 instr
+= 1; /* Advance to the movl %esp,%ebp */
638 * Sometimes, the compiler will schedule an intervening instruction
639 * in the function prologue. Example:
642 * 000006d8 pushl %ebp
643 * 000006d9 movl $0x00000004,%edx
644 * 000006de movl %esp,%ebp
646 * Try the next instruction, to see if it is a movl %esp,%ebp
649 instr
+= 1; /* Advance past the pushl %ebp */
650 if ((size
= dtrace_instr_size(instr
)) <= 0)
655 if ((instr
+ 1) >= limit
)
661 if (!(i1
== FBT_MOVL_ESP_EBP0_V0
&& i2
== FBT_MOVL_ESP_EBP1_V0
) &&
662 !(i1
== FBT_MOVL_ESP_EBP0_V1
&& i2
== FBT_MOVL_ESP_EBP1_V1
))
665 /* instr already points at the movl %esp,%ebp */
669 fbt
= kmem_zalloc(sizeof (fbt_probe_t
), KM_SLEEP
);
670 strlcpy( (char *)&(fbt
->fbtp_name
), name
, MAX_FBTP_NAME_CHARS
);
671 fbt
->fbtp_id
= dtrace_probe_create(fbt_id
, modname
, name
, FBT_ENTRY
, FBT_AFRAMES_ENTRY
, fbt
);
672 fbt
->fbtp_patchpoint
= instr
;
674 fbt
->fbtp_loadcnt
= ctl
->mod_loadcnt
;
675 fbt
->fbtp_rval
= DTRACE_INVOP_MOVL_ESP_EBP
;
676 fbt
->fbtp_savedval
= theInstr
;
677 fbt
->fbtp_patchval
= FBT_PATCHVAL
;
679 fbt
->fbtp_hashnext
= fbt_probetab
[FBT_ADDR2NDX(instr
)];
680 fbt
->fbtp_symndx
= i
;
681 fbt_probetab
[FBT_ADDR2NDX(instr
)] = fbt
;
689 * If this disassembly fails, then we've likely walked off into
690 * a jump table or some other unsuitable area. Bail out of the
693 if ((size
= dtrace_instr_size(instr
)) <= 0)
697 * We (desperately) want to avoid erroneously instrumenting a
698 * jump table, especially given that our markers are pretty
699 * short: two bytes on x86, and just one byte on amd64. To
700 * determine if we're looking at a true instruction sequence
701 * or an inline jump table that happens to contain the same
702 * byte sequences, we resort to some heuristic sleeze: we
703 * treat this instruction as being contained within a pointer,
704 * and see if that pointer points to within the body of the
705 * function. If it does, we refuse to instrument it.
707 for (j
= 0; j
< sizeof (uintptr_t); j
++) {
708 uintptr_t check
= (uintptr_t)instr
- j
;
711 if (check
< sym
[i
].n_value
)
714 if (check
+ sizeof (uintptr_t) > (uintptr_t)limit
)
717 ptr
= *(uint8_t **)check
;
719 if (ptr
>= (uint8_t *)sym
[i
].n_value
&& ptr
< limit
) {
726 * OK, it's an instruction.
730 /* Walked onto the start of the next routine? If so, bail out of this function. */
731 if (theInstr
== FBT_PUSHL_EBP
)
734 if (!(size
== 1 && (theInstr
== FBT_POPL_EBP
|| theInstr
== FBT_LEAVE
))) {
740 * Found the popl %ebp; or leave.
742 machine_inst_t
*patch_instr
= instr
;
745 * Scan forward for a "ret", or "jmp".
751 size
= dtrace_instr_size(instr
);
752 if (size
<= 0) /* Failed instruction decode? */
757 if (!(size
== FBT_RET_LEN
&& (theInstr
== FBT_RET
)) &&
758 !(size
== FBT_RET_IMM16_LEN
&& (theInstr
== FBT_RET_IMM16
)) &&
759 !(size
== FBT_JMP_SHORT_REL_LEN
&& (theInstr
== FBT_JMP_SHORT_REL
)) &&
760 !(size
== FBT_JMP_NEAR_REL_LEN
&& (theInstr
== FBT_JMP_NEAR_REL
)) &&
761 !(size
== FBT_JMP_FAR_ABS_LEN
&& (theInstr
== FBT_JMP_FAR_ABS
)))
765 * popl %ebp; ret; or leave; ret; or leave; jmp tailCalledFun; -- We have a winner!
767 fbt
= kmem_zalloc(sizeof (fbt_probe_t
), KM_SLEEP
);
768 strlcpy( (char *)&(fbt
->fbtp_name
), name
, MAX_FBTP_NAME_CHARS
);
770 if (retfbt
== NULL
) {
771 fbt
->fbtp_id
= dtrace_probe_create(fbt_id
, modname
,
772 name
, FBT_RETURN
, FBT_AFRAMES_RETURN
, fbt
);
774 retfbt
->fbtp_next
= fbt
;
775 fbt
->fbtp_id
= retfbt
->fbtp_id
;
779 fbt
->fbtp_patchpoint
= patch_instr
;
781 fbt
->fbtp_loadcnt
= ctl
->mod_loadcnt
;
783 if (*patch_instr
== FBT_POPL_EBP
) {
784 fbt
->fbtp_rval
= DTRACE_INVOP_POPL_EBP
;
786 ASSERT(*patch_instr
== FBT_LEAVE
);
787 fbt
->fbtp_rval
= DTRACE_INVOP_LEAVE
;
790 (uintptr_t)(patch_instr
- (uint8_t *)sym
[i
].n_value
);
792 fbt
->fbtp_savedval
= *patch_instr
;
793 fbt
->fbtp_patchval
= FBT_PATCHVAL
;
794 fbt
->fbtp_hashnext
= fbt_probetab
[FBT_ADDR2NDX(patch_instr
)];
795 fbt
->fbtp_symndx
= i
;
796 fbt_probetab
[FBT_ADDR2NDX(patch_instr
)] = fbt
;
803 extern struct modctl g_fbt_kernctl
;
804 #undef kmem_alloc /* from its binding to dt_kmem_alloc glue */
805 #undef kmem_free /* from its binding to dt_kmem_free glue */
806 #include <vm/vm_kern.h>
810 fbt_provide_module(void *arg
, struct modctl
*ctl
)
813 __fbt_provide_module(arg
, &g_fbt_kernctl
);
815 kmem_free(kernel_map
, (vm_offset_t
)g_fbt_kernctl
.address
, round_page_32(g_fbt_kernctl
.size
));
816 g_fbt_kernctl
.address
= 0;
817 g_fbt_kernctl
.size
= 0;