Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Nov 2013 21:51:34 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r258694 - head/sys/powerpc/ofw
Message-ID:  <201311272151.rARLpY6b056185@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Wed Nov 27 21:51:34 2013
New Revision: 258694
URL: http://svnweb.freebsd.org/changeset/base/258694

Log:
  Make RTAS calls, which call setfault() to recover from machine checks,
  preserve any existing fault buffer. RTAS calls are meant to be safe from
  interrupt context (and are indeed used there to implement the xics PIC
  drvier). Without this, calling into RTAS in interrupt context would have
  the effect of clearing any existing onfault state of the interrupted
  thread, potentially leading to a panic.

Modified:
  head/sys/powerpc/ofw/rtas.c

Modified: head/sys/powerpc/ofw/rtas.c
==============================================================================
--- head/sys/powerpc/ofw/rtas.c	Wed Nov 27 20:56:10 2013	(r258693)
+++ head/sys/powerpc/ofw/rtas.c	Wed Nov 27 21:51:34 2013	(r258694)
@@ -192,7 +192,7 @@ int
 rtas_call_method(cell_t token, int nargs, int nreturns, ...)
 {
 	vm_offset_t argsptr;
-	faultbuf env;
+	faultbuf env, *oldfaultbuf;
 	va_list ap;
 	struct {
 		cell_t token;
@@ -221,6 +221,7 @@ rtas_call_method(cell_t token, int nargs
 
 	/* Get rid of any stale machine checks that have been waiting.  */
 	__asm __volatile ("sync; isync");
+	oldfaultbuf = curthread->td_pcb->pcb_onfault;
         if (!setfault(env)) {
 		__asm __volatile ("sync");
 		result = rtascall(argsptr, rtas_private_data);
@@ -228,7 +229,7 @@ rtas_call_method(cell_t token, int nargs
 	} else {
 		result = RTAS_HW_ERROR;
 	}
-	curthread->td_pcb->pcb_onfault = 0;
+	curthread->td_pcb->pcb_onfault = oldfaultbuf;
 	__asm __volatile ("sync");
 
 	rtas_real_unmap(argsptr, &args, sizeof(args));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311272151.rARLpY6b056185>