aboutsummaryrefslogtreecommitdiff
path: root/kern
Commit message (Collapse)AuthorAgeFilesLines
* kern/rdxtree: Fix undefined behaviorSergey Bugaev2024-03-271-2/+2
| | | | | | | | Initializing a variable with itself is undefined, and GCC 14 rightfully produces a warning about the variable being used (to initialize itself) prior to initialization. X15 sets the variables to 0 instead, so do the same in Mach. Message-ID: <20240327161841.95685-8-bugaevc@gmail.com>
* gsync: Use copyin()/copyout() to access user memorySergey Bugaev2024-03-271-7/+31
| | | | | | | | | Depending on the architecture and setup, it may not be possible to access user memory directly, for example, due to user mode mappings not being accessible from kernel mode (x86 SMAP, AArch64 PAN). There are dedicated machine-specific copyin()/copyout() routines that know how to access user memory from the kernel; use them. Message-ID: <20240327161841.95685-6-bugaevc@gmail.com>
* Load 64-bit ELFs on all 64-bit portsSergey Bugaev2024-03-271-1/+1
| | | | | Not only on x86_64. Message-ID: <20240327161841.95685-5-bugaevc@gmail.com>
* Disable host_kernel_version() everywhere but on i386Sergey Bugaev2024-03-271-2/+2
| | | | | It's not only x86_64, none of new architectures are going to have it. Message-ID: <20240327161841.95685-3-bugaevc@gmail.com>
* move x86 copy_user.[ch] to ipc/ and make it arch-indipendentLD2024-03-091-1/+1
| | | | Message-ID: <20240309140244.347835-3-luca@orpolo.org>
* remove machine/machspl.h as it duplicates machine/spl.hLD2024-03-0914-14/+14
| | | | Message-ID: <20240309140244.347835-2-luca@orpolo.org>
* Check for null ports in task_set_essential, task_set_name and thread_set_name.Flavio Cruz2024-02-282-0/+9
| | | | | | Otherwise, it is easy to crash the kernel if userland passes arbitrary port names. Message-ID: <ZdriTgNhPsfu7c2M@jupiter.tail36e24.ts.net>
* kern: move pset_idle_lock/unlock to headerSamuel Thibault2024-02-233-14/+16
| | | | so that kern/machine.c can use it
* kern: Use _nocheck variants of locks taken at splsched()Damien Zammit2024-02-232-16/+28
| | | | | Fixes assertion errors when LDEBUG is compiled in. Message-ID: <20240223081404.458062-1-damien@zamaudio.com>
* kern: Use _irq variant of lock and disable interruptsDamien Zammit2024-02-233-4/+4
| | | | | During quantum adjustment, disable interrupts and call appropriate lock. Message-ID: <20240223080948.457792-1-damien@zamaudio.com>
* kern/processor: Do not set default_pset.empty on bootstrapDamien Zammit2024-02-231-2/+0
| | | | | | This is not needed because cpu_up does this when it comes online, it calls pset_add_processor(). Message-ID: <20240223080357.457465-1-damien@zamaudio.com>
* kern/gsync: Use vm_map_lookup with keep_map_lockedDamien Zammit2024-02-221-13/+6
| | | | | | | | | | | | | This prevents a deadlock in smp where a read lock on the map is taken in gsync and then the map is locked again inside vm_map_lookup() but another thread had a pre-existing write lock, therefore the second read lock blocks. This is fixed by removing the initial gsync read lock on the map but keeping the read lock held upon returning from vm_map_lookup(). Co-Authored-By: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240222082410.422869-4-damien@zamaudio.com>
* vm_map_lookup: Add parameter for keeping map lockedDamien Zammit2024-02-221-1/+1
| | | | | | | | | | | This adds a parameter called keep_map_locked to vm_map_lookup() that allows the function to return with the map locked. This is to prepare for fixing a bug with gsync where the map is locked twice by mistake. Co-Authored-By: Sergey Bugaev <bugaevc@gmail.com> Message-ID: <20240222082410.422869-3-damien@zamaudio.com>
* Fix compile with MACH_LOCK_MONDamien Zammit2024-02-191-0/+7
|
* Introduce and use assert_splsched()Samuel Thibault2024-02-193-6/+6
|
* kern: Fix parenthesis around assignment used as valueDamien Zammit2024-02-191-1/+1
|
* smp: Set processor set to non-empty when adding a processorDamien Zammit2024-02-121-0/+1
| | | | | | This allows the slave_pset to be used for actual tasks with the processor_set RPCs. Message-ID: <20240212053817.1919056-1-damien@zamaudio.com>
* Add thread_set_name RPC.Flavio Cruz2024-02-122-0/+28
| | | | | | | Like task_set_name, we use the same size as the task name and will inherit the task name, whenever it exists. This will be used to implement pthread_setname_np. Message-ID: <20240212062634.1082207-2-flaviocruz@gmail.com>
* Replace kernel header includes in include/mach/mach_types.h with forward ↵Flavio Cruz2024-02-123-0/+7
| | | | | | | | | | | | | | | declarations. I was trying to reuse TASK_NAME_SIZE in kern/thread.h but it was impossible because files included from kern/task.h end up requiring kern/thread.h (through percpu.h), creating a recursive dependency. With this change, mach_types.h only defines forward declarations and modules have to explicitly include the appropriate header file if they want to be able touch those structures. Most of the other includes are required because we no longer grab many different includes through mach_types.h. Message-ID: <20240212062634.1082207-1-flaviocruz@gmail.com>
* task: fix addressability of assign_active fieldSamuel Thibault2024-02-111-2/+2
| | | | It is used for thread_wakeup and alike.
* smp: Create AP processor set and put all APs inside itDamien Zammit2024-02-113-1/+18
| | | | | | | This has the effect of running with one cpu only with smp, but has the ability to enable APs in userspace with the right processor set RPCs. Message-ID: <20240211120051.1889789-1-damien@zamaudio.com>
* smp: Fix parenthesis around logic expression valueDamien Zammit2024-02-111-1/+1
| | | | Message-ID: <20240211070915.1879676-1-damien@zamaudio.com>
* mach_msg: Fix checking reception sizeSamuel Thibault2023-10-011-1/+1
| | | | | | | We need to check against the actual user size that will be used, not the current kernel size. Usually userland uses amply-large reception buffer, but better be exact.
* Add and use ikm_cache_alloc/free/_trySamuel Thibault2023-10-012-23/+13
|
* slab: Make whatis look furtherSamuel Thibault2023-10-011-3/+53
| | | | | Without a tree, we can still look up by hand in the buffers. This also allows to find freed objects.
* ddb: Add whatis commandSamuel Thibault2023-10-012-1/+40
| | | | This is convenient when tracking buffer overflows
* Allow disabling of MACH_PCSAMPLE and disable by defaultDamien Zammit2023-09-301-16/+16
| | | | | | This fixes a page fault when the sampling occurs in MP. Perhaps it is not MP safe yet. Message-Id: <20230930063032.75232-4-damien@zamaudio.com>
* kdb: Add "show all runqs" debug commandDamien Zammit2023-09-291-0/+1
| | | | Message-Id: <20230929045936.31535-1-damien@zamaudio.com>
* percpu: active_stack with gsDamien Zammit2023-09-253-8/+3
| | | | Message-Id: <20230925002417.467022-1-damien@zamaudio.com>
* SMP: Fix setting up initial gdtSamuel Thibault2023-09-241-1/+1
| | | | | We cannot access cpu_id_lut from the initial AP state, so update the percpu segment after loading gdt.
* percpu active_thread using gs segmentDamien Zammit2023-09-247-10/+8
| | | | | TESTED: As per previous commit Message-Id: <20230924052824.449219-4-damien@zamaudio.com>
* percpu area using gs segmentDamien Zammit2023-09-244-19/+11
| | | | | | | | | | | | | | | This speeds up smp again, by storing the struct processor in a percpu area and avoiding an expensive cpu_number every call of current_processor(), as well as getting the cpu_number by an offset into the percpu area. Untested on 64 bit and work remains to use other percpu arrays. TESTED: (NCPUS=8) -smp 1 boots to login shell ~2x slower than uniprocessor TESTED: (NCPUS=8) -smp 2 boots to INIT but hangs there TESTED: (NCPUS=8) -smp 4 gets stuck seemingly within rumpdisk and hangs TESTED: (NCPUS=1) uniprocessor is a bit faster than normal Message-Id: <20230924103428.455966-3-damien@zamaudio.com>
* cpu_number: Inline widely used simple functionDamien Zammit2023-09-243-3/+4
| | | | | | TESTED: on uniprocessor and smp, both behaved as normal. Message-Id: <20230924103428.455966-2-damien@zamaudio.com>
* sched_prim.c: Check all run queues not just master processorDamien Zammit2023-08-221-2/+8
| | | | Message-Id: <20230816014835.2322718-6-damien@zamaudio.com>
* eventcount: Fix locking thread while calling thread_setrunSamuel Thibault2023-08-221-1/+1
|
* sched_prim.c: Lock thread when calling thread_setrunDamien Zammit2023-08-221-0/+2
| | | | Message-Id: <20230816014835.2322718-5-damien@zamaudio.com>
* slab: Optimize non-slab PAGE_SIZE allocationsSamuel Thibault2023-08-211-0/+4
| | | | | In case there is no slab for PAGE_SIZE allocations, we can use direct physical allocation rather than consuming the kernel virtual space.
* pmap+slab: Add more smoketestsSamuel Thibault2023-08-141-0/+3
| | | | | Checking the range of addresses for operations on the kernel_pmap is quite cheap, and allows to catch oddities quite early enough.
* slab [SLAB_VERIFY]: Fix not enabling KMEM_CF_VERIFY on 4K slabsSamuel Thibault2023-08-141-1/+1
|
* slab [SLAB_VERIFY]: Do not enable KMEM_CF_VERIFY on large slabsSamuel Thibault2023-08-131-3/+3
| | | | | That would be refused by kmem_cache_compute_properties later on anyway, and prevent the kernel from booting at all.
* lock: Fix SMP buildSamuel Thibault2023-08-131-1/+1
|
* kern/sched_prim: Cause ast on cpu coming out of idleDamien Zammit2023-08-131-0/+6
| | | | Message-Id: <20230811083424.2154350-3-damien@zamaudio.com>
* simple lock: check that the non-_irq variants are not called from IRQSamuel Thibault2023-08-121-2/+8
|
* assert: fix concurrency against irqsSamuel Thibault2023-08-121-6/+7
| | | | by using simple_lock_irq.
* clock: Convert timer_lock to using simple_lock_irqSamuel Thibault2023-08-121-33/+17
|
* sched: Add waitq_lock helpers which check they are called at spl7Samuel Thibault2023-08-121-6/+21
|
* sched: Add runq_lock helpers which check they are called at spl7Samuel Thibault2023-08-124-11/+26
|
* kern: Check that locking thread is done at spl7Samuel Thibault2023-08-121-2/+13
|
* lock: Add _irq variantsSamuel Thibault2023-08-121-9/+75
| | | | | | | | And pave the way for making the non-_irq variants check that they are never used within interrupts. We do have a few places which were missing it, as the following commits will show.
* lock: Add more sanity checksSamuel Thibault2023-08-121-0/+3
|