arch/risc-v64: Add lazy FPU stacking and QEMU functional tests for GNU port#549
arch/risc-v64: Add lazy FPU stacking and QEMU functional tests for GNU port#549Winstonllllai wants to merge 3 commits into
Conversation
Save mstatus/sstatus to stack slot 29 and skip floating-point register save/restore when FS is Off (bits 14:13). This avoids unnecessary FP context work for threads that do not use the FPU. - context_save: check FS in nested and first-level interrupt paths - context_restore: gate FP restore on nested, no-preempt, and preempt paths - use sstatus when TX_RISCV_SMODE is defined, otherwise mstatus
Wire the QEMU virt demo into the CMake build system and add a Python/GDB functional test runner, mirroring the risc-v32/gnu port. - Add qemu_virt/CMakeLists.txt to build kernel.elf and register the check-functional-riscv64 target (requires Python3; skipped if absent) - Link kernel.elf with --whole-archive so all ThreadX symbols resolve - Pin _start at 0x80000000 via .text.boot in entry.s and KEEP(*(.text.boot)) in link.lds - Extend demo_threadx.c with fpu_test_val and shorten thread_0 sleep for GDB-driven FPU, timer, and preemption checks - Add test/azrtos_test_tx_gnu_riscv64_qemu.py; verified passing on QEMU virt (FPU, timer interrupt, preemption)
|
Hi @Winstonllllai. Thank you for this contribution. @akifejaz and I will review it. |
|
Hi @fdesbiens and @akifejaz , |
|
Hi @Winstonllllai please see comments below |
akifejaz
left a comment
There was a problem hiding this comment.
Hi @Winstonllllai I see multiple issue at first glance some of those I already pointed in your previous PR : #513
and
- i see no significance for test/ dir & *.py script you can keep it for local testing. -- please also remove from RV32 port (PR : #513)
- the "TX_RISCV_SMODE" is obviously from some other PR, seems like merging issue, you should not be adding these changes
- There are multiple new empty asm symbols in there, I'm not sure why you've added those if you chose to keep them empty.
- also please change the comments carefully, I see you updated the comments wrongly, the earlier versions were fine.
- the file name is
entry.Sbut your cmake calls it `entry.s' (small s), it should give build fails, please double check changes when submit PR
Also AI generated code should be marked properly. @fdesbiens when you get time, please also share the AI coding guidelines (if we have any) to him.
4c8dcd2 to
6943895
Compare
Revert accidental RV64 qemu_virt test/CMake integration changes and keep this branch focused on lazy FPU context handling only. Also remove unintended TX_RISCV_SMODE-based mstatus/sstatus save path and align comments/logic to mstatus-only behavior.
|
Hi @akifejaz . Thanks for the review — I've addressed the points below:
The PR is now scoped to lazy FPU context save/restore only. |
|
For the RV32 cleanup requested in review, I opened a separate follow-up PR: #552. It removes the local-only QEMU test script and related CMake/test-only changes from the RV32 port. |
This PR adds functional enhancements for the ThreadX RISC-V 64-bit (RV64) GNU port, mirroring the improvements delivered for RV32 in #513.
Lazy FPU Stacking:
_tx_thread_context_saveand_tx_thread_context_restoreto savemstatus/sstatusand skip FP register save/restore when the FS field (bits 14:13) is Off.TX_RISCV_SMODE(readssstatusvsmstatusas appropriate).Automated Testing Framework:
azrtos_test_tx_gnu_riscv64_qemu.py).qemu_virt/CMakeLists.txtand registered thecheck-functional-riscv64target.demo_threadx.cwithfpu_test_valand adjusted thread timing for GDB-driven verification.QEMU Boot & Link Fixes:
_startin a.text.bootsection and addedKEEP(*(.text.boot))tolink.ldsso the entry point is pinned at0x80000000(QEMU virt reset PC).kernel.elfwith--whole-archiveto ensure all ThreadX symbols resolve on RV64.How to Run Tests
cmake -B build_qemu -DCMAKE_TOOLCHAIN_FILE=cmake/riscv64_gnu.cmake cd build_qemu make check-functional-riscv64Tested on QEMU virt machine (rv64gc).
Please let me know if there is anything I should improve or if I missed anything.