Skip to content

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Jan 29, 2026

This replaces global in_syscall_context flag with per-task tracking in TCB. Global flag was corrupted when Task A yielded during syscall and Task B ran another syscall, clearing the flag before Task A resumed.

  • Add volatile bool in_syscall to tcb_t (survives preemption)
  • Update do_syscall to track per-task context
  • Update mo_task_spawn_kernel to check per-task flag
  • Use uintptr_t for syscall arguments (matches RISC-V ABI semantics)

Summary by cubic

Fix a race in syscall context tracking by moving from a global flag to per-task tracking, ensuring correct privilege enforcement across preemption. Also switch syscall argument types to uintptr_t to match the RISC-V ABI.

  • Bug Fixes

    • Replace global in_syscall_context with tcb_t.in_syscall (volatile, per-task).
    • Set/clear the flag in do_syscall so it survives preemption.
    • Update mo_task_spawn_kernel to use the per-task flag and block calls from syscall context.
  • Refactors

    • Use uintptr_t for syscall arguments across entry, HAL, headers, and syscall dispatch.
    • Update user-space wrappers to cast to uintptr_t, aligning with RISC-V register conventions.

Written for commit bb6344f. Summary will update on new commits.

This replaces global in_syscall_context flag with per-task tracking in
TCB. Global flag was corrupted when Task A yielded during syscall and
Task B ran another syscall, clearing the flag before Task A resumed.
- Add volatile bool in_syscall to tcb_t (survives preemption)
- Update do_syscall to track per-task context
- Update mo_task_spawn_kernel to check per-task flag
- Use uintptr_t for syscall arguments (matches RISC-V ABI semantics)
@jserv jserv requested review from HeatCrab and visitorckw January 29, 2026 05:15
@github-actions
Copy link

Linmo CI Test Results

Overall Status: ✅ passed
Timestamp: 2026-01-29T05:16:37+00:00
Commit: e4cbe20

Toolchain Results

Toolchain Build Crash Test Functional
GNU ✅ passed ✅ passed ✅ passed
LLVM ✅ passed ⏭️ skipped ⏭️ skipped

Application Tests

App GNU LLVM
cond ✅ passed ⏭️ skipped
coop ✅ passed ⏭️ skipped
cpubench ✅ passed ⏭️ skipped
echo ✅ passed ⏭️ skipped
hello ✅ passed ⏭️ skipped
mqueues ✅ passed ⏭️ skipped
mutex ✅ passed ⏭️ skipped
pipes ✅ passed ⏭️ skipped
pipes_small ✅ passed ⏭️ skipped
pipes_struct ✅ passed ⏭️ skipped
prodcons ✅ passed ⏭️ skipped
progress ✅ passed ⏭️ skipped
rtsched ✅ passed ⏭️ skipped
semaphore ✅ passed ⏭️ skipped
suspend ✅ passed ⏭️ skipped
test64 ✅ passed ⏭️ skipped
test_libc ✅ passed ⏭️ skipped
timer ✅ passed ⏭️ skipped
timer_kill ✅ passed ⏭️ skipped
umode ⚠️ ⏭️ skipped

Functional Test Details

Test GNU LLVM
mutex:data_consistency ✅ passed ⏭️ skipped
mutex:fairness ✅ passed ⏭️ skipped
mutex:mutual_exclusion ✅ passed ⏭️ skipped
mutex:overall ✅ passed ⏭️ skipped
semaphore:overall ✅ passed ⏭️ skipped
umode:[exception]_illegal_instruction ✅ passed ⚠️
umode:pass:_sys_tid()_returned ✅ passed ⚠️
umode:pass:_sys_uptime()_returned ✅ passed ⚠️

Report generated from test-summary.toml

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Copy link
Collaborator

@HeatCrab HeatCrab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jserv jserv merged commit f063a38 into main Jan 29, 2026
7 checks passed
@jserv jserv deleted the syscall-refine branch January 29, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants