opnsense-src/sys/vm
Mark Johnston 0db4588bbe thread: Simplify sanitizer integration with thread creation
fork() may allocate a new thread in one of two ways: from UMA, or cached
in a freed proc that was just allocated from UMA.  In either case, KASAN
and KMSAN need to initialize some state; in particular they need to
initialize the shadow mapping of the new thread's stack.

This is done differently between KASAN and KMSAN, which is confusing.
This patch improves things a bit:
- Add a new thread_recycle() function, which moves all kernel stack
  handling out of kern_fork.c, since it doesn't really belong there.
- Then, thread_alloc_stack() has only one local caller, so just inline
  it.
- Avoid redundant shadow stack initialization: thread_alloc()
  initializes the KMSAN shadow stack (via kmsan_thread_alloc()) even
  through vm_thread_new() already did that.
- Add kasan_thread_alloc(), for consistency with kmsan_thread_alloc().

No functional change intended.

Reviewed by:	khng
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44891

(cherry picked from commit 800da341bc4a35f4b4d82d104b130825d9a42ffa)
2025-02-07 14:46:53 +00:00
..
_vm_phys.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
_vm_radix.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
device_pager.c device_pager: rename the un_pager.devp.dev field to handle 2024-11-13 01:19:18 +02:00
memguard.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
memguard.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
phys_pager.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
pmap.h pmap: move the smp_targeted_tlb_shutdown pointer stuff to amd64 pmap.h 2024-07-01 13:07:38 +00:00
redzone.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
redzone.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
sg_pager.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
swap_pager.c swap_pager: Ensure that swapoff puts swapped-in pages in page queues 2024-11-28 14:38:17 +00:00
swap_pager.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
uma.h uma: Permit specifying max of cache line and some custom alignment 2023-11-16 10:07:18 -05:00
uma_align_mask.h uma: Make the cache alignment mask unsigned 2023-11-16 10:07:16 -05:00
uma_core.c uma: New check_align_mask(): Validate alignments (INVARIANTS) 2023-11-16 10:07:17 -05:00
uma_dbg.c uma: Micro-optimize memory trashing 2023-12-08 21:32:43 -05:00
uma_dbg.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
uma_int.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_domainset.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_domainset.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_dumpset.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_extern.h vm: Add kva_alloc_aligned 2024-09-02 08:43:18 +00:00
vm_fault.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_glue.c thread: Simplify sanitizer integration with thread creation 2025-02-07 14:46:53 +00:00
vm_init.c Adjust comments referencing vm_mem_init() 2024-06-06 11:23:01 -03:00
vm_kern.c vm: Add kva_alloc_aligned 2024-09-02 08:43:18 +00:00
vm_kern.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_map.c vm_map: add vm_map_find_locked(9) 2024-10-05 10:08:54 +03:00
vm_map.h vm_map: add vm_map_find_locked(9) 2024-10-05 10:08:54 +03:00
vm_meter.c vm_meter: Fix laundry accounting 2024-10-29 13:04:25 +00:00
vm_mmap.c vm_object: do not assume that un_pager.devp.dev is cdev 2024-11-13 01:19:18 +02:00
vm_object.c vm_object: do not assume that un_pager.devp.dev is cdev 2024-11-13 01:19:18 +02:00
vm_object.h vm_object: do not assume that un_pager.devp.dev is cdev 2024-11-13 01:19:18 +02:00
vm_page.c vm_pageout: Add a chicken switch for multithreaded PQ_INACTIVE scanning 2025-01-23 13:58:07 +00:00
vm_page.h vm_page_free_pages_toq(): return the count of freed pages 2024-10-05 10:08:56 +03:00
vm_pageout.c vm_pageout: Add a chicken switch for multithreaded PQ_INACTIVE scanning 2025-01-23 13:58:07 +00:00
vm_pageout.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_pagequeue.h vm_pageout: Add a chicken switch for multithreaded PQ_INACTIVE scanning 2025-01-23 13:58:07 +00:00
vm_pager.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_pager.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
vm_param.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_phys.c vm_phys: fix freelist_contig 2023-11-24 19:19:05 -06:00
vm_phys.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_radix.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_radix.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_reserv.c vm_reserv_reclaim_contig: Return NULL not false 2024-04-17 10:33:26 -04:00
vm_reserv.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
vm_swapout.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_swapout_dummy.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vm_unix.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
vnode_pager.c buf: Add a runningbufclaim() helper 2024-12-06 14:51:09 +00:00
vnode_pager.h Add vnode_pager_clean_{a,}sync(9) 2024-01-18 02:51:33 +02:00