Deleted Added
full compact
dtrace_isa.c (179237) dtrace_isa.c (211608)
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 *

--- 5 unchanged lines hidden (view full) ---

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 *
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 *

--- 5 unchanged lines hidden (view full) ---

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 * $FreeBSD: head/sys/cddl/dev/dtrace/i386/dtrace_isa.c 179237 2008-05-23 05:59:42Z jb $
22 * $FreeBSD: head/sys/cddl/dev/dtrace/i386/dtrace_isa.c 211608 2010-08-22 10:53:32Z rpaulo $
23 */
24/*
25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28#include <sys/cdefs.h>
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/stack.h>
34#include <sys/pcpu.h>
35
23 */
24/*
25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28#include <sys/cdefs.h>
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/kernel.h>
33#include <sys/stack.h>
34#include <sys/pcpu.h>
35
36#include <machine/frame.h>
36#include <machine/md_var.h>
37#include <machine/md_var.h>
38#include <machine/pcb.h>
37#include <machine/stack.h>
38
39#include <vm/vm.h>
40#include <vm/vm_param.h>
41#include <vm/pmap.h>
42
39#include <machine/stack.h>
40
41#include <vm/vm.h>
42#include <vm/vm_param.h>
43#include <vm/pmap.h>
44
45#include "regset.h"
46
43extern uintptr_t kernbase;
44uintptr_t kernelbase = (uintptr_t) &kernbase;
45
46#define INKERNEL(va) (((vm_offset_t)(va)) >= USRSTACK && \
47 ((vm_offset_t)(va)) < VM_MAX_KERNEL_ADDRESS)
48
49uint8_t dtrace_fuword8_nocheck(void *);
50uint16_t dtrace_fuword16_nocheck(void *);

--- 44 unchanged lines hidden (view full) ---

95 frame = frame->f_frame;
96 }
97
98 for (; depth < pcstack_limit; depth++) {
99 pcstack[depth] = 0;
100 }
101}
102
47extern uintptr_t kernbase;
48uintptr_t kernelbase = (uintptr_t) &kernbase;
49
50#define INKERNEL(va) (((vm_offset_t)(va)) >= USRSTACK && \
51 ((vm_offset_t)(va)) < VM_MAX_KERNEL_ADDRESS)
52
53uint8_t dtrace_fuword8_nocheck(void *);
54uint16_t dtrace_fuword16_nocheck(void *);

--- 44 unchanged lines hidden (view full) ---

99 frame = frame->f_frame;
100 }
101
102 for (; depth < pcstack_limit; depth++) {
103 pcstack[depth] = 0;
104 }
105}
106
103#ifdef notyet
104static int
105dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc,
106 uintptr_t sp)
107{
107static int
108dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc,
109 uintptr_t sp)
110{
108 klwp_t *lwp = ttolwp(curthread);
111#ifdef notyet
109 proc_t *p = curproc;
112 proc_t *p = curproc;
110 uintptr_t oldcontext = lwp->lwp_oldcontext;
113 uintptr_t oldcontext = lwp->lwp_oldcontext; /* XXX signal stack. */
114 size_t s1, s2;
115#endif
111 volatile uint16_t *flags =
112 (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
116 volatile uint16_t *flags =
117 (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
113 size_t s1, s2;
114 int ret = 0;
115
116 ASSERT(pcstack == NULL || pcstack_limit > 0);
117
118 int ret = 0;
119
120 ASSERT(pcstack == NULL || pcstack_limit > 0);
121
122#ifdef notyet /* XXX signal stack. */
118 if (p->p_model == DATAMODEL_NATIVE) {
119 s1 = sizeof (struct frame) + 2 * sizeof (long);
120 s2 = s1 + sizeof (siginfo_t);
121 } else {
122 s1 = sizeof (struct frame32) + 3 * sizeof (int);
123 s2 = s1 + sizeof (siginfo32_t);
124 }
123 if (p->p_model == DATAMODEL_NATIVE) {
124 s1 = sizeof (struct frame) + 2 * sizeof (long);
125 s2 = s1 + sizeof (siginfo_t);
126 } else {
127 s1 = sizeof (struct frame32) + 3 * sizeof (int);
128 s2 = s1 + sizeof (siginfo32_t);
129 }
130#endif
125
131
126 while (pc != 0 && sp != 0) {
132 while (pc != 0) {
127 ret++;
128 if (pcstack != NULL) {
129 *pcstack++ = (uint64_t)pc;
130 pcstack_limit--;
131 if (pcstack_limit <= 0)
132 break;
133 }
134
133 ret++;
134 if (pcstack != NULL) {
135 *pcstack++ = (uint64_t)pc;
136 pcstack_limit--;
137 if (pcstack_limit <= 0)
138 break;
139 }
140
141 if (sp == 0)
142 break;
143
144#ifdef notyet /* XXX signal stack. */
135 if (oldcontext == sp + s1 || oldcontext == sp + s2) {
136 if (p->p_model == DATAMODEL_NATIVE) {
137 ucontext_t *ucp = (ucontext_t *)oldcontext;
138 greg_t *gregs = ucp->uc_mcontext.gregs;
139
140 sp = dtrace_fulword(&gregs[REG_FP]);
141 pc = dtrace_fulword(&gregs[REG_PC]);
142

--- 15 unchanged lines hidden (view full) ---

158 sp = dtrace_fulword(&fr->fr_savfp);
159 } else {
160 struct frame32 *fr = (struct frame32 *)sp;
161
162 pc = dtrace_fuword32(&fr->fr_savpc);
163 sp = dtrace_fuword32(&fr->fr_savfp);
164 }
165 }
145 if (oldcontext == sp + s1 || oldcontext == sp + s2) {
146 if (p->p_model == DATAMODEL_NATIVE) {
147 ucontext_t *ucp = (ucontext_t *)oldcontext;
148 greg_t *gregs = ucp->uc_mcontext.gregs;
149
150 sp = dtrace_fulword(&gregs[REG_FP]);
151 pc = dtrace_fulword(&gregs[REG_PC]);
152

--- 15 unchanged lines hidden (view full) ---

168 sp = dtrace_fulword(&fr->fr_savfp);
169 } else {
170 struct frame32 *fr = (struct frame32 *)sp;
171
172 pc = dtrace_fuword32(&fr->fr_savpc);
173 sp = dtrace_fuword32(&fr->fr_savfp);
174 }
175 }
176#else
177 pc = dtrace_fuword32((void *)(sp +
178 offsetof(struct i386_frame, f_retaddr)));
179 sp = dtrace_fuword32((void *)sp);
180#endif /* ! notyet */
166
167 /*
168 * This is totally bogus: if we faulted, we're going to clear
169 * the fault and break. This is to deal with the apparently
170 * broken Java stacks on x86.
171 */
172 if (*flags & CPU_DTRACE_FAULT) {
173 *flags &= ~CPU_DTRACE_FAULT;
174 break;
175 }
176 }
177
178 return (ret);
179}
180
181void
182dtrace_getupcstack(uint64_t *pcstack, int pcstack_limit)
183{
181
182 /*
183 * This is totally bogus: if we faulted, we're going to clear
184 * the fault and break. This is to deal with the apparently
185 * broken Java stacks on x86.
186 */
187 if (*flags & CPU_DTRACE_FAULT) {
188 *flags &= ~CPU_DTRACE_FAULT;
189 break;
190 }
191 }
192
193 return (ret);
194}
195
196void
197dtrace_getupcstack(uint64_t *pcstack, int pcstack_limit)
198{
184 klwp_t *lwp = ttolwp(curthread);
185 proc_t *p = curproc;
199 proc_t *p = curproc;
186 struct regs *rp;
187 uintptr_t pc, sp;
200 struct trapframe *tf;
201 uintptr_t pc, sp, fp;
188 volatile uint16_t *flags =
189 (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
190 int n;
191
192 if (*flags & CPU_DTRACE_FAULT)
193 return;
194
195 if (pcstack_limit <= 0)
196 return;
197
198 /*
199 * If there's no user context we still need to zero the stack.
200 */
202 volatile uint16_t *flags =
203 (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
204 int n;
205
206 if (*flags & CPU_DTRACE_FAULT)
207 return;
208
209 if (pcstack_limit <= 0)
210 return;
211
212 /*
213 * If there's no user context we still need to zero the stack.
214 */
201 if (lwp == NULL || p == NULL || (rp = lwp->lwp_regs) == NULL)
215 if (p == NULL || (tf = curthread->td_frame) == NULL)
202 goto zero;
203
204 *pcstack++ = (uint64_t)p->p_pid;
205 pcstack_limit--;
206
207 if (pcstack_limit <= 0)
208 return;
209
216 goto zero;
217
218 *pcstack++ = (uint64_t)p->p_pid;
219 pcstack_limit--;
220
221 if (pcstack_limit <= 0)
222 return;
223
210 pc = rp->r_pc;
211 sp = rp->r_fp;
224 pc = tf->tf_eip;
225 fp = tf->tf_ebp;
226 sp = tf->tf_esp;
212
213 if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
227
228 if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
229 /*
230 * In an entry probe. The frame pointer has not yet been
231 * pushed (that happens in the function prologue). The
232 * best approach is to add the current pc as a missing top
233 * of stack and back the pc up to the caller, which is stored
234 * at the current stack pointer address since the call
235 * instruction puts it there right before the branch.
236 */
237
214 *pcstack++ = (uint64_t)pc;
215 pcstack_limit--;
216 if (pcstack_limit <= 0)
217 return;
218
238 *pcstack++ = (uint64_t)pc;
239 pcstack_limit--;
240 if (pcstack_limit <= 0)
241 return;
242
219 if (p->p_model == DATAMODEL_NATIVE)
220 pc = dtrace_fulword((void *)rp->r_sp);
221 else
222 pc = dtrace_fuword32((void *)rp->r_sp);
243 pc = dtrace_fuword32((void *) sp);
223 }
224
225 n = dtrace_getustack_common(pcstack, pcstack_limit, pc, sp);
226 ASSERT(n >= 0);
227 ASSERT(n <= pcstack_limit);
228
229 pcstack += n;
230 pcstack_limit -= n;
231
232zero:
233 while (pcstack_limit-- > 0)
244 }
245
246 n = dtrace_getustack_common(pcstack, pcstack_limit, pc, sp);
247 ASSERT(n >= 0);
248 ASSERT(n <= pcstack_limit);
249
250 pcstack += n;
251 pcstack_limit -= n;
252
253zero:
254 while (pcstack_limit-- > 0)
234 *pcstack++ = NULL;
255 *pcstack++ = 0;
235}
236
237int
238dtrace_getustackdepth(void)
239{
256}
257
258int
259dtrace_getustackdepth(void)
260{
261 proc_t *p = curproc;
262 struct trapframe *tf;
263 uintptr_t pc, fp, sp;
264 int n = 0;
265
266 if (p == NULL || (tf = curthread->td_frame) == NULL)
267 return (0);
268
269 if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_FAULT))
270 return (-1);
271
272 pc = tf->tf_eip;
273 fp = tf->tf_ebp;
274 sp = tf->tf_esp;
275
276 if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
277 /*
278 * In an entry probe. The frame pointer has not yet been
279 * pushed (that happens in the function prologue). The
280 * best approach is to add the current pc as a missing top
281 * of stack and back the pc up to the caller, which is stored
282 * at the current stack pointer address since the call
283 * instruction puts it there right before the branch.
284 */
285
286 pc = dtrace_fuword32((void *) sp);
287 n++;
288 }
289
290 n += dtrace_getustack_common(NULL, 0, pc, fp);
291
292 return (n);
240}
241
242void
243dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit)
244{
293}
294
295void
296dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit)
297{
245 klwp_t *lwp = ttolwp(curthread);
246 proc_t *p = curproc;
298 proc_t *p = curproc;
247 struct regs *rp;
248 uintptr_t pc, sp, oldcontext;
299 struct trapframe *tf;
300 uintptr_t pc, sp, fp;
249 volatile uint16_t *flags =
250 (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
301 volatile uint16_t *flags =
302 (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
303#ifdef notyet /* XXX signal stack */
304 uintptr_t oldcontext;
251 size_t s1, s2;
305 size_t s1, s2;
306#endif
252
253 if (*flags & CPU_DTRACE_FAULT)
254 return;
255
256 if (pcstack_limit <= 0)
257 return;
258
259 /*
260 * If there's no user context we still need to zero the stack.
261 */
307
308 if (*flags & CPU_DTRACE_FAULT)
309 return;
310
311 if (pcstack_limit <= 0)
312 return;
313
314 /*
315 * If there's no user context we still need to zero the stack.
316 */
262 if (lwp == NULL || p == NULL || (rp = lwp->lwp_regs) == NULL)
317 if (p == NULL || (tf = curthread->td_frame) == NULL)
263 goto zero;
264
265 *pcstack++ = (uint64_t)p->p_pid;
266 pcstack_limit--;
267
268 if (pcstack_limit <= 0)
269 return;
270
318 goto zero;
319
320 *pcstack++ = (uint64_t)p->p_pid;
321 pcstack_limit--;
322
323 if (pcstack_limit <= 0)
324 return;
325
271 pc = rp->r_pc;
272 sp = rp->r_fp;
326 pc = tf->tf_eip;
327 fp = tf->tf_ebp;
328 sp = tf->tf_esp;
329
330#ifdef notyet /* XXX signal stack */
273 oldcontext = lwp->lwp_oldcontext;
274
275 if (p->p_model == DATAMODEL_NATIVE) {
276 s1 = sizeof (struct frame) + 2 * sizeof (long);
277 s2 = s1 + sizeof (siginfo_t);
278 } else {
279 s1 = sizeof (struct frame32) + 3 * sizeof (int);
280 s2 = s1 + sizeof (siginfo32_t);
281 }
331 oldcontext = lwp->lwp_oldcontext;
332
333 if (p->p_model == DATAMODEL_NATIVE) {
334 s1 = sizeof (struct frame) + 2 * sizeof (long);
335 s2 = s1 + sizeof (siginfo_t);
336 } else {
337 s1 = sizeof (struct frame32) + 3 * sizeof (int);
338 s2 = s1 + sizeof (siginfo32_t);
339 }
340#endif
282
283 if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
284 *pcstack++ = (uint64_t)pc;
285 *fpstack++ = 0;
286 pcstack_limit--;
287 if (pcstack_limit <= 0)
288 return;
289
341
342 if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
343 *pcstack++ = (uint64_t)pc;
344 *fpstack++ = 0;
345 pcstack_limit--;
346 if (pcstack_limit <= 0)
347 return;
348
290 if (p->p_model == DATAMODEL_NATIVE)
291 pc = dtrace_fulword((void *)rp->r_sp);
292 else
293 pc = dtrace_fuword32((void *)rp->r_sp);
349 pc = dtrace_fuword32((void *)sp);
294 }
295
350 }
351
296 while (pc != 0 && sp != 0) {
352 while (pc != 0) {
297 *pcstack++ = (uint64_t)pc;
353 *pcstack++ = (uint64_t)pc;
298 *fpstack++ = sp;
354 *fpstack++ = fp;
299 pcstack_limit--;
300 if (pcstack_limit <= 0)
301 break;
302
355 pcstack_limit--;
356 if (pcstack_limit <= 0)
357 break;
358
359 if (fp == 0)
360 break;
361
362#ifdef notyet /* XXX signal stack */
303 if (oldcontext == sp + s1 || oldcontext == sp + s2) {
304 if (p->p_model == DATAMODEL_NATIVE) {
305 ucontext_t *ucp = (ucontext_t *)oldcontext;
306 greg_t *gregs = ucp->uc_mcontext.gregs;
307
308 sp = dtrace_fulword(&gregs[REG_FP]);
309 pc = dtrace_fulword(&gregs[REG_PC]);
310
311 oldcontext = dtrace_fulword(&ucp->uc_link);
312 } else {
313 ucontext_t *ucp = (ucontext_t *)oldcontext;
314 greg_t *gregs = ucp->uc_mcontext.gregs;
315
316 sp = dtrace_fuword32(&gregs[EBP]);
317 pc = dtrace_fuword32(&gregs[EIP]);
318
319 oldcontext = dtrace_fuword32(&ucp->uc_link);
320 }
363 if (oldcontext == sp + s1 || oldcontext == sp + s2) {
364 if (p->p_model == DATAMODEL_NATIVE) {
365 ucontext_t *ucp = (ucontext_t *)oldcontext;
366 greg_t *gregs = ucp->uc_mcontext.gregs;
367
368 sp = dtrace_fulword(&gregs[REG_FP]);
369 pc = dtrace_fulword(&gregs[REG_PC]);
370
371 oldcontext = dtrace_fulword(&ucp->uc_link);
372 } else {
373 ucontext_t *ucp = (ucontext_t *)oldcontext;
374 greg_t *gregs = ucp->uc_mcontext.gregs;
375
376 sp = dtrace_fuword32(&gregs[EBP]);
377 pc = dtrace_fuword32(&gregs[EIP]);
378
379 oldcontext = dtrace_fuword32(&ucp->uc_link);
380 }
321 } else {
322 if (p->p_model == DATAMODEL_NATIVE) {
323 struct frame *fr = (struct frame *)sp;
324
325 pc = dtrace_fulword(&fr->fr_savpc);
326 sp = dtrace_fulword(&fr->fr_savfp);
327 } else {
328 struct frame32 *fr = (struct frame32 *)sp;
329
330 pc = dtrace_fuword32(&fr->fr_savpc);
331 sp = dtrace_fuword32(&fr->fr_savfp);
332 }
381 } else
382#endif /* XXX */
383 {
384 pc = dtrace_fuword32((void *)(fp +
385 offsetof(struct i386_frame, f_retaddr)));
386 fp = dtrace_fuword32((void *)fp);
333 }
334
335 /*
336 * This is totally bogus: if we faulted, we're going to clear
337 * the fault and break. This is to deal with the apparently
338 * broken Java stacks on x86.
339 */
340 if (*flags & CPU_DTRACE_FAULT) {
341 *flags &= ~CPU_DTRACE_FAULT;
342 break;
343 }
344 }
345
346zero:
347 while (pcstack_limit-- > 0)
387 }
388
389 /*
390 * This is totally bogus: if we faulted, we're going to clear
391 * the fault and break. This is to deal with the apparently
392 * broken Java stacks on x86.
393 */
394 if (*flags & CPU_DTRACE_FAULT) {
395 *flags &= ~CPU_DTRACE_FAULT;
396 break;
397 }
398 }
399
400zero:
401 while (pcstack_limit-- > 0)
348 *pcstack++ = NULL;
402 *pcstack++ = 0;
349}
403}
350#endif
351
352uint64_t
353dtrace_getarg(int arg, int aframes)
354{
355 uintptr_t val;
356 struct i386_frame *fp = (struct i386_frame *)dtrace_getfp();
357 uintptr_t *stack;
358 int i;

--- 60 unchanged lines hidden (view full) ---

419 frame = frame->f_frame;
420 }
421 if (depth < aframes)
422 return 0;
423 else
424 return depth - aframes;
425}
426
404
405uint64_t
406dtrace_getarg(int arg, int aframes)
407{
408 uintptr_t val;
409 struct i386_frame *fp = (struct i386_frame *)dtrace_getfp();
410 uintptr_t *stack;
411 int i;

--- 60 unchanged lines hidden (view full) ---

472 frame = frame->f_frame;
473 }
474 if (depth < aframes)
475 return 0;
476 else
477 return depth - aframes;
478}
479
427#ifdef notyet
428ulong_t
480ulong_t
429dtrace_getreg(struct regs *rp, uint_t reg)
481dtrace_getreg(struct trapframe *rp, uint_t reg)
430{
482{
431#if defined(__amd64)
432 int regmap[] = {
433 REG_GS, /* GS */
434 REG_FS, /* FS */
435 REG_ES, /* ES */
436 REG_DS, /* DS */
437 REG_RDI, /* EDI */
438 REG_RSI, /* ESI */
439 REG_RBP, /* EBP */
440 REG_RSP, /* ESP */
441 REG_RBX, /* EBX */
442 REG_RDX, /* EDX */
443 REG_RCX, /* ECX */
444 REG_RAX, /* EAX */
445 REG_TRAPNO, /* TRAPNO */
446 REG_ERR, /* ERR */
447 REG_RIP, /* EIP */
448 REG_CS, /* CS */
449 REG_RFL, /* EFL */
450 REG_RSP, /* UESP */
451 REG_SS /* SS */
483 struct pcb *pcb;
484 int regmap[] = { /* Order is dependent on reg.d */
485 REG_GS, /* 0 GS */
486 REG_FS, /* 1 FS */
487 REG_ES, /* 2 ES */
488 REG_DS, /* 3 DS */
489 REG_RDI, /* 4 EDI */
490 REG_RSI, /* 5 ESI */
491 REG_RBP, /* 6 EBP, REG_FP */
492 REG_RSP, /* 7 ESP */
493 REG_RBX, /* 8 EBX */
494 REG_RDX, /* 9 EDX, REG_R1 */
495 REG_RCX, /* 10 ECX */
496 REG_RAX, /* 11 EAX, REG_R0 */
497 REG_TRAPNO, /* 12 TRAPNO */
498 REG_ERR, /* 13 ERR */
499 REG_RIP, /* 14 EIP, REG_PC */
500 REG_CS, /* 15 CS */
501 REG_RFL, /* 16 EFL, REG_PS */
502 REG_RSP, /* 17 UESP, REG_SP */
503 REG_SS /* 18 SS */
452 };
453
504 };
505
454 if (reg <= SS) {
455 if (reg >= sizeof (regmap) / sizeof (int)) {
456 DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
457 return (0);
458 }
506 if (reg > SS) {
507 DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
508 return (0);
509 }
459
510
460 reg = regmap[reg];
461 } else {
462 reg -= SS + 1;
511 if (reg >= sizeof (regmap) / sizeof (int)) {
512 DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
513 return (0);
463 }
464
514 }
515
465 switch (reg) {
516 reg = regmap[reg];
517
518 switch(reg) {
519 case REG_GS:
520 if ((pcb = curthread->td_pcb) == NULL) {
521 DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
522 return (0);
523 }
524 return (pcb->pcb_gs);
525 case REG_FS:
526 return (rp->tf_fs);
527 case REG_ES:
528 return (rp->tf_es);
529 case REG_DS:
530 return (rp->tf_ds);
466 case REG_RDI:
531 case REG_RDI:
467 return (rp->r_rdi);
532 return (rp->tf_edi);
468 case REG_RSI:
533 case REG_RSI:
469 return (rp->r_rsi);
470 case REG_RDX:
471 return (rp->r_rdx);
534 return (rp->tf_esi);
535 case REG_RBP:
536 return (rp->tf_ebp);
537 case REG_RSP:
538 return (rp->tf_isp);
539 case REG_RBX:
540 return (rp->tf_ebx);
472 case REG_RCX:
541 case REG_RCX:
473 return (rp->r_rcx);
474 case REG_R8:
475 return (rp->r_r8);
476 case REG_R9:
477 return (rp->r_r9);
542 return (rp->tf_ecx);
478 case REG_RAX:
543 case REG_RAX:
479 return (rp->r_rax);
480 case REG_RBX:
481 return (rp->r_rbx);
482 case REG_RBP:
483 return (rp->r_rbp);
484 case REG_R10:
485 return (rp->r_r10);
486 case REG_R11:
487 return (rp->r_r11);
488 case REG_R12:
489 return (rp->r_r12);
490 case REG_R13:
491 return (rp->r_r13);
492 case REG_R14:
493 return (rp->r_r14);
494 case REG_R15:
495 return (rp->r_r15);
496 case REG_DS:
497 return (rp->r_ds);
498 case REG_ES:
499 return (rp->r_es);
500 case REG_FS:
501 return (rp->r_fs);
502 case REG_GS:
503 return (rp->r_gs);
544 return (rp->tf_eax);
504 case REG_TRAPNO:
545 case REG_TRAPNO:
505 return (rp->r_trapno);
546 return (rp->tf_trapno);
506 case REG_ERR:
547 case REG_ERR:
507 return (rp->r_err);
548 return (rp->tf_err);
508 case REG_RIP:
549 case REG_RIP:
509 return (rp->r_rip);
550 return (rp->tf_eip);
510 case REG_CS:
551 case REG_CS:
511 return (rp->r_cs);
512 case REG_SS:
513 return (rp->r_ss);
552 return (rp->tf_cs);
514 case REG_RFL:
553 case REG_RFL:
515 return (rp->r_rfl);
554 return (rp->tf_eflags);
555#if 0
516 case REG_RSP:
556 case REG_RSP:
517 return (rp->r_rsp);
557 return (rp->tf_esp);
558#endif
559 case REG_SS:
560 return (rp->tf_ss);
518 default:
519 DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
520 return (0);
521 }
561 default:
562 DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
563 return (0);
564 }
522
523#else
524 if (reg > SS) {
525 DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP);
526 return (0);
527 }
528
529 return ((&rp->r_gs)[reg]);
530#endif
531}
565}
532#endif
533
534static int
535dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size)
536{
537 ASSERT(kaddr >= kernelbase && kaddr + size >= kaddr);
538
539 if (uaddr + size >= kernelbase || uaddr + size < uaddr) {
540 DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);

--- 82 unchanged lines hidden ---
566
567static int
568dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size)
569{
570 ASSERT(kaddr >= kernelbase && kaddr + size >= kaddr);
571
572 if (uaddr + size >= kernelbase || uaddr + size < uaddr) {
573 DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);

--- 82 unchanged lines hidden ---