From owner-svn-src-head@freebsd.org Sun Jan 28 19:18:41 2018 Return-Path: Delivered-To: svn-src-head@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 D1A75EDA2D6; Sun, 28 Jan 2018 19:18:40 +0000 (UTC) (envelope-from jhibbits@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 852426AB1A; Sun, 28 Jan 2018 19:18:40 +0000 (UTC) (envelope-from jhibbits@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 67CFD1DC1F; Sun, 28 Jan 2018 19:18:40 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0SJIeJg086092; Sun, 28 Jan 2018 19:18:40 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0SJIexg086091; Sun, 28 Jan 2018 19:18:40 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201801281918.w0SJIexg086091@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Sun, 28 Jan 2018 19:18:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328516 - head/sys/powerpc/powerpc X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/powerpc X-SVN-Commit-Revision: 328516 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jan 2018 19:18:41 -0000 Author: jhibbits Date: Sun Jan 28 19:18:40 2018 New Revision: 328516 URL: https://svnweb.freebsd.org/changeset/base/328516 Log: Consolidate trap instruction checks to a single function Summary: Rather than duplicating the checks for programmatic traps all over the code, put it all in one function. This helps to remove some of the #ifdefs between AIM and Book-E. Reviewed By: nwhitehorn Differential Revision: https://reviews.freebsd.org/D14082 Modified: head/sys/powerpc/powerpc/trap.c Modified: head/sys/powerpc/powerpc/trap.c ============================================================================== --- head/sys/powerpc/powerpc/trap.c Sun Jan 28 18:38:17 2018 (r328515) +++ head/sys/powerpc/powerpc/trap.c Sun Jan 28 19:18:40 2018 (r328516) @@ -183,6 +183,16 @@ trapname(u_int vector) return ("unknown"); } +static inline bool +frame_is_trap_inst(struct trapframe *frame) +{ +#ifdef AIM + return (frame->exc == EXC_PGM && frame->srr1 & EXC_PGM_TRAP); +#else + return (frame->exc == EXC_DEBUG || frame->cpu.booke.esr & ESR_PTR); +#endif +} + void trap(struct trapframe *frame) { @@ -323,11 +333,7 @@ trap(struct trapframe *frame) case EXC_PGM: /* Identify the trap reason */ -#ifdef AIM - if (frame->srr1 & EXC_PGM_TRAP) { -#else - if (frame->cpu.booke.esr & ESR_PTR) { -#endif + if (frame_is_trap_inst(frame)) { #ifdef KDTRACE_HOOKS inst = fuword32((const void *)frame->srr0); if (inst == 0x0FFFDDDD && @@ -371,11 +377,7 @@ trap(struct trapframe *frame) switch (type) { case EXC_PGM: #ifdef KDTRACE_HOOKS -#ifdef AIM - if (frame->srr1 & EXC_PGM_TRAP) { -#else - if (frame->cpu.booke.esr & ESR_PTR) { -#endif + if (frame_is_trap_inst(frame)) { if (*(uint32_t *)frame->srr0 == EXC_DTRACE) { if (dtrace_invop_jump_addr != NULL) { dtrace_invop_jump_addr(frame); @@ -886,13 +888,7 @@ db_trap_glue(struct trapframe *frame) if (!(frame->srr1 & PSL_PR) && (frame->exc == EXC_TRC || frame->exc == EXC_RUNMODETRC -#ifdef AIM - || (frame->exc == EXC_PGM - && (frame->srr1 & EXC_PGM_TRAP)) -#else - || (frame->exc == EXC_DEBUG) - || (frame->cpu.booke.esr & ESR_PTR) -#endif + || frame_is_trap_inst(frame) || frame->exc == EXC_BPT || frame->exc == EXC_DSI)) { int type = frame->exc; @@ -900,12 +896,7 @@ db_trap_glue(struct trapframe *frame) /* Ignore DTrace traps. */ if (*(uint32_t *)frame->srr0 == EXC_DTRACE) return (0); -#ifdef AIM - if (type == EXC_PGM && (frame->srr1 & EXC_PGM_TRAP)) { -#else - if (type == EXC_DEBUG || - (frame->cpu.booke.esr & ESR_PTR)) { -#endif + if (frame_is_trap_inst(frame)) { type = T_BREAKPOINT; } return (kdb_trap(type, 0, frame));