#3 bi-weekly progress report

Published: Mon 18 November 2019

Good news everyone, reporting progress in Mimiker development!

Preliminary virtual address space manager (vmem) implementation (by JPsz)

The kernel needs to keep track of allocated memory regions, both for physical and virtual memory. Regions of physical memory are handled by physmem subsystem of Mimiker (using classy buddy algorithm btw), while virtual memory regions have been managed in an ad hoc way so far. This will change in a near future: JPsz ported a variant of vmem subsystem from NetBSD, thus providing abstractions of memory arenas, spans and segments. An arena is a container of disjoint spans and each span consists of disjoint segments. Here both spans and segments represent contiguous virtual memory addresses. Note that vmem doesn’t allocate physical memory, but only provides bookkeeping services. It may e.g. be useful in kmem (i.e. kernel memory allocator) implementation.

Kernel can be parsed by Clang for static analysis purposes (by JPiec)

As the Mimiker kernel grows big, it’s certainly being poisoned by a stream of subtle bugs, unavoidable in any larger project. Although fully automatic bug discovery is infeasible (simply speaking), some of them, like arithmetic errors or some cases of invalid memory dereferences, can be handled by means of static analysis. The Clang framework offers industry-standard static analyses almost off the shelve and we’ll make use of it!

Implement VFS name resolver - generalized version of vfs_lookup (by JUrb)

Mimiker’s Virtual File System interface has became a bit more mature. Function vfs_nameresolve, the wrapper of which is the path-to-vnode resolver vfs_lookup, had its interface generalized and is now also able to fetch parent file vnode.

Link cpio nodes with v-nodes correctly for initrd file system (by JSzcz)

In Unix-like systems an initial ramdisk, initrd, serves as a primary boot-time filesystem in which both kernel and loadable kernel modules (device drivers) are stored. The initrd image of Mimiker’s kernel is stored in the form of cpio archive, which must be correctly handled by vfs subsystem. The handling has been improved.

Load user program symbols automatically on GDB startup (by JMaz)

GDB can access kernel memory even when CPU is in user mode (by JMaz)

Debugging is definitely most time consuming programmer’s activity, therefore any effort made to ease this process quickly pays back. E.g. you want addresses encountered during a GDB session to be automagically mapped to source code identifiers. To make GDB aware of the mapping when debugging Mimiker’s user-space programs, you had to specify program path either in command-line or in .gdbinit. This has changed and an appropriate option is passed to GDB by Mimiker’s launch infrastructure by default. You will also want to view the entire system memory, even when debugging user-space program, and this has been achieved (under QEMU of course, this can’t work on bare metal).

Kernel launch script can pass arguments to init process (by PJas)

Another feature to ease debugging and inject boot time system parameters.

Port ksh (Korn Shell), cat & wc from NetBSD to Mimiker (by Cahir)

The more tools, the more usable the system is. Great!

Kernel bootstrap is performed in virtual addresses (by Cahir)

Further progress in moving the entire system to virtual space: kernel main thread (aka thread zero), the first thread started upon system boot has its stack moved to virtual space. The construction of the stack takes place just after boot loader invoked _start method, so the platform_init and all following code of the main thread is fully virtualized! Note that virtualization decouples kernel code from architecture details, what will prove its significance when porting Mimiker to AArch64.

Memory for pool and kmem allocator is provided lazily (by Cahir)

Kernel memory allocators kmem and pool code should operate on virtual addresses, but virtual memory subsystem itself employs these allocators. The main problem was with pool, for which this chicken and egg situation was resolved by hard-wired allocation of memory from kernel .bss section.