trap.c (208453) | trap.c (208833) |
---|---|
1/*- 2 * Copyright (C) 1994, David Greenman 3 * Copyright (c) 1990, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the University of Utah, and William Jolitz. 8 * --- 24 unchanged lines hidden (view full) --- 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 38 */ 39 40#include <sys/cdefs.h> | 1/*- 2 * Copyright (C) 1994, David Greenman 3 * Copyright (c) 1990, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the University of Utah, and William Jolitz. 8 * --- 24 unchanged lines hidden (view full) --- 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 38 */ 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/sys/amd64/amd64/trap.c 208453 2010-05-23 18:32:02Z kib $"); | 41__FBSDID("$FreeBSD: head/sys/amd64/amd64/trap.c 208833 2010-06-05 15:59:59Z kib $"); |
42 43/* 44 * AMD64 Trap and System call handling 45 */ 46 47#include "opt_clock.h" 48#include "opt_cpu.h" 49#include "opt_hwpmc_hooks.h" --- 370 unchanged lines hidden (view full) --- 420 421 case T_BOUND: /* bounds check fault */ 422 ucode = FPE_FLTSUB; 423 i = SIGFPE; 424 break; 425 426 case T_DNA: 427 /* transparent fault (due to context switch "late") */ | 42 43/* 44 * AMD64 Trap and System call handling 45 */ 46 47#include "opt_clock.h" 48#include "opt_cpu.h" 49#include "opt_hwpmc_hooks.h" --- 370 unchanged lines hidden (view full) --- 420 421 case T_BOUND: /* bounds check fault */ 422 ucode = FPE_FLTSUB; 423 i = SIGFPE; 424 break; 425 426 case T_DNA: 427 /* transparent fault (due to context switch "late") */ |
428 KASSERT(PCB_USER_FPU(td->td_pcb), 429 ("kernel FPU ctx has leaked")); |
|
428 fpudna(); 429 goto userout; 430 431 case T_FPOPFLT: /* FPU operand fetch fault */ 432 ucode = ILL_COPROC; 433 i = SIGILL; 434 break; 435 --- 8 unchanged lines hidden (view full) --- 444 KASSERT(cold || td->td_ucred != NULL, 445 ("kernel trap doesn't have ucred")); 446 switch (type) { 447 case T_PAGEFLT: /* page fault */ 448 (void) trap_pfault(frame, FALSE); 449 goto out; 450 451 case T_DNA: | 430 fpudna(); 431 goto userout; 432 433 case T_FPOPFLT: /* FPU operand fetch fault */ 434 ucode = ILL_COPROC; 435 i = SIGILL; 436 break; 437 --- 8 unchanged lines hidden (view full) --- 446 KASSERT(cold || td->td_ucred != NULL, 447 ("kernel trap doesn't have ucred")); 448 switch (type) { 449 case T_PAGEFLT: /* page fault */ 450 (void) trap_pfault(frame, FALSE); 451 goto out; 452 453 case T_DNA: |
454 KASSERT(!PCB_USER_FPU(td->td_pcb), 455 ("Unregistered use of FPU in kernel")); 456 fpudna(); 457 goto out; 458 459 case T_ARITHTRAP: /* arithmetic trap */ 460 case T_XMMFLT: /* SIMD floating-point exception */ 461 case T_FPOPFLT: /* FPU operand fetch fault */ |
|
452 /* | 462 /* |
453 * The kernel is apparently using fpu for copying. 454 * XXX this should be fatal unless the kernel has 455 * registered such use. | 463 * XXXKIB for now disable any FPU traps in kernel 464 * handler registration seems to be overkill |
456 */ | 465 */ |
457 printf("fpudna in kernel mode!\n"); 458#ifdef KDB 459 kdb_backtrace(); 460#endif 461 fpudna(); | 466 trap_fatal(frame, 0); |
462 goto out; 463 464 case T_STKFLT: /* stack fault */ 465 break; 466 467 case T_PROTFLT: /* general protection fault */ 468 case T_SEGNPFLT: /* segment not present fault */ 469 if (td->td_intr_nesting_level != 0) --- 128 unchanged lines hidden (view full) --- 598 ksi.ksi_code = ucode; 599 ksi.ksi_trapno = type; 600 ksi.ksi_addr = (void *)addr; 601 trapsignal(td, &ksi); 602 603user: 604 userret(td, frame); 605 mtx_assert(&Giant, MA_NOTOWNED); | 467 goto out; 468 469 case T_STKFLT: /* stack fault */ 470 break; 471 472 case T_PROTFLT: /* general protection fault */ 473 case T_SEGNPFLT: /* segment not present fault */ 474 if (td->td_intr_nesting_level != 0) --- 128 unchanged lines hidden (view full) --- 603 ksi.ksi_code = ucode; 604 ksi.ksi_trapno = type; 605 ksi.ksi_addr = (void *)addr; 606 trapsignal(td, &ksi); 607 608user: 609 userret(td, frame); 610 mtx_assert(&Giant, MA_NOTOWNED); |
611 KASSERT(PCB_USER_FPU(td->td_pcb), 612 ("Return from trap with kernel FPU ctx leaked")); |
|
606userout: 607out: 608 return; 609} 610 611static int 612trap_pfault(frame, usermode) 613 struct trapframe *frame; --- 272 unchanged lines hidden (view full) --- 886 frame->tf_rflags &= ~PSL_T; 887 ksiginfo_init_trap(&ksi); 888 ksi.ksi_signo = SIGTRAP; 889 ksi.ksi_code = TRAP_TRACE; 890 ksi.ksi_addr = (void *)frame->tf_rip; 891 trapsignal(td, &ksi); 892 } 893 | 613userout: 614out: 615 return; 616} 617 618static int 619trap_pfault(frame, usermode) 620 struct trapframe *frame; --- 272 unchanged lines hidden (view full) --- 893 frame->tf_rflags &= ~PSL_T; 894 ksiginfo_init_trap(&ksi); 895 ksi.ksi_signo = SIGTRAP; 896 ksi.ksi_code = TRAP_TRACE; 897 ksi.ksi_addr = (void *)frame->tf_rip; 898 trapsignal(td, &ksi); 899 } 900 |
901 KASSERT(PCB_USER_FPU(td->td_pcb), 902 ("System call %s returing with kernel FPU ctx leaked", 903 syscallname(td->td_proc, sa.code))); 904 KASSERT(td->td_pcb->pcb_save == &td->td_pcb->pcb_user_save, 905 ("System call %s returning with mangled pcb_save", 906 syscallname(td->td_proc, sa.code))); 907 |
|
894 syscallret(td, error, &sa); 895} | 908 syscallret(td, error, &sa); 909} |