From owner-svn-src-all@FreeBSD.ORG Thu Mar 19 13:17:19 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3E9B106567E; Thu, 19 Mar 2009 13:17:19 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 877D88FC26; Thu, 19 Mar 2009 13:17:19 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2JDHJvB062520; Thu, 19 Mar 2009 13:17:19 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2JDHJvv062517; Thu, 19 Mar 2009 13:17:19 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200903191317.n2JDHJvv062517@svn.freebsd.org> From: Marius Strobl Date: Thu, 19 Mar 2009 13:17:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190041 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/include sparc64/sparc64 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2009 13:17:23 -0000 Author: marius Date: Thu Mar 19 13:17:19 2009 New Revision: 190041 URL: http://svn.freebsd.org/changeset/base/190041 Log: MFC: r182773 Use the PROM provided SUNW,set-trap-table to take over the trap table. This is required in order to set obp-control-relinquished within the PROM, allowing to safely read the OFW translations node. Without this, f.e. a `ofwdump -ap` triggers a fatal reset error or worse things on machines based on USIII and beyond. In theory this should allow to remove touching %tba in cpu_setregs(), in practice we seem to currently face a chicken and egg problem when doing so however. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/include/trap.h stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sparc64/sparc64/trap.c Modified: stable/7/sys/sparc64/include/trap.h ============================================================================== --- stable/7/sys/sparc64/include/trap.h Thu Mar 19 13:11:02 2009 (r190040) +++ stable/7/sys/sparc64/include/trap.h Thu Mar 19 13:17:19 2009 (r190041) @@ -90,6 +90,7 @@ #define T_KERNEL 64 #ifndef LOCORE +void sun4u_set_traptable(void *tba_addr); extern const char *trap_msg[]; #endif Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 13:11:02 2009 (r190040) +++ stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 13:17:19 2009 (r190041) @@ -437,6 +437,16 @@ sparc64_init(caddr_t mdp, u_long o1, u_l cpu_setregs(pc); /* + * Take over the trap table via the PROM. Using the PROM for this + * is necessary in order to set obp-control-relinquished to true + * within the PROM so obtaining /virtual-memory/translations doesn't + * trigger a fatal reset error or worse things further down the road. + * XXX it should be possible to use this soley instead of writing + * %tba in cpu_setregs(). Doing so causes a hang however. + */ + sun4u_set_traptable(tl0_base); + + /* * It's now safe to use the real DELAY(). */ delay_func = delay_tick; Modified: stable/7/sys/sparc64/sparc64/trap.c ============================================================================== --- stable/7/sys/sparc64/sparc64/trap.c Thu Mar 19 13:11:02 2009 (r190040) +++ stable/7/sys/sparc64/sparc64/trap.c Thu Mar 19 13:17:19 2009 (r190041) @@ -70,6 +70,8 @@ __FBSDID("$FreeBSD$"); #endif #include +#include + #include #include #include @@ -227,6 +229,28 @@ int debugger_on_signal = 0; SYSCTL_INT(_debug, OID_AUTO, debugger_on_signal, CTLFLAG_RW, &debugger_on_signal, 0, ""); +/* + * SUNW,set-trap-table allows to take over %tba from the PROM, which + * will turn off interrupts and handle outstanding ones while doing so, + * in a safe way. + */ +void +sun4u_set_traptable(void *tba_addr) +{ + static struct { + cell_t name; + cell_t nargs; + cell_t nreturns; + cell_t tba_addr; + } args = { + (cell_t)"SUNW,set-trap-table", + 2, + }; + + args.tba_addr = (cell_t)tba_addr; + openfirmware(&args); +} + void trap(struct trapframe *tf) {