Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jun 2012 21:08:48 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r237243 - head/sys/amd64/amd64
Message-ID:  <201206182108.q5IL8mWK001009@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Jun 18 21:08:48 2012
New Revision: 237243
URL: http://svn.freebsd.org/changeset/base/237243

Log:
  Adjust the fix in r236953, by not generating the signal manually, but
  performing the return to usermode using full return path.  This
  consolidates the handling of exceptional situations in less number of
  places, and is less code as well.
  
  Reviewed by:   jhb
  MFC after:     1 week

Modified:
  head/sys/amd64/amd64/trap.c

Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c	Mon Jun 18 21:00:54 2012	(r237242)
+++ head/sys/amd64/amd64/trap.c	Mon Jun 18 21:08:48 2012	(r237243)
@@ -977,16 +977,10 @@ amd64_syscall(struct thread *td, int tra
 	 * If the user-supplied value of %rip is not a canonical
 	 * address, then some CPUs will trigger a ring 0 #GP during
 	 * the sysret instruction.  However, the fault handler would
-	 * execute with the user's %gs and %rsp in ring 0 which would
-	 * not be safe.  Instead, preemptively kill the thread with a
-	 * SIGBUS.
+	 * execute in ring 0 with the user's %gs and %rsp which would
+	 * not be safe.  Instead, use the full return path which
+	 * catches the problem safely.
 	 */
-	if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) {
-		ksiginfo_init_trap(&ksi);
-		ksi.ksi_signo = SIGBUS;
-		ksi.ksi_code = BUS_OBJERR;
-		ksi.ksi_trapno = T_PROTFLT;
-		ksi.ksi_addr = (void *)td->td_frame->tf_rip;
-		trapsignal(td, &ksi);
-	}
+	if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS)
+		set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
 }



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