Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Feb 2020 18:41:48 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r358470 - head/sys/kern
Message-ID:  <202002291841.01TIfmQs047308@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Sat Feb 29 18:41:48 2020
New Revision: 358470
URL: https://svnweb.freebsd.org/changeset/base/358470

Log:
  Ensure that arm64 thread structures are allocated from the direct map.
  
  Otherwise we can fail to handle translation faults on curthread, leading
  to a panic.
  
  Reviewed by:	alc, rlibby
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23895

Modified:
  head/sys/kern/kern_thread.c

Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c	Sat Feb 29 17:24:02 2020	(r358469)
+++ head/sys/kern/kern_thread.c	Sat Feb 29 18:41:48 2020	(r358470)
@@ -331,6 +331,7 @@ proc_linkup(struct proc *p, struct thread *td)
 void
 threadinit(void)
 {
+	uint32_t flags;
 
 	mtx_init(&tid_lock, "TID lock", NULL, MTX_DEF);
 
@@ -340,9 +341,20 @@ threadinit(void)
 	 */
 	tid_unrhdr = new_unrhdr(PID_MAX + 2, INT_MAX, &tid_lock);
 
+	flags = UMA_ZONE_NOFREE;
+#ifdef __aarch64__
+	/*
+	 * Force thread structures to be allocated from the direct map.
+	 * Otherwise, superpage promotions and demotions may temporarily
+	 * invalidate thread structure mappings.  For most dynamically allocated
+	 * structures this is not a problem, but translation faults cannot be
+	 * handled without accessing curthread.
+	 */
+	flags |= UMA_ZONE_CONTIG;
+#endif
 	thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(),
 	    thread_ctor, thread_dtor, thread_init, thread_fini,
-	    32 - 1, UMA_ZONE_NOFREE);
+	    32 - 1, flags);
 	tidhashtbl = hashinit(maxproc / 2, M_TIDHASH, &tidhash);
 	rw_init(&tidhash_lock, "tidhash");
 }



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