Created by: Alic3r3L1cwhk
This pull request introduces a comprehensive set of improvements and bug fixes, focusing on dynamic linker (glibc) support, SMP stability, file system reliability, and test infrastructure. The kernel now fully supports glibc dynamic linking, passes all LTP basic and glibc/lua test suites (SMP=2), resolves several critical SMP and file system races, and enhances the disk image build process for more robust CI/testing. The memory layout and stack sizes have been adjusted to support these new features, and documentation has been updated to reflect the current project status and roadmap.
Dynamic Linker and Memory Management Enhancements
- Full glibc dynamic linker (
PT_INTERP) support: Kernel loadsld.soat a high base address, constructs a proper auxiliary vector (auxv), and fixesAT_PHDRcalculation for both PIE and non-PIE binaries, enabling seamless execution of dynamically linked glibc binaries. Lazy (on-demand) anonymous mmap is implemented to handle glibc's large memory arenas efficiently, preventing OOM on startup. Stack sizes are increased (USER_STACK_SIZEto 1MB,KERNEL_STACK_SIZEto 64KB) to accommodate glibc startup requirements. [1] [2] [3] [4]
SMP and Kernel Stability Fixes
- SMP lost-wakeup race and chdir kernel panic resolved:
WaitQueue::waitandwakeup_taskare made atomic to eliminate wait/exit race conditions; defensive checks added tosys_chdirandtranslated_strto prevent kernel panics. - Pipe buffer moved from stack to heap to prevent kernel stack overflow; pipe lost-wakeup race fixed by atomically checking and sleeping in the wait queue.
- Timer ISR only polls for console input if there are waiting tasks, preventing system-wide hangs due to blocking SBI calls.
File System and Block Device Improvements
- FAT32: Multiple bug fixes in cluster allocation, file size updates, and LFN (long file name) write-back;
FatTableandFat32Filerefactored to track and update the current first cluster and file size atomically, ensuring data consistency. [1] [2] [3] [4] [5] - Block device layer: Now panics immediately if no block device is found, preventing downstream errors; device access is now checked and locked for every read/write operation. [1] [2]
Test Infrastructure and Disk Image Build
-
os/make-disk.sh: Now supports injecting prebuiltbasic/*binaries into both FAT32 and EXT4 partitions usingdebugfs, making it easier to test with external or CI-provided binaries. The script is more robust and informative about what files are written. [1] [2] - QEMU and kernel memory increased to 256MB to support glibc's memory requirements. [1] [2]
Documentation and Roadmap Updates
-
README.md: Updated to reflect glibc dynamic linking as fully supported, all LTP basic and glibc/lua tests passing, and major SMP/filesystem bugs fixed. The roadmap and next steps are revised to focus on architecture abstraction, busybox shell, pthread/futex/TLS, and further driver upgrades. [1] [2] [3] [4] [5] [6] [7]
Other Notable Changes
- Console output now uses an interrupt-safe spinlock to prevent deadlocks if an interrupt handler logs during a critical section.
- Removed the
os/fs.imgbinary from version control.
These changes collectively bring the kernel to a new level of stability and compatibility, especially for dynamic userland workloads and rigorous testing scenarios.
References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]