subr_trap.c (f05a9476764c08d84216e7848fb4a5b3d0c3645a) subr_trap.c (699d648aabcebb491ac2ada593f6f97281e5903a)
1/*-
2 * Copyright (C) 1994, David Greenman
3 * Copyright (c) 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 2007 The FreeBSD Foundation
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the University of Utah, and William Jolitz.

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

41 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91
42 */
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD$");
46
47#include "opt_ktrace.h"
48#include "opt_kdtrace.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 * Copyright (c) 2007 The FreeBSD Foundation
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the University of Utah, and William Jolitz.

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

41 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91
42 */
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD$");
46
47#include "opt_ktrace.h"
48#include "opt_kdtrace.h"
49#ifdef __i386__
50#include "opt_npx.h"
51#endif
52#include "opt_sched.h"
53
54#include <sys/param.h>
55#include <sys/bus.h>
56#include <sys/kernel.h>
57#include <sys/lock.h>
58#include <sys/mutex.h>
59#include <sys/pmckern.h>

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

70#include <sys/vmmeter.h>
71#ifdef KTRACE
72#include <sys/uio.h>
73#include <sys/ktrace.h>
74#endif
75#include <security/audit/audit.h>
76
77#include <machine/cpu.h>
49#include "opt_sched.h"
50
51#include <sys/param.h>
52#include <sys/bus.h>
53#include <sys/kernel.h>
54#include <sys/lock.h>
55#include <sys/mutex.h>
56#include <sys/pmckern.h>

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

67#include <sys/vmmeter.h>
68#ifdef KTRACE
69#include <sys/uio.h>
70#include <sys/ktrace.h>
71#endif
72#include <security/audit/audit.h>
73
74#include <machine/cpu.h>
78#include <machine/pcb.h>
79
80#ifdef XEN
81#include <vm/vm.h>
82#include <vm/vm_param.h>
83#include <vm/pmap.h>
84#endif
85
86#include <security/mac/mac_framework.h>

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

142 */
143void
144ast(struct trapframe *framep)
145{
146 struct thread *td;
147 struct proc *p;
148 int flags;
149 int sig;
75
76#ifdef XEN
77#include <vm/vm.h>
78#include <vm/vm_param.h>
79#include <vm/pmap.h>
80#endif
81
82#include <security/mac/mac_framework.h>

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

138 */
139void
140ast(struct trapframe *framep)
141{
142 struct thread *td;
143 struct proc *p;
144 int flags;
145 int sig;
150#if defined(DEV_NPX) && !defined(SMP)
151 int ucode;
152 ksiginfo_t ksi;
153#endif
154
155 td = curthread;
156 p = td->td_proc;
157
158 CTR3(KTR_SYSC, "ast: thread %p (pid %d, %s)", td, p->p_pid,
159 p->p_comm);
160 KASSERT(TRAPF_USERMODE(framep), ("ast in kernel mode"));
161 WITNESS_WARN(WARN_PANIC, NULL, "Returning to user mode");

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

185 td->td_profil_ticks = 0;
186 td->td_pflags &= ~TDP_OWEUPC;
187 }
188 if (flags & TDF_ALRMPEND) {
189 PROC_LOCK(p);
190 psignal(p, SIGVTALRM);
191 PROC_UNLOCK(p);
192 }
146
147 td = curthread;
148 p = td->td_proc;
149
150 CTR3(KTR_SYSC, "ast: thread %p (pid %d, %s)", td, p->p_pid,
151 p->p_comm);
152 KASSERT(TRAPF_USERMODE(framep), ("ast in kernel mode"));
153 WITNESS_WARN(WARN_PANIC, NULL, "Returning to user mode");

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

177 td->td_profil_ticks = 0;
178 td->td_pflags &= ~TDP_OWEUPC;
179 }
180 if (flags & TDF_ALRMPEND) {
181 PROC_LOCK(p);
182 psignal(p, SIGVTALRM);
183 PROC_UNLOCK(p);
184 }
193#if defined(DEV_NPX) && !defined(SMP)
194 if (PCPU_GET(curpcb)->pcb_flags & PCB_NPXTRAP) {
195 atomic_clear_int(&PCPU_GET(curpcb)->pcb_flags,
196 PCB_NPXTRAP);
197 ucode = npxtrap();
198 if (ucode != -1) {
199 ksiginfo_init_trap(&ksi);
200 ksi.ksi_signo = SIGFPE;
201 ksi.ksi_code = ucode;
202 trapsignal(td, &ksi);
203 }
204 }
205#endif
206 if (flags & TDF_PROFPEND) {
207 PROC_LOCK(p);
208 psignal(p, SIGPROF);
209 PROC_UNLOCK(p);
210 }
211#ifdef MAC
212 if (flags & TDF_MACPEND)
213 mac_thread_userret(td);

--- 204 unchanged lines hidden ---
185 if (flags & TDF_PROFPEND) {
186 PROC_LOCK(p);
187 psignal(p, SIGPROF);
188 PROC_UNLOCK(p);
189 }
190#ifdef MAC
191 if (flags & TDF_MACPEND)
192 mac_thread_userret(td);

--- 204 unchanged lines hidden ---