aboutsummaryrefslogtreecommitdiff
path: root/kern
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* lock: Reset l->writer also for read-write upgradees which are doneSamuel Thibault2023-08-121-2/+5
|
* lock: Fix building with MACH_LDEBUG but NCPUS==1Samuel Thibault2023-08-121-1/+1
|
* lock: Rename simple_unlock version with information to _simple_unlockSamuel Thibault2023-08-122-2/+3
| | | | For coherency with the rest of the implementations
* kern/thread: Only loop over cpus that existDamien Zammit2023-08-061-1/+2
| | | | Message-Id: <20230805154859.2003109-1-damien@zamaudio.com>
* Add timing info to MACH_LOCK_MON lock monitoringDamien Zammit2023-08-051-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Booting to beginning of bootstrap with different number of cpus and checking the lock statistics where TIME is in milliseconds: Set MACH_LOCK_MON to 1 in configfrag.ac, then Configure options --enable-ncpus=8 --enable-kdb --enable-apic --disable-linux-groups -smp 1 db{0}> show all slocks SUCCESS FAIL MASKED STACK TIME LOCK/CALLER 4208 0/0 4208/100 2/0 7890/1 0xc1098f54(c11847c8) 1 0/0 1/100 0/0 7890/7890 0x315(c11966e0) 30742 0/0 0/0 2106/0 160/0 0xf52a9e2c(f5a07958) 30742 0/0 0/0 0/0 140/0 0xf52a5e2c(f5a07b10) 149649 0/0 3372/2 1/0 120/0 0xc118a590(c118a9d4) 16428 0/0 0/0 1/0 90/0 0xf52a5dd0(f5a07ab8) 14345 0/0 0/0 18/0 80/0 0xf64afe2c(f64aa488) 1791 0/0 0/0 1/0 80/0 0xf52a3e70(f5e57f70) 17331 total locks, 0 empty buckets 2320150 0/0 455490/19 11570533/4 17860/0 0xc10a4580(c10a4580) -smp 2 (could not wait until booted) db{0}> show all slocks SUCCESS FAIL MASKED STACK TIME LOCK/CALLER 47082 0/0 47082/100 0/0 413940/8 0xc1098f54(c11847c8) 2 0/0 2/100 0/0 413940/206970 0x6ede(c11966e0) 47139 0/0 0/0 2106/0 4670/0 0xc119edec(f5e409b0) 132895 3/0 3372/2 1/0 4580/0 0xc118a590(c118a9d4) 118313 0/0 2/0 0/0 3660/0 0xc1098ec4(c1189f80) 183233 1/0 1714/0 2/0 2290/0 0xc1098e54(c118aa8c) 14357 0/0 0/0 1878/0 1200/0 0xf52a4de0(f5e40a60) 14345 0/0 0/0 18/0 1200/0 0xf52a4dec(f528f488) 16910 total locks, 0 empty buckets 2220850 455/0 485391/21 11549793/5 879030/0 0xc10a4580(c10a4580) Message-Id: <20230722045043.1579134-1-damien@zamaudio.com>
* Fix task_info for TASK_THREAD_TIMES_INFO.Flavio Cruz2023-05-171-1/+7
| | | | | | We are checking for the existence of time_value64_t but we didn't add that to the task_thread_times_info structure. Message-Id: <ZGRDbS0XIm1fJwkG@jupiter.tail36e24.ts.net>
* Keep host_get_kernel_version for USER32-on-x86_64 caseSamuel Thibault2023-05-111-1/+1
|
* Remove host_kernel_version RPC for x86_64Flavio Cruz2023-05-111-4/+6
| | | | | | | We can fast track the simplification of the RPC ABI for x86_64 if we don't have MACH_MSG_TYPE_STRING used in RPCs which forces msgt_size to use more than 8 bits. Message-Id: <ZFht+/9cVPHuV90D@jupiter.tail36e24.ts.net>
* Use designated initializers in kern/ipc_kobject.cFlavio Cruz2023-05-051-7/+8
| | | | | msgt_deallocate was not initialized explicitly, this fixes that too. Message-Id: <ZFM2cLr1Ms/B3v8U@jupiter.tail36e24.ts.net>
* Use designated initializers in kern/exception.cFlavio Cruz2023-05-041-28/+28
| | | | Message-Id: <ZFLq5/a9zzRHOlSf@jupiter.tail36e24.ts.net>
* Implement mig_deallocate to free memory when kernel server RPC succeedsFlavio Cruz2023-05-021-0/+10
| | | | | | | | | | | | In case the kernel interfaces use dynamically sized strings, we will end up calling mig_deallocate to free the out of line string that was copied into the kernel. As a matter of contract such type of data is freed automatically either in kernel code when the RPC fails or in the MiG stub if it succeeds. This was tested by changing task_set_name to use dynamic strings and making sure out of line data is passed when strlen(name) > 4. Message-Id: <ZFB64/0vOJ3x15ub@jupiter.tail36e24.ts.net>
* Use mig_support.h prototypes instead of duplicating them.Flavio Cruz2023-05-022-10/+2
| | | | | | | | | * include/mach/mig_support.h: Drop the ifndef because this file is only used internally to compile gnumach. We export mig_support.h from glibc already. * kern/ipc_mig.c: len should be vm_size_t. * kern/ipc_mig.h: Drop duplicate prototypes. Message-Id: <ZFBjEk07CaQgx9Ru@jupiter.tail36e24.ts.net>
* add setting gs/fsbaseLuca Dariz2023-05-011-0/+3
| | | | | | | | | | | * i386/i386/i386asm.sym: add offsets for asm * i386/i386/pcb.c: switch FSBASE/GSBASE on context switch and implement accessors in thread setstatus/getstatus * i386/i386/thread.h: add new state to thread saved state * kern/thread.c: add i386_FSGS_BASE_STATE handler * x86_64/locore.S: fix fs/gs handling, skipping the base address and avoid resetting it by manually re-loading fs/gs Message-Id: <20230419194703.410575-5-luca@orpolo.org>
* Update task_basic_info and thread_basic_info to include time_value64_t data.Flavio Cruz2023-04-272-9/+23
| | | | | | RPCs remain compatible with existing clients but if they know about the new size then we will populate the new fields. Message-Id: <ZDzPLCJccKeRB5Pd@mars.tail36e24.ts.net>
* Remove host_get_boot_info and host_get_kernel_boot_info since they are not used.Flavio Cruz2023-04-071-23/+0
| | | | | | host_get_kernel_boot_info was added recently to fix the use of MACH_MSG_TYPE_STRING. Message-Id: <ZC5Sz8a4FCT6IjCY@jupiter.tail36e24.ts.net>
* Align the user stack correctly for 64 bit programs.Flavio Cruz2023-04-041-2/+1
| | | | | | | | | | | * i386/i386/thread.h: Define USER_STACK_ALIGN which is 16-byte for 64 bit programs as recommended by the System V AMD64 guidelines. Also define KERNEL_STACK_ALIGN which can differ from user land. * i386/i386/pcb.c: Use USER_STACK_ALIGN to align the bootstrap arguments and ultimately the stack where the program starts on. * kern/bootstrap.c: Do not align arg_len here since it will be aligned in set_user_regs. Message-Id: <ZCpOb6vNEfPclKPr@jupiter.tail36e24.ts.net>
* Make exception subcode a longSergey Bugaev2023-04-033-16/+32
| | | | | | | | | On EXC_BAD_ACCESS, exception subcode is used to pass the faulting memory address, so it needs to be (at least) pointer-sized. Thus, make it into a long. This requires matching changes in glibc and the Hurd. Message-Id: <20230319151017.531737-4-bugaevc@gmail.com>
* Track task and thread time using time_value64_t.Flavio Cruz2023-03-137-104/+76
| | | | | | | | Changed kern/timer.c to use the higher precision time_value64_t. Of course, this won't suffer from the 2038 overflow but it does provide nanosecond precision (if gnumach ever uses a better timer) and moves us closer to only having time_value64_t. Message-Id: <ZA63tGcv3bETUJFJ@jupiter.tail36e24.ts.net>
* Use c_string to define host_get_kernel_version and host_get_kernel_boot_info.Flavio Cruz2023-03-132-0/+16
| | | | | | | | | | | | | | The existing definitions for kernel_version_t and kernel_boot_info_t use (MACH_MSG_TYPE_STRING, length*8) which result in message types that have a single element of 512 or 4096 bytes (set as msgt_size). This results in MiG generating mach_msg_type_long_t. Using c_string has the benefit of moving this size to be defined as msgt_number which doesn't overflow. This will allow us to simplify the 64 bit RPC ABI since all msgt_size can be defined with just 8 bits (as it should be expected). The resulting implementation is the same but we still need to define new RPCs since server and user expect different mach_msg_type_t. Message-Id: <ZA63pS8j9J6NwuXY@jupiter.tail36e24.ts.net>
* Update thread and task creation time to use time_value64_tFlavio Cruz2023-03-124-12/+9
| | | | Message-Id: <ZAzYoE7+ugFsH5JA@jupiter.tail36e24.ts.net>
* lock_mon: Fix warningsSamuel Thibault2023-03-073-9/+16
|
* kern: Fix MACH_LOCK_MON lock monitoring debugDamien Zammit2023-03-074-4/+17
| | | | | | | | TESTED: - by setting MACH_LOCK_MON to 1 in configfrag.ac and running "show all slocks" in kdb - does not break default configured kernel Message-Id: <20230306070512.292715-1-damien@zamaudio.com>
* x86_64: fix argument passing to bootstrap modules if ! USER32Luca Dariz2023-02-161-5/+5
| | | | | * kern/bootstrap.c: replace integers with long/vm_offset_t Message-Id: <20230216213318.2048699-3-luca@orpolo.org>