trap.c (99900) | trap.c (101955) |
---|---|
1/*- 2 * Copyright (c) 2001, Jake Burkholder 3 * Copyright (C) 1994, David Greenman 4 * Copyright (c) 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * the University of Utah, and William Jolitz. --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 39 * from: FreeBSD: src/sys/i386/i386/trap.c,v 1.197 2001/07/19 | 1/*- 2 * Copyright (c) 2001, Jake Burkholder 3 * Copyright (C) 1994, David Greenman 4 * Copyright (c) 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * the University of Utah, and William Jolitz. --- 23 unchanged lines hidden (view full) --- 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 39 * from: FreeBSD: src/sys/i386/i386/trap.c,v 1.197 2001/07/19 |
40 * $FreeBSD: head/sys/sparc64/sparc64/trap.c 99900 2002-07-13 04:36:50Z mini $ | 40 * $FreeBSD: head/sys/sparc64/sparc64/trap.c 101955 2002-08-16 00:57:37Z jake $ |
41 */ 42 43#include "opt_ddb.h" 44#include "opt_ktr.h" 45#include "opt_ktrace.h" 46 47#include <sys/param.h> 48#include <sys/kernel.h> --- 37 unchanged lines hidden (view full) --- 86#include <machine/tsb.h> 87#include <machine/watch.h> 88 89void trap(struct trapframe *tf); 90void syscall(struct trapframe *tf); 91 92static int trap_pfault(struct thread *td, struct trapframe *tf); 93 | 41 */ 42 43#include "opt_ddb.h" 44#include "opt_ktr.h" 45#include "opt_ktrace.h" 46 47#include <sys/param.h> 48#include <sys/kernel.h> --- 37 unchanged lines hidden (view full) --- 86#include <machine/tsb.h> 87#include <machine/watch.h> 88 89void trap(struct trapframe *tf); 90void syscall(struct trapframe *tf); 91 92static int trap_pfault(struct thread *td, struct trapframe *tf); 93 |
94extern char fsbail[]; | 94extern char copy_fault[]; 95extern char copy_nofault_begin[]; 96extern char copy_nofault_end[]; |
95 | 97 |
98extern char fs_fault[]; 99extern char fs_nofault_begin[]; 100extern char fs_nofault_end[]; 101extern char fs_nofault_intr_begin[]; 102extern char fs_nofault_intr_end[]; 103 |
|
96extern char *syscallnames[]; 97 98const char *trap_msg[] = { 99 "reserved", 100 "instruction access exception", 101 "instruction access error", 102 "instruction access protection", 103 "illtrap instruction", --- 194 unchanged lines hidden (view full) --- 298 */ 299#ifdef DDB 300 case T_BREAKPOINT | T_KERNEL: 301 case T_KSTACK_FAULT | T_KERNEL: 302 if (kdb_trap(tf) != 0) 303 goto out; 304 break; 305#endif | 104extern char *syscallnames[]; 105 106const char *trap_msg[] = { 107 "reserved", 108 "instruction access exception", 109 "instruction access error", 110 "instruction access protection", 111 "illtrap instruction", --- 194 unchanged lines hidden (view full) --- 306 */ 307#ifdef DDB 308 case T_BREAKPOINT | T_KERNEL: 309 case T_KSTACK_FAULT | T_KERNEL: 310 if (kdb_trap(tf) != 0) 311 goto out; 312 break; 313#endif |
314 case T_DATA_EXCEPTION | T_KERNEL: 315 case T_MEM_ADDRESS_NOT_ALIGNED | T_KERNEL: 316 if ((tf->tf_sfsr & MMU_SFSR_FV) == 0 || 317 MMU_SFSR_GET_ASI(tf->tf_sfsr) != ASI_AIUP) 318 break; 319 if (tf->tf_tpc >= (u_long)copy_nofault_begin && 320 tf->tf_tpc <= (u_long)copy_nofault_end) { 321 tf->tf_tpc = (u_long)copy_fault; 322 tf->tf_tnpc = tf->tf_tpc + 4; 323 goto out; 324 } 325 if (tf->tf_tpc >= (u_long)fs_nofault_begin && 326 tf->tf_tpc <= (u_long)fs_nofault_end) { 327 tf->tf_tpc = (u_long)fs_fault; 328 tf->tf_tnpc = tf->tf_tpc + 4; 329 goto out; 330 } 331 break; |
|
306 case T_DATA_MISS | T_KERNEL: 307 case T_DATA_PROTECTION | T_KERNEL: 308 case T_INSTRUCTION_MISS | T_KERNEL: 309 error = trap_pfault(td, tf); 310 if (error == 0) 311 goto out; 312 break; 313#ifdef DDB --- 120 unchanged lines hidden (view full) --- 434 prot = VM_PROT_READ; 435 else 436 prot = VM_PROT_READ | VM_PROT_EXECUTE; 437 flags = VM_FAULT_NORMAL; 438 } 439 440 if (ctx != TLB_CTX_KERNEL) { 441 if ((tf->tf_tstate & TSTATE_PRIV) != 0 && | 332 case T_DATA_MISS | T_KERNEL: 333 case T_DATA_PROTECTION | T_KERNEL: 334 case T_INSTRUCTION_MISS | T_KERNEL: 335 error = trap_pfault(td, tf); 336 if (error == 0) 337 goto out; 338 break; 339#ifdef DDB --- 120 unchanged lines hidden (view full) --- 460 prot = VM_PROT_READ; 461 else 462 prot = VM_PROT_READ | VM_PROT_EXECUTE; 463 flags = VM_FAULT_NORMAL; 464 } 465 466 if (ctx != TLB_CTX_KERNEL) { 467 if ((tf->tf_tstate & TSTATE_PRIV) != 0 && |
442 (td->td_intr_nesting_level != 0 || 443 pcb->pcb_onfault == NULL || pcb->pcb_onfault == fsbail)) 444 return (-1); | 468 (tf->tf_tpc >= (u_long)fs_nofault_intr_begin && 469 tf->tf_tpc <= (u_long)fs_nofault_intr_end)) { 470 tf->tf_tpc = (u_long)fs_fault; 471 tf->tf_tnpc = tf->tf_tpc + 4; 472 return (0); 473 } |
445 446 /* 447 * This is a fault on non-kernel virtual memory. 448 */ 449 vm = p->p_vmspace; 450 451 /* 452 * Keep swapout from messing with us during this --- 9 unchanged lines hidden (view full) --- 462 /* 463 * Now the process can be swapped again. 464 */ 465 PROC_LOCK(p); 466 --p->p_lock; 467 PROC_UNLOCK(p); 468 } else { 469 /* | 474 475 /* 476 * This is a fault on non-kernel virtual memory. 477 */ 478 vm = p->p_vmspace; 479 480 /* 481 * Keep swapout from messing with us during this --- 9 unchanged lines hidden (view full) --- 491 /* 492 * Now the process can be swapped again. 493 */ 494 PROC_LOCK(p); 495 --p->p_lock; 496 PROC_UNLOCK(p); 497 } else { 498 /* |
470 * This is a fault on kernel virtual memory. Attempts to access 471 * kernel memory from user mode cause privileged action traps, 472 * not page fault. | 499 * This is a fault on kernel virtual memory. Attempts to 500 * access kernel memory from user mode cause privileged 501 * action traps, not page fault. |
473 */ 474 KASSERT(tf->tf_tstate & TSTATE_PRIV, 475 ("trap_pfault: fault on nucleus context from user mode")); 476 477 /* 478 * Don't have to worry about process locking or stacks in the 479 * kernel. 480 */ 481 rv = vm_fault(kernel_map, va, prot, VM_FAULT_NORMAL); 482 } 483 484 CTR3(KTR_TRAP, "trap_pfault: return td=%p va=%#lx rv=%d", 485 td, va, rv); 486 if (rv == KERN_SUCCESS) 487 return (0); | 502 */ 503 KASSERT(tf->tf_tstate & TSTATE_PRIV, 504 ("trap_pfault: fault on nucleus context from user mode")); 505 506 /* 507 * Don't have to worry about process locking or stacks in the 508 * kernel. 509 */ 510 rv = vm_fault(kernel_map, va, prot, VM_FAULT_NORMAL); 511 } 512 513 CTR3(KTR_TRAP, "trap_pfault: return td=%p va=%#lx rv=%d", 514 td, va, rv); 515 if (rv == KERN_SUCCESS) 516 return (0); |
488 if ((tf->tf_tstate & TSTATE_PRIV) != 0) { 489 if (td->td_intr_nesting_level == 0 && 490 pcb->pcb_onfault != NULL) { 491 tf->tf_tpc = (u_long)pcb->pcb_onfault; | 517 if (ctx != TLB_CTX_KERNEL && (tf->tf_tstate & TSTATE_PRIV) != 0) { 518 if (tf->tf_tpc >= (u_long)fs_nofault_begin && 519 tf->tf_tpc <= (u_long)fs_nofault_end) { 520 tf->tf_tpc = (u_long)fs_fault; |
492 tf->tf_tnpc = tf->tf_tpc + 4; 493 return (0); 494 } | 521 tf->tf_tnpc = tf->tf_tpc + 4; 522 return (0); 523 } |
524 if (tf->tf_tpc >= (u_long)copy_nofault_begin && 525 tf->tf_tpc <= (u_long)copy_nofault_end) { 526 tf->tf_tpc = (u_long)copy_fault; 527 tf->tf_tnpc = tf->tf_tpc + 4; 528 return (0); 529 } |
|
495 } 496 return ((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV); 497} 498 499/* Maximum number of arguments that can be passed via the out registers. */ 500#define REG_MAXARGS 6 501 502/* --- 195 unchanged lines hidden --- | 530 } 531 return ((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV); 532} 533 534/* Maximum number of arguments that can be passed via the out registers. */ 535#define REG_MAXARGS 6 536 537/* --- 195 unchanged lines hidden --- |