Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To implement timer interrupts and inter-processor interrupts (IPIs) on RISC-V, ACLINT and CLINT are the commonly used hardware components. The key difference between ACLINT and CLINT lies in ACLINT’s ability to support both Supervisor software interrupts (SSWI) and Machine software interrupts (MSWI). Additionally, ACLINT modularizes its hardware functionalities, such as timers and IPI controllers, making the design and implementation more flexible than CLINT. According to the Linux kernel documentation: https://www.kernel.org/doc/html/next/riscv/boot.html#kernel-entry, there are two methods for entering the Linux kernel on SMP systems: - RISCV_BOOT_SPINWAIT: Boots all harts simultaneously, mainly used for older firmwares without SBI HSM extension and M-mode RISC-V kernels. - Ordered booting: Utilizes the SBI HSM extension to boot only one hart during the initial boot phase. The Linux kernel introduced ordered booting (commit 'cfafe26') to simplify multi-stage SMP boot management. The commit explains that the previous method complicated the multi-stage boot process, requiring management of all harts at each stage. The SBI HSM extension simplifies this by booting only one hart initially, which can then bring up the remaining harts sequentially. To fully support the HSM extension, ACLINT is necessary. particularly for supervisor-level interrupt management. This commit transitions from CLINT to ACLINT, aligning with modern RISC-V specifications and providing support for 'mtimer', 'mswi', and 'sswi'. The existing CLINT implementation has been removed entirely as ACLINT covers its functionalities. Testing instructions: - Run the following command to test the implementation: 'make check SMP=n', where 'n' is the number of harts to simulate. - After booting the emulator: - Verify multi-core operation and HSM implementation with '/proc/cpuinfo'. - Check timer interrupts via '/proc/interrupts'. - Confirm ACLINT is correctly recognized using '/proc/device-tree'. Future work: Currently, due to the lack of implementation, the introduced ACLINT uses only supervisor-level IPI. Therefore, although the logic for mswi is implemented, it is not being used at the moment. Also, SMP support remains incomplete. For example, the current semu implementation sequentially simulates multi-core execution, causing a slowdown as the number of cores increases. This leads to a time desynchronization issue across cores. To achieve parallel multi-core simulation, RFENCE extension implementation is required. However, it is currently incomplete. After completing ACLINT, the next step is to implement the RFENCE extension to fully support multi-core system simulation.
- Loading branch information