From owner-svn-src-stable@freebsd.org Fri Jun 22 10:49:22 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A05661016E45; Fri, 22 Jun 2018 10:49:22 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DD0F8B208; Fri, 22 Jun 2018 10:49:22 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2B5391FA49; Fri, 22 Jun 2018 10:49:22 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5MAnMjT075245; Fri, 22 Jun 2018 10:49:22 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5MAnLOT075240; Fri, 22 Jun 2018 10:49:21 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201806221049.w5MAnLOT075240@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 22 Jun 2018 10:49:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335556 - in stable/11/sys: arm/arm arm64/arm64 mips/mips X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/11/sys: arm/arm arm64/arm64 mips/mips X-SVN-Commit-Revision: 335556 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2018 10:49:22 -0000 Author: avg Date: Fri Jun 22 10:49:21 2018 New Revision: 335556 URL: https://svnweb.freebsd.org/changeset/base/335556 Log: MFC r333667: followup to r332730/r332752: set kdb_why to "trap" for fatal traps This change updates arm, arm64 and mips achitectures. Additionally, it removes redundant checks for kdb_active where it already results in kdb_reenter() and adds kdb_reenter() calls where they were missing. Some architectures check the return value of kdb_trap(), but some don't. I haven't changed any of that. Some trap handling routines have a return code. I am not sure if I provided correct ones for returns after kdb_reenter(). kdb_reenter should never return unless kdb_jmpbufp is NULL for some reason. Modified: stable/11/sys/arm/arm/trap-v4.c stable/11/sys/arm/arm/trap-v6.c stable/11/sys/arm64/arm64/trap.c stable/11/sys/mips/mips/trap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/trap-v4.c ============================================================================== --- stable/11/sys/arm/arm/trap-v4.c Fri Jun 22 10:44:33 2018 (r335555) +++ stable/11/sys/arm/arm/trap-v4.c Fri Jun 22 10:49:21 2018 (r335556) @@ -404,7 +404,16 @@ dab_fatal(struct trapframe *tf, u_int fsr, u_int far, struct ksig *ksig) { const char *mode; +#ifdef KDB + bool handled; +#endif +#ifdef KDB + if (kdb_active) { + kdb_reenter(); + return (0); + } +#endif #ifdef KDTRACE_HOOKS if (!TRAP_USERMODE(tf)) { if (dtrace_trap_func != NULL && (*dtrace_trap_func)(tf, far & FAULT_TYPE_MASK)) @@ -447,9 +456,13 @@ dab_fatal(struct trapframe *tf, u_int fsr, u_int far, printf(", pc =%08x\n\n", tf->tf_pc); #ifdef KDB - if (debugger_on_panic || kdb_active) - if (kdb_trap(fsr, 0, tf)) + if (debugger_on_panic) { + kdb_why = KDB_WHY_TRAP; + handled = kdb_trap(fsr, 0, tf); + kdb_why = KDB_WHY_UNSET; + if (handled) return (0); + } #endif panic("Fatal abort"); /*NOTREACHED*/ Modified: stable/11/sys/arm/arm/trap-v6.c ============================================================================== --- stable/11/sys/arm/arm/trap-v6.c Fri Jun 22 10:44:33 2018 (r335555) +++ stable/11/sys/arm/arm/trap-v6.c Fri Jun 22 10:49:21 2018 (r335556) @@ -599,8 +599,11 @@ abort_fatal(struct trapframe *tf, u_int idx, u_int fsr printf(", pc =%08x\n\n", tf->tf_pc); #ifdef KDB - if (debugger_on_panic || kdb_active) + if (debugger_on_panic) { + kdb_why = KDB_WHY_TRAP; kdb_trap(fsr, 0, tf); + kdb_why = KDB_WHY_UNSET; + } #endif panic("Fatal abort"); /*NOTREACHED*/ Modified: stable/11/sys/arm64/arm64/trap.c ============================================================================== --- stable/11/sys/arm64/arm64/trap.c Fri Jun 22 10:44:33 2018 (r335555) +++ stable/11/sys/arm64/arm64/trap.c Fri Jun 22 10:49:21 2018 (r335556) @@ -155,6 +155,9 @@ data_abort(struct thread *td, struct trapframe *frame, vm_prot_t ftype; vm_offset_t va; int error, sig, ucode; +#ifdef KDB + bool handled; +#endif /* * According to the ARMv8-A rev. A.g, B2.10.5 "Load-Exclusive @@ -232,9 +235,14 @@ data_abort(struct thread *td, struct trapframe *frame, printf(" esr: %.8lx\n", esr); #ifdef KDB - if (debugger_on_panic || kdb_active) - if (kdb_trap(ESR_ELx_EXCEPTION(esr), 0, frame)) + if (debugger_on_panic) { + kdb_why = KDB_WHY_TRAP; + handled = kdb_trap(ESR_ELx_EXCEPTION(esr), 0, + frame); + kdb_why = KDB_WHY_UNSET; + if (handled) return; + } #endif panic("vm_fault failed: %lx", frame->tf_elr); } Modified: stable/11/sys/mips/mips/trap.c ============================================================================== --- stable/11/sys/mips/mips/trap.c Fri Jun 22 10:44:33 2018 (r335555) +++ stable/11/sys/mips/mips/trap.c Fri Jun 22 10:49:21 2018 (r335556) @@ -533,7 +533,12 @@ trap(struct trapframe *trapframe) register_t *frame_regs; trapdebug_enter(trapframe, 0); - +#ifdef KDB + if (kdb_active) { + kdb_reenter(); + return (0); + } +#endif type = (trapframe->cause & MIPS_CR_EXC_CODE) >> MIPS_CR_EXC_CODE_SHIFT; if (TRAPF_USERMODE(trapframe)) { type |= T_USER; @@ -1104,8 +1109,10 @@ err: #endif #ifdef KDB - if (debugger_on_panic || kdb_active) { + if (debugger_on_panic) { + kdb_why = KDB_WHY_TRAP; kdb_trap(type, 0, trapframe); + kdb_why = KDB_WHY_UNSET; } #endif panic("trap");