diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2014-05-10 05:33:01 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2014-05-10 05:33:01 +0000 |
commit | b12870a5d75b3e82406ba541feec0aeaf9f19a2e (patch) | |
tree | cdfdb3d18e1b9828c390564327c4d4374a3351dd /sys | |
parent | dfeb688a946a2b27fde19e82f8a8e80020a07e6c (diff) |
Factor out the common ast bits into mi_ast()
ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/alpha/alpha/trap.c | 13 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 12 | ||||
-rw-r--r-- | sys/arch/arm/arm/ast.c | 13 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/trap.c | 11 | ||||
-rw-r--r-- | sys/arch/hppa64/hppa64/trap.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/i386/trap.c | 11 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/trap.c | 11 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/trap.c | 12 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/trap.c | 11 | ||||
-rw-r--r-- | sys/arch/sh/sh/trap.c | 14 | ||||
-rw-r--r-- | sys/arch/solbourne/solbourne/trap.c | 8 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/trap.c | 8 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/trap.c | 10 | ||||
-rw-r--r-- | sys/arch/vax/vax/trap.c | 8 | ||||
-rw-r--r-- | sys/sys/syscall_mi.h | 25 |
15 files changed, 53 insertions, 123 deletions
diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c index 45c44d03cd1..2d7d82b6358 100644 --- a/sys/arch/alpha/alpha/trap.c +++ b/sys/arch/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -720,16 +720,7 @@ ast(framep) 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)); diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 4ef833ba31e..0ce734d6624 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -281,15 +281,7 @@ copyfault: 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: diff --git a/sys/arch/arm/arm/ast.c b/sys/arch/arm/arm/ast.c index 7fb82e5850d..ea410eca92b 100644 --- a/sys/arch/arm/arm/ast.c +++ b/sys/arch/arm/arm/ast.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -50,6 +50,7 @@ #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> @@ -81,7 +82,6 @@ ast(struct trapframe *tf) /* Interrupts were restored by exception_exit. */ uvmexp.traps++; - uvmexp.softs++; #ifdef DEBUG if (p == NULL) @@ -90,14 +90,7 @@ ast(struct trapframe *tf) 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); } diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c index 1b5e34c678a..130c9f1f350 100644 --- a/sys/arch/hppa/hppa/trap.c +++ b/sys/arch/hppa/hppa/trap.c @@ -1,4 +1,4 @@ -/* $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 @@ -139,14 +139,7 @@ ast(struct proc *p) { 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); } } diff --git a/sys/arch/hppa64/hppa64/trap.c b/sys/arch/hppa64/hppa64/trap.c index 8310c42db1b..86e6a7e4e31 100644 --- a/sys/arch/hppa64/hppa64/trap.c +++ b/sys/arch/hppa64/hppa64/trap.c @@ -1,4 +1,4 @@ -/* $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 @@ -132,12 +132,7 @@ ast(struct proc *p) { if (astpending) { astpending = 0; - uvmexp.softs++; - if (p->p_flag & P_OWEUPC) { - ADDUPROF(p); - } - if (want_resched) - preempt(NULL); + mi_ast(p, want_resched); } } diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index 31d4c77109c..9ec543f41df 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $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 $ */ /*- @@ -334,14 +334,7 @@ trap(struct trapframe *frame) 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: { diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index f73b801db0d..5426eea703a 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $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. @@ -205,16 +205,9 @@ ast(struct trapframe *frame) 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); } diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index 5576f84d545..d24a98afe3d 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $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. @@ -148,17 +148,9 @@ ast() 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); } diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c index 8725a286db1..7bd6d13ad41 100644 --- a/sys/arch/powerpc/powerpc/trap.c +++ b/sys/arch/powerpc/powerpc/trap.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -619,15 +619,8 @@ for (i = 0; i < errnum; i++) { 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; } diff --git a/sys/arch/sh/sh/trap.c b/sys/arch/sh/sh/trap.c index 56c9828686c..10035c940b5 100644 --- a/sys/arch/sh/sh/trap.c +++ b/sys/arch/sh/sh/trap.c @@ -1,4 +1,4 @@ -/* $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 $ */ @@ -479,18 +479,8 @@ ast(struct proc *p, struct trapframe *tf) 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); } } diff --git a/sys/arch/solbourne/solbourne/trap.c b/sys/arch/solbourne/solbourne/trap.c index dbd30071636..76ac5f739a4 100644 --- a/sys/arch/solbourne/solbourne/trap.c +++ b/sys/arch/solbourne/solbourne/trap.c @@ -1,4 +1,4 @@ -/* $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 */ /* @@ -308,11 +308,7 @@ trap(type, psr, pc, tf) 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: diff --git a/sys/arch/sparc/sparc/trap.c b/sys/arch/sparc/sparc/trap.c index 9ef25319c59..5f15e8392e8 100644 --- a/sys/arch/sparc/sparc/trap.c +++ b/sys/arch/sparc/sparc/trap.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -301,11 +301,7 @@ trap(type, psr, pc, tf) 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: diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index d1605f05207..1be854801b4 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -452,13 +452,7 @@ dopanic: 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: diff --git a/sys/arch/vax/vax/trap.c b/sys/arch/vax/vax/trap.c index bcd9a5a609f..842234fa674 100644 --- a/sys/arch/vax/vax/trap.c +++ b/sys/arch/vax/vax/trap.c @@ -1,4 +1,4 @@ -/* $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. @@ -253,11 +253,7 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n", 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 diff --git a/sys/sys/syscall_mi.h b/sys/sys/syscall_mi.h index 20293f025db..d8c52eaa1e0 100644 --- a/sys/sys/syscall_mi.h +++ b/sys/sys/syscall_mi.h @@ -1,4 +1,4 @@ -/* $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 @@ -142,3 +142,26 @@ mi_child_return(struct proc *p) } #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() + */ +} |