svn commit: r358470 - head/sys/kern
Mark Johnston
markj at FreeBSD.org
Sat Feb 29 18:41:49 UTC 2020
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");
}
More information about the svn-src-all
mailing list