Module Name: src
Committed By: ad
Date: Fri Nov 29 18:27:33 UTC 2019
Modified Files:
src/sys/arch/hppa/hppa: trap.c
src/sys/arch/sh3/include: userret.h
src/sys/arch/sh3/sh3: exception.c
src/sys/arch/sparc/include: userret.h
src/sys/arch/usermode/usermode: trap.c
Log Message:
PR port-sparc/54718 (sparc install hangs since recent scheduler changes)
- userret() must be called every time we return to user, it's not optional.
- If clearing the AST with interrupts off, you must loop over userret().
To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/arch/hppa/hppa/trap.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sh3/include/userret.h
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/sh3/sh3/exception.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/userret.h
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/usermode/usermode/trap.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/hppa/hppa/trap.c
diff -u src/sys/arch/hppa/hppa/trap.c:1.112 src/sys/arch/hppa/hppa/trap.c:1.113
--- src/sys/arch/hppa/hppa/trap.c:1.112 Thu Nov 21 19:24:00 2019
+++ src/sys/arch/hppa/hppa/trap.c Fri Nov 29 18:27:32 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.112 2019/11/21 19:24:00 ad Exp $ */
+/* $NetBSD: trap.c,v 1.113 2019/11/29 18:27:32 ad Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.112 2019/11/21 19:24:00 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.113 2019/11/29 18:27:32 ad Exp $");
/* #define INTRDEBUG */
/* #define TRAPDEBUG */
@@ -202,10 +202,11 @@ userret(struct lwp *l, register_t pc, u_
{
struct proc *p = l->l_proc;
- l->l_md.md_astpending = 0;
- //curcpu()->ci_data.cpu_nast++;
-
- mi_userret(l);
+ do {
+ l->l_md.md_astpending = 0;
+ //curcpu()->ci_data.cpu_nast++;
+ mi_userret(l);
+ } while (l->l_md.md_astpending);
/*
* If profiling, charge recent system time to the trapped pc.
Index: src/sys/arch/sh3/include/userret.h
diff -u src/sys/arch/sh3/include/userret.h:1.14 src/sys/arch/sh3/include/userret.h:1.15
--- src/sys/arch/sh3/include/userret.h:1.14 Wed Nov 2 00:11:59 2016
+++ src/sys/arch/sh3/include/userret.h Fri Nov 29 18:27:32 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: userret.h,v 1.14 2016/11/02 00:11:59 pgoyette Exp $ */
+/* $NetBSD: userret.h,v 1.15 2019/11/29 18:27:32 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -52,7 +52,16 @@ userret(struct lwp *l)
{
/* Invoke MI userret code */
- mi_userret(l);
+ do {
+ //curcpu()->ci_data.cpu_nast++;
+ l->l_md.md_astpending = 0;
+ mi_userret(l);
+ } while (l->l_md.md_astpending);
+
+ if (l->l_pflag & LP_OWEUPC) {
+ l->l_pflag &= ~LP_OWEUPC;
+ ADDUPROF(l);
+ }
#ifdef PTRACE_HOOKS
/* Check if lwp is being PT_STEP'ed */
Index: src/sys/arch/sh3/sh3/exception.c
diff -u src/sys/arch/sh3/sh3/exception.c:1.68 src/sys/arch/sh3/sh3/exception.c:1.69
--- src/sys/arch/sh3/sh3/exception.c:1.68 Thu Nov 21 19:24:01 2019
+++ src/sys/arch/sh3/sh3/exception.c Fri Nov 29 18:27:33 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: exception.c,v 1.68 2019/11/21 19:24:01 ad Exp $ */
+/* $NetBSD: exception.c,v 1.69 2019/11/29 18:27:33 ad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.68 2019/11/21 19:24:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.69 2019/11/29 18:27:33 ad Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -471,15 +471,5 @@ ast(struct lwp *l, struct trapframe *tf)
KDASSERT(l != NULL);
KDASSERT(l->l_md.md_regs == tf);
- while (l->l_md.md_astpending) {
- //curcpu()->ci_data.cpu_nast++;
- l->l_md.md_astpending = 0;
-
- if (l->l_pflag & LP_OWEUPC) {
- l->l_pflag &= ~LP_OWEUPC;
- ADDUPROF(l);
- }
-
- userret(l);
- }
+ userret(l);
}
Index: src/sys/arch/sparc/include/userret.h
diff -u src/sys/arch/sparc/include/userret.h:1.10 src/sys/arch/sparc/include/userret.h:1.11
--- src/sys/arch/sparc/include/userret.h:1.10 Sat Nov 23 16:50:39 2019
+++ src/sys/arch/sparc/include/userret.h Fri Nov 29 18:27:33 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: userret.h,v 1.10 2019/11/23 16:50:39 ad Exp $ */
+/* $NetBSD: userret.h,v 1.11 2019/11/29 18:27:33 ad Exp $ */
/*
* Copyright (c) 1996
@@ -63,13 +63,14 @@ userret(struct lwp *l, int pc, u_quad_t
{
struct proc *p = l->l_proc;
- while (cpuinfo.ci_want_ast) {
+ do {
cpuinfo.ci_want_ast = 0;
mi_userret(l);
- if (l->l_pflag & LP_OWEUPC) {
- l->l_pflag &= ~LP_OWEUPC;
- ADDUPROF(l);
- }
+ } while (cpuinfo.ci_want_ast);
+
+ if (l->l_pflag & LP_OWEUPC) {
+ l->l_pflag &= ~LP_OWEUPC;
+ ADDUPROF(l);
}
/*
Index: src/sys/arch/usermode/usermode/trap.c
diff -u src/sys/arch/usermode/usermode/trap.c:1.71 src/sys/arch/usermode/usermode/trap.c:1.72
--- src/sys/arch/usermode/usermode/trap.c:1.71 Thu Nov 21 19:24:02 2019
+++ src/sys/arch/usermode/usermode/trap.c Fri Nov 29 18:27:33 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.71 2019/11/21 19:24:02 ad Exp $ */
+/* $NetBSD: trap.c,v 1.72 2019/11/29 18:27:33 ad Exp $ */
/*-
* Copyright (c) 2011 Reinoud Zandijk <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.71 2019/11/21 19:24:02 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.72 2019/11/29 18:27:33 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -188,12 +188,13 @@ ast(struct lwp *l)
{
struct pcb *pcb;
- if (!astpending)
- return;
-
- astpending = 0;
curcpu()->ci_data.cpu_ntrap++;
+ do {
+ astpending = 0;
+ mi_userret(l);
+ } while (astpending);
+
#if 0
/* profiling */
if (l->l_pflag & LP_OWEUPC) {
@@ -204,7 +205,6 @@ ast(struct lwp *l)
KASSERT(l == curlwp); KASSERT(l);
pcb = lwp_getpcb(l); KASSERT(pcb);
- mi_userret(l);
}