xref: /freebsd/sys/cddl/dev/dtrace/amd64/dtrace_isa.c (revision 95eb4b873b6a8b527c5bd78d7191975dfca38998)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #include <sys/cdefs.h>
27 
28 #include <sys/param.h>
29 #include <sys/systm.h>
30 #include <sys/dtrace_impl.h>
31 #include <sys/kernel.h>
32 #include <sys/stack.h>
33 #include <sys/pcpu.h>
34 
35 #include <machine/frame.h>
36 #include <machine/md_var.h>
37 #include <machine/stack.h>
38 #include <x86/ifunc.h>
39 
40 #include <vm/vm.h>
41 #include <vm/vm_param.h>
42 #include <vm/pmap.h>
43 
44 #include "regset.h"
45 
46 uint8_t dtrace_fuword8_nocheck(void *);
47 uint16_t dtrace_fuword16_nocheck(void *);
48 uint32_t dtrace_fuword32_nocheck(void *);
49 uint64_t dtrace_fuword64_nocheck(void *);
50 
51 int	dtrace_ustackdepth_max = 2048;
52 
53 void
54 dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
55     uint32_t *intrpc)
56 {
57 	struct thread *td;
58 	int depth = 0;
59 	register_t rbp;
60 	struct amd64_frame *frame;
61 	vm_offset_t callpc;
62 	pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller;
63 
64 	if (intrpc != 0)
65 		pcstack[depth++] = (pc_t) intrpc;
66 
67 	aframes++;
68 
69 	__asm __volatile("movq %%rbp,%0" : "=r" (rbp));
70 
71 	frame = (struct amd64_frame *)rbp;
72 	td = curthread;
73 	while (depth < pcstack_limit) {
74 		if (!kstack_contains(curthread, (vm_offset_t)frame,
75 		    sizeof(*frame)))
76 			break;
77 
78 		callpc = frame->f_retaddr;
79 
80 		if (!INKERNEL(callpc))
81 			break;
82 
83 		if (aframes > 0) {
84 			aframes--;
85 			if ((aframes == 0) && (caller != 0)) {
86 				pcstack[depth++] = caller;
87 			}
88 		} else {
89 			pcstack[depth++] = callpc;
90 		}
91 
92 		if ((vm_offset_t)frame->f_frame <= (vm_offset_t)frame)
93 			break;
94 		frame = frame->f_frame;
95 	}
96 
97 	for (; depth < pcstack_limit; depth++) {
98 		pcstack[depth] = 0;
99 	}
100 }
101 
102 static int
103 dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc,
104     uintptr_t sp)
105 {
106 	uintptr_t oldsp;
107 	volatile uint16_t *flags =
108 	    (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
109 	int ret = 0;
110 
111 	ASSERT(pcstack == NULL || pcstack_limit > 0);
112 	ASSERT(dtrace_ustackdepth_max > 0);
113 
114 	while (pc != 0) {
115 		/*
116 		 * We limit the number of times we can go around this
117 		 * loop to account for a circular stack.
118 		 */
119 		if (ret++ >= dtrace_ustackdepth_max) {
120 			*flags |= CPU_DTRACE_BADSTACK;
121 			cpu_core[curcpu].cpuc_dtrace_illval = sp;
122 			break;
123 		}
124 
125 		if (pcstack != NULL) {
126 			*pcstack++ = (uint64_t)pc;
127 			pcstack_limit--;
128 			if (pcstack_limit <= 0)
129 				break;
130 		}
131 
132 		if (sp == 0)
133 			break;
134 
135 		oldsp = sp;
136 
137 		pc = dtrace_fuword64((void *)(sp +
138 			offsetof(struct amd64_frame, f_retaddr)));
139 		sp = dtrace_fuword64((void *)sp);
140 
141 		if (sp == oldsp) {
142 			*flags |= CPU_DTRACE_BADSTACK;
143 			cpu_core[curcpu].cpuc_dtrace_illval = sp;
144 			break;
145 		}
146 
147 		/*
148 		 * This is totally bogus:  if we faulted, we're going to clear
149 		 * the fault and break.  This is to deal with the apparently
150 		 * broken Java stacks on x86.
151 		 */
152 		if (*flags & CPU_DTRACE_FAULT) {
153 			*flags &= ~CPU_DTRACE_FAULT;
154 			break;
155 		}
156 	}
157 
158 	return (ret);
159 }
160 
161 void
162 dtrace_getupcstack(uint64_t *pcstack, int pcstack_limit)
163 {
164 	proc_t *p = curproc;
165 	struct trapframe *tf;
166 	uintptr_t pc, sp, fp;
167 	volatile uint16_t *flags =
168 	    (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
169 	int n;
170 
171 	if (*flags & CPU_DTRACE_FAULT)
172 		return;
173 
174 	if (pcstack_limit <= 0)
175 		return;
176 
177 	/*
178 	 * If there's no user context we still need to zero the stack.
179 	 */
180 	if (p == NULL || (tf = curthread->td_frame) == NULL)
181 		goto zero;
182 
183 	*pcstack++ = (uint64_t)p->p_pid;
184 	pcstack_limit--;
185 
186 	if (pcstack_limit <= 0)
187 		return;
188 
189 	pc = tf->tf_rip;
190 	fp = tf->tf_rbp;
191 	sp = tf->tf_rsp;
192 
193 	if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
194 		/*
195 		 * In an entry probe.  The frame pointer has not yet been
196 		 * pushed (that happens in the function prologue).  The
197 		 * best approach is to add the current pc as a missing top
198 		 * of stack and back the pc up to the caller, which is stored
199 		 * at the current stack pointer address since the call
200 		 * instruction puts it there right before the branch.
201 		 */
202 
203 		*pcstack++ = (uint64_t)pc;
204 		pcstack_limit--;
205 		if (pcstack_limit <= 0)
206 			return;
207 
208 		pc = dtrace_fuword64((void *) sp);
209 	}
210 
211 	n = dtrace_getustack_common(pcstack, pcstack_limit, pc, fp);
212 	ASSERT(n >= 0);
213 	ASSERT(n <= pcstack_limit);
214 
215 	pcstack += n;
216 	pcstack_limit -= n;
217 
218 zero:
219 	while (pcstack_limit-- > 0)
220 		*pcstack++ = 0;
221 }
222 
223 int
224 dtrace_getustackdepth(void)
225 {
226 	proc_t *p = curproc;
227 	struct trapframe *tf;
228 	uintptr_t pc, fp, sp;
229 	int n = 0;
230 
231 	if (p == NULL || (tf = curthread->td_frame) == NULL)
232 		return (0);
233 
234 	if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_FAULT))
235 		return (-1);
236 
237 	pc = tf->tf_rip;
238 	fp = tf->tf_rbp;
239 	sp = tf->tf_rsp;
240 
241 	if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
242 		/*
243 		 * In an entry probe.  The frame pointer has not yet been
244 		 * pushed (that happens in the function prologue).  The
245 		 * best approach is to add the current pc as a missing top
246 		 * of stack and back the pc up to the caller, which is stored
247 		 * at the current stack pointer address since the call
248 		 * instruction puts it there right before the branch.
249 		 */
250 
251 		pc = dtrace_fuword64((void *) sp);
252 		n++;
253 	}
254 
255 	n += dtrace_getustack_common(NULL, 0, pc, fp);
256 
257 	return (n);
258 }
259 
260 void
261 dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit)
262 {
263 	proc_t *p = curproc;
264 	struct trapframe *tf;
265 	uintptr_t pc, sp, fp;
266 	volatile uint16_t *flags =
267 	    (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
268 #ifdef notyet	/* XXX signal stack */
269 	uintptr_t oldcontext;
270 	size_t s1, s2;
271 #endif
272 
273 	if (*flags & CPU_DTRACE_FAULT)
274 		return;
275 
276 	if (pcstack_limit <= 0)
277 		return;
278 
279 	/*
280 	 * If there's no user context we still need to zero the stack.
281 	 */
282 	if (p == NULL || (tf = curthread->td_frame) == NULL)
283 		goto zero;
284 
285 	*pcstack++ = (uint64_t)p->p_pid;
286 	pcstack_limit--;
287 
288 	if (pcstack_limit <= 0)
289 		return;
290 
291 	pc = tf->tf_rip;
292 	sp = tf->tf_rsp;
293 	fp = tf->tf_rbp;
294 
295 #ifdef notyet /* XXX signal stack */
296 	oldcontext = lwp->lwp_oldcontext;
297 	s1 = sizeof (struct xframe) + 2 * sizeof (long);
298 	s2 = s1 + sizeof (siginfo_t);
299 #endif
300 
301 	if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
302 		*pcstack++ = (uint64_t)pc;
303 		*fpstack++ = 0;
304 		pcstack_limit--;
305 		if (pcstack_limit <= 0)
306 			return;
307 
308 		pc = dtrace_fuword64((void *)sp);
309 	}
310 
311 	while (pc != 0) {
312 		*pcstack++ = (uint64_t)pc;
313 		*fpstack++ = fp;
314 		pcstack_limit--;
315 		if (pcstack_limit <= 0)
316 			break;
317 
318 		if (fp == 0)
319 			break;
320 
321 #ifdef notyet /* XXX signal stack */
322 		if (oldcontext == sp + s1 || oldcontext == sp + s2) {
323 			ucontext_t *ucp = (ucontext_t *)oldcontext;
324 			greg_t *gregs = ucp->uc_mcontext.gregs;
325 
326 			sp = dtrace_fulword(&gregs[REG_FP]);
327 			pc = dtrace_fulword(&gregs[REG_PC]);
328 
329 			oldcontext = dtrace_fulword(&ucp->uc_link);
330 		} else
331 #endif /* XXX */
332 		{
333 			pc = dtrace_fuword64((void *)(fp +
334 				offsetof(struct amd64_frame, f_retaddr)));
335 			fp = dtrace_fuword64((void *)fp);
336 		}
337 
338 		/*
339 		 * This is totally bogus:  if we faulted, we're going to clear
340 		 * the fault and break.  This is to deal with the apparently
341 		 * broken Java stacks on x86.
342 		 */
343 		if (*flags & CPU_DTRACE_FAULT) {
344 			*flags &= ~CPU_DTRACE_FAULT;
345 			break;
346 		}
347 	}
348 
349 zero:
350 	while (pcstack_limit-- > 0)
351 		*pcstack++ = 0;
352 }
353 
354 /*ARGSUSED*/
355 uint64_t
356 dtrace_getarg(int arg, int aframes)
357 {
358 	uintptr_t val;
359 	struct amd64_frame *fp = (struct amd64_frame *)dtrace_getfp();
360 	uintptr_t *stack;
361 	int i;
362 
363 	/*
364 	 * A total of 6 arguments are passed via registers; any argument with
365 	 * index of 5 or lower is therefore in a register.
366 	 */
367 	int inreg = 5;
368 
369 	for (i = 1; i <= aframes; i++) {
370 		fp = fp->f_frame;
371 
372 		if (roundup2(fp->f_retaddr, 16) ==
373 		    (long)dtrace_invop_callsite) {
374 			/*
375 			 * In the case of amd64, we will use the pointer to the
376 			 * regs structure that was pushed when we took the
377 			 * trap.  To get this structure, we must increment
378 			 * beyond the frame structure, and then again beyond
379 			 * the calling RIP stored in dtrace_invop().  If the
380 			 * argument that we're seeking is passed on the stack,
381 			 * we'll pull the true stack pointer out of the saved
382 			 * registers and decrement our argument by the number
383 			 * of arguments passed in registers; if the argument
384 			 * we're seeking is passed in registers, we can just
385 			 * load it directly.
386 			 */
387 			struct trapframe *tf = (struct trapframe *)&fp[1];
388 
389 			if (arg <= inreg) {
390 				switch (arg) {
391 				case 0:
392 					stack = (uintptr_t *)&tf->tf_rdi;
393 					break;
394 				case 1:
395 					stack = (uintptr_t *)&tf->tf_rsi;
396 					break;
397 				case 2:
398 					stack = (uintptr_t *)&tf->tf_rdx;
399 					break;
400 				case 3:
401 					stack = (uintptr_t *)&tf->tf_rcx;
402 					break;
403 				case 4:
404 					stack = (uintptr_t *)&tf->tf_r8;
405 					break;
406 				case 5:
407 					stack = (uintptr_t *)&tf->tf_r9;
408 					break;
409 				}
410 				arg = 0;
411 			} else {
412 				stack = (uintptr_t *)(tf->tf_rsp);
413 				arg -= inreg;
414 			}
415 			goto load;
416 		}
417 
418 	}
419 
420 	/*
421 	 * We know that we did not come through a trap to get into
422 	 * dtrace_probe() -- the provider simply called dtrace_probe()
423 	 * directly.  As this is the case, we need to shift the argument
424 	 * that we're looking for:  the probe ID is the first argument to
425 	 * dtrace_probe(), so the argument n will actually be found where
426 	 * one would expect to find argument (n + 1).
427 	 */
428 	arg++;
429 
430 	if (arg <= inreg) {
431 		/*
432 		 * This shouldn't happen.  If the argument is passed in a
433 		 * register then it should have been, well, passed in a
434 		 * register...
435 		 */
436 		DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
437 		return (0);
438 	}
439 
440 	arg -= (inreg + 1);
441 	stack = (uintptr_t *)&fp[1];
442 
443 load:
444 	DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
445 	val = stack[arg];
446 	DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT);
447 
448 	return (val);
449 }
450 
451 int
452 dtrace_getstackdepth(int aframes)
453 {
454 	int depth = 0;
455 	struct amd64_frame *frame;
456 	vm_offset_t rbp;
457 
458 	aframes++;
459 	rbp = dtrace_getfp();
460 	frame = (struct amd64_frame *)rbp;
461 	depth++;
462 	for(;;) {
463 		if (!kstack_contains(curthread, (vm_offset_t)frame,
464 		    sizeof(*frame)))
465 			break;
466 		depth++;
467 		if (frame->f_frame <= frame)
468 			break;
469 		frame = frame->f_frame;
470 	}
471 	if (depth < aframes)
472 		return 0;
473 	else
474 		return depth - aframes;
475 }
476 
477 ulong_t
478 dtrace_getreg(struct trapframe *frame, uint_t reg)
479 {
480 	/* This table is dependent on reg.d. */
481 	int regmap[] = {
482 		REG_GS,		/* 0  GS */
483 		REG_FS,		/* 1  FS */
484 		REG_ES,		/* 2  ES */
485 		REG_DS,		/* 3  DS */
486 		REG_RDI,	/* 4  EDI */
487 		REG_RSI,	/* 5  ESI */
488 		REG_RBP,	/* 6  EBP, REG_FP */
489 		REG_RSP,	/* 7  ESP */
490 		REG_RBX,	/* 8  EBX, REG_R1 */
491 		REG_RDX,	/* 9  EDX */
492 		REG_RCX,	/* 10 ECX */
493 		REG_RAX,	/* 11 EAX, REG_R0 */
494 		REG_TRAPNO,	/* 12 TRAPNO */
495 		REG_ERR,	/* 13 ERR */
496 		REG_RIP,	/* 14 EIP, REG_PC */
497 		REG_CS,		/* 15 CS */
498 		REG_RFL,	/* 16 EFL, REG_PS */
499 		REG_RSP,	/* 17 UESP, REG_SP */
500 		REG_SS		/* 18 SS */
501 	};
502 
503 	if (reg <= GS) {
504 		if (reg >= sizeof (regmap) / sizeof (int)) {
505 			DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
506 			return (0);
507 		}
508 
509 		reg = regmap[reg];
510 	} else {
511 		/* This is dependent on reg.d. */
512 		reg -= GS + 1;
513 	}
514 
515 	switch (reg) {
516 	case REG_RDI:
517 		return (frame->tf_rdi);
518 	case REG_RSI:
519 		return (frame->tf_rsi);
520 	case REG_RDX:
521 		return (frame->tf_rdx);
522 	case REG_RCX:
523 		return (frame->tf_rcx);
524 	case REG_R8:
525 		return (frame->tf_r8);
526 	case REG_R9:
527 		return (frame->tf_r9);
528 	case REG_RAX:
529 		return (frame->tf_rax);
530 	case REG_RBX:
531 		return (frame->tf_rbx);
532 	case REG_RBP:
533 		return (frame->tf_rbp);
534 	case REG_R10:
535 		return (frame->tf_r10);
536 	case REG_R11:
537 		return (frame->tf_r11);
538 	case REG_R12:
539 		return (frame->tf_r12);
540 	case REG_R13:
541 		return (frame->tf_r13);
542 	case REG_R14:
543 		return (frame->tf_r14);
544 	case REG_R15:
545 		return (frame->tf_r15);
546 	case REG_DS:
547 		return (frame->tf_ds);
548 	case REG_ES:
549 		return (frame->tf_es);
550 	case REG_FS:
551 		return (frame->tf_fs);
552 	case REG_GS:
553 		return (frame->tf_gs);
554 	case REG_TRAPNO:
555 		return (frame->tf_trapno);
556 	case REG_ERR:
557 		return (frame->tf_err);
558 	case REG_RIP:
559 		return (frame->tf_rip);
560 	case REG_CS:
561 		return (frame->tf_cs);
562 	case REG_SS:
563 		return (frame->tf_ss);
564 	case REG_RFL:
565 		return (frame->tf_rflags);
566 	case REG_RSP:
567 		return (frame->tf_rsp);
568 	default:
569 		DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
570 		return (0);
571 	}
572 }
573 
574 static int
575 dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size)
576 {
577 	ASSERT(INKERNEL(kaddr) && kaddr + size >= kaddr);
578 
579 	if (uaddr + size > VM_MAXUSER_ADDRESS || uaddr + size < uaddr) {
580 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
581 		cpu_core[curcpu].cpuc_dtrace_illval = uaddr;
582 		return (0);
583 	}
584 
585 	return (1);
586 }
587 
588 void
589 dtrace_copyin(uintptr_t uaddr, uintptr_t kaddr, size_t size,
590     volatile uint16_t *flags)
591 {
592 	if (dtrace_copycheck(uaddr, kaddr, size))
593 		dtrace_copy(uaddr, kaddr, size);
594 }
595 
596 void
597 dtrace_copyout(uintptr_t kaddr, uintptr_t uaddr, size_t size,
598     volatile uint16_t *flags)
599 {
600 	if (dtrace_copycheck(uaddr, kaddr, size))
601 		dtrace_copy(kaddr, uaddr, size);
602 }
603 
604 void
605 dtrace_copyinstr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
606     volatile uint16_t *flags)
607 {
608 	if (dtrace_copycheck(uaddr, kaddr, size))
609 		dtrace_copystr(uaddr, kaddr, size, flags);
610 }
611 
612 void
613 dtrace_copyoutstr(uintptr_t kaddr, uintptr_t uaddr, size_t size,
614     volatile uint16_t *flags)
615 {
616 	if (dtrace_copycheck(uaddr, kaddr, size))
617 		dtrace_copystr(kaddr, uaddr, size, flags);
618 }
619 
620 uint8_t
621 dtrace_fuword8(void *uaddr)
622 {
623 	if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
624 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
625 		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
626 		return (0);
627 	}
628 	return (dtrace_fuword8_nocheck(uaddr));
629 }
630 
631 uint16_t
632 dtrace_fuword16(void *uaddr)
633 {
634 	if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
635 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
636 		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
637 		return (0);
638 	}
639 	return (dtrace_fuword16_nocheck(uaddr));
640 }
641 
642 uint32_t
643 dtrace_fuword32(void *uaddr)
644 {
645 	if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
646 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
647 		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
648 		return (0);
649 	}
650 	return (dtrace_fuword32_nocheck(uaddr));
651 }
652 
653 uint64_t
654 dtrace_fuword64(void *uaddr)
655 {
656 	if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
657 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
658 		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
659 		return (0);
660 	}
661 	return (dtrace_fuword64_nocheck(uaddr));
662 }
663 
664 /*
665  * ifunc resolvers for SMAP support
666  */
667 void dtrace_copy_nosmap(uintptr_t, uintptr_t, size_t);
668 void dtrace_copy_smap(uintptr_t, uintptr_t, size_t);
669 DEFINE_IFUNC(, void, dtrace_copy, (uintptr_t, uintptr_t, size_t))
670 {
671 
672 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
673 	    dtrace_copy_smap : dtrace_copy_nosmap);
674 }
675 
676 void dtrace_copystr_nosmap(uintptr_t, uintptr_t, size_t, volatile uint16_t *);
677 void dtrace_copystr_smap(uintptr_t, uintptr_t, size_t, volatile uint16_t *);
678 DEFINE_IFUNC(, void, dtrace_copystr, (uintptr_t, uintptr_t, size_t,
679     volatile uint16_t *))
680 {
681 
682 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
683 	    dtrace_copystr_smap : dtrace_copystr_nosmap);
684 }
685 
686 uintptr_t dtrace_fulword_nosmap(void *);
687 uintptr_t dtrace_fulword_smap(void *);
688 DEFINE_IFUNC(, uintptr_t, dtrace_fulword, (void *))
689 {
690 
691 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
692 	    dtrace_fulword_smap : dtrace_fulword_nosmap);
693 }
694 
695 uint8_t dtrace_fuword8_nocheck_nosmap(void *);
696 uint8_t dtrace_fuword8_nocheck_smap(void *);
697 DEFINE_IFUNC(, uint8_t, dtrace_fuword8_nocheck, (void *))
698 {
699 
700 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
701 	    dtrace_fuword8_nocheck_smap : dtrace_fuword8_nocheck_nosmap);
702 }
703 
704 uint16_t dtrace_fuword16_nocheck_nosmap(void *);
705 uint16_t dtrace_fuword16_nocheck_smap(void *);
706 DEFINE_IFUNC(, uint16_t, dtrace_fuword16_nocheck, (void *))
707 {
708 
709 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
710 	    dtrace_fuword16_nocheck_smap : dtrace_fuword16_nocheck_nosmap);
711 }
712 
713 uint32_t dtrace_fuword32_nocheck_nosmap(void *);
714 uint32_t dtrace_fuword32_nocheck_smap(void *);
715 DEFINE_IFUNC(, uint32_t, dtrace_fuword32_nocheck, (void *))
716 {
717 
718 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
719 	    dtrace_fuword32_nocheck_smap : dtrace_fuword32_nocheck_nosmap);
720 }
721 
722 uint64_t dtrace_fuword64_nocheck_nosmap(void *);
723 uint64_t dtrace_fuword64_nocheck_smap(void *);
724 DEFINE_IFUNC(, uint64_t, dtrace_fuword64_nocheck, (void *))
725 {
726 
727 	return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
728 	    dtrace_fuword64_nocheck_smap : dtrace_fuword64_nocheck_nosmap);
729 }
730