-/* $OpenBSD: trap.c,v 1.72 2014/04/18 11:51:16 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.73 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */
/*-
panic("ast and not user");
#endif
- atomic_add_int(&uvmexp.softs, 1);
-
- if (p->p_flag & P_OWEUPC) {
- KERNEL_LOCK();
- ADDUPROF(p);
- KERNEL_UNLOCK();
- }
-
- if (ci->ci_want_resched)
- preempt(NULL);
+ mi_ast(p, ci->ci_want_resched);
/* Do any deferred user pmap operations. */
PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));
-/* $OpenBSD: trap.c,v 1.37 2014/04/30 06:24:23 sf Exp $ */
+/* $OpenBSD: trap.c,v 1.38 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */
/*-
goto out;
case T_ASTFLT|T_USER: /* Allow process switch */
- uvmexp.softs++;
- if (p->p_flag & P_OWEUPC) {
- KERNEL_LOCK();
- ADDUPROF(p);
- KERNEL_UNLOCK();
- }
- /* Allow a forced task switch. */
- if (curcpu()->ci_want_resched)
- preempt(NULL);
+ mi_ast(p, curcpu()->ci_want_resched);
goto out;
case T_BOUND|T_USER:
-/* $OpenBSD: ast.c,v 1.10 2011/11/16 20:50:18 deraadt Exp $ */
+/* $OpenBSD: ast.c,v 1.11 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: ast.c,v 1.6 2003/10/31 16:44:34 cl Exp $ */
/*
#include <sys/signal.h>
#include <sys/signalvar.h>
#include <sys/vmmeter.h>
+#include <sys/syscall_mi.h>
#include <machine/cpu.h>
#include <machine/frame.h>
/* Interrupts were restored by exception_exit. */
uvmexp.traps++;
- uvmexp.softs++;
#ifdef DEBUG
if (p == NULL)
panic("ast: no pcb!");
#endif
- if (p->p_flag & P_OWEUPC) {
- ADDUPROF(p);
- }
-
- /* Allow a forced task switch. */
- if (want_resched)
- preempt(NULL);
-
+ mi_ast(p, want_resched);
userret(p);
}
-/* $OpenBSD: trap.c,v 1.131 2014/05/08 21:32:45 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.132 2014/05/10 05:33:00 guenther Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
{
if (p->p_md.md_astpending) {
p->p_md.md_astpending = 0;
- uvmexp.softs++;
- if (p->p_flag & P_OWEUPC) {
- KERNEL_LOCK();
- ADDUPROF(p);
- KERNEL_UNLOCK();
- }
- if (curcpu()->ci_want_resched)
- preempt(NULL);
+ mi_ast(p, curcpu()->ci_want_resched);
}
}
-/* $OpenBSD: trap.c,v 1.36 2014/04/18 11:51:16 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.37 2014/05/10 05:33:00 guenther Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
{
if (astpending) {
astpending = 0;
- uvmexp.softs++;
- if (p->p_flag & P_OWEUPC) {
- ADDUPROF(p);
- }
- if (want_resched)
- preempt(NULL);
+ mi_ast(p, want_resched);
}
}
-/* $OpenBSD: trap.c,v 1.114 2014/04/18 11:51:17 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.115 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
goto out;
case T_ASTFLT|T_USER: /* Allow process switch */
- uvmexp.softs++;
- if (p->p_flag & P_OWEUPC) {
- KERNEL_LOCK();
- ADDUPROF(p);
- KERNEL_UNLOCK();
- }
- if (want_resched)
- preempt(NULL);
+ mi_ast(p, want_resched);
goto out;
case T_DNA|T_USER: {
-/* $OpenBSD: trap.c,v 1.91 2014/05/08 22:17:33 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.92 2014/05/10 05:33:00 guenther Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
struct cpu_info *ci = curcpu();
struct proc *p = ci->ci_curproc;
- uvmexp.softs++;
p->p_md.md_astpending = 0;
- if (p->p_flag & P_OWEUPC) {
- KERNEL_LOCK();
- ADDUPROF(p);
- KERNEL_UNLOCK();
- }
- if (ci->ci_want_resched)
- preempt(NULL);
+ mi_ast(p, ci->ci_want_resched);
userret(p);
}
-/* $OpenBSD: trap.c,v 1.93 2014/04/18 11:51:17 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.94 2014/05/10 05:33:00 guenther Exp $ */
/*
* Copyright (c) 1988 University of Utah.
struct cpu_info *ci = curcpu();
struct proc *p = ci->ci_curproc;
- atomic_add_int(&uvmexp.softs, 1);
-
p->p_md.md_astpending = 0;
- if (p->p_flag & P_OWEUPC) {
- KERNEL_LOCK();
- ADDUPROF(p);
- KERNEL_UNLOCK();
- }
- if (ci->ci_want_resched)
- preempt(NULL);
+ mi_ast(p, ci->ci_want_resched);
userret(p);
}
-/* $OpenBSD: trap.c,v 1.97 2014/05/09 18:16:15 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.98 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
break;
case EXC_AST|EXC_USER:
- uvmexp.softs++;
p->p_md.md_astpending = 0; /* we are about to do it */
- if (p->p_flag & P_OWEUPC) {
- KERNEL_LOCK();
- ADDUPROF(p);
- KERNEL_UNLOCK();
- }
- if (ci->ci_want_resched)
- preempt(NULL);
+ mi_ast(p, ci->ci_want_resched);
break;
}
-/* $OpenBSD: trap.c,v 1.26 2014/05/08 21:43:04 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.27 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: exception.c,v 1.32 2006/09/04 23:57:52 uwe Exp $ */
/* $NetBSD: syscall.c,v 1.6 2006/03/07 07:21:50 thorpej Exp $ */
while (p->p_md.md_astpending) {
p->p_md.md_astpending = 0;
- uvmexp.softs++;
-
refreshcreds(p);
- if (p->p_flag & P_OWEUPC) {
- ADDUPROF(p);
- }
-
- if (want_resched) {
- /* We are being preempted. */
- preempt(NULL);
- }
-
+ mi_ast(p, want_resched);
userret(p);
}
}
-/* $OpenBSD: trap.c,v 1.19 2014/04/18 11:51:17 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.20 2014/05/10 05:33:00 guenther Exp $ */
/* OpenBSD: trap.c,v 1.42 2004/12/06 20:12:25 miod Exp */
/*
case T_AST:
want_ast = 0;
- if (p->p_flag & P_OWEUPC) {
- ADDUPROF(p);
- }
- if (want_resched)
- preempt(NULL);
+ mi_ast(p, want_resched);
break;
case T_ILLINST:
-/* $OpenBSD: trap.c,v 1.66 2014/04/30 04:20:31 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.67 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: trap.c,v 1.58 1997/09/12 08:55:01 pk Exp $ */
/*
case T_AST:
want_ast = 0;
- if (p->p_flag & P_OWEUPC) {
- ADDUPROF(p);
- }
- if (want_resched)
- preempt(NULL);
+ mi_ast(p, want_resched);
break;
case T_ILLINST:
-/* $OpenBSD: trap.c,v 1.81 2014/04/18 11:51:17 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.82 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */
/*
case T_AST:
p->p_md.md_astpending = 0;
- if (p->p_flag & P_OWEUPC) {
- KERNEL_LOCK();
- ADDUPROF(p);
- KERNEL_UNLOCK();
- }
- if (curcpu()->ci_want_resched)
- preempt(NULL);
+ mi_ast(p, curcpu()->ci_want_resched);
break;
case T_RWRET:
-/* $OpenBSD: trap.c,v 1.51 2014/04/18 11:51:17 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.52 2014/05/10 05:33:00 guenther Exp $ */
/* $NetBSD: trap.c,v 1.47 1999/08/21 19:26:20 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
case T_ASTFLT|T_USER:
mtpr(AST_NO,PR_ASTLVL);
trapsig = 0;
- if (p->p_flag & P_OWEUPC) {
- ADDUPROF(p);
- }
- if (want_resched)
- preempt(NULL);
+ mi_ast(p, want_resched);
break;
#ifdef DDB
-/* $OpenBSD: syscall_mi.h,v 1.3 2014/04/18 11:51:17 guenther Exp $ */
+/* $OpenBSD: syscall_mi.h,v 1.4 2014/05/10 05:33:00 guenther Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
}
#endif
}
+
+/*
+ * Do the specific processing necessary for an AST
+ */
+static void
+mi_ast(struct proc *p, int resched)
+{
+ uvmexp.softs++;
+
+ if (p->p_flag & P_OWEUPC) {
+ KERNEL_LOCK();
+ ADDUPROF(p);
+ KERNEL_UNLOCK();
+ }
+ if (resched)
+ preempt(NULL);
+
+ /*
+ * XXX could move call to userret() here, but
+ * hppa calls ast() in syscall return and sh calls
+ * it after userret()
+ */
+}