Skip to content

Resolve issues IRQ handling, IPC, and fpage - #168

Merged
jserv merged 5 commits into
masterfrom
fix-kprobe
Jan 25, 2026
Merged

Resolve issues IRQ handling, IPC, and fpage#168
jserv merged 5 commits into
masterfrom
fix-kprobe

Conversation

@jserv

@jserv jserv commented Jan 25, 2026

Copy link
Copy Markdown
Member

IRQ handling:

  • Add memory clobbers to cpsid/cpsie to prevent reordering
  • Fix irq_number() operand order (was reading garbage)
  • Add isb after msr control for pipeline synchronization
  • Restore r4-r11 in schedule_in_irq() when no context switch
  • Make __irq_saved_regs volatile to prevent optimization issues
  • Use explicit unrolled copy in __irq_save to prevent loop issues

IPC:

  • Add MR bounds check in INACTIVE non-start path (security)
  • Return error for send to T_INACTIVE without timeout (prevents hang)
  • Return error for send to non-existent thread

Fpage management:

  • Fix split_fpage() bounds validation (<= base, >= end)
  • Add NULL checks for as/fpage parameters
  • Fix shift UB: use ((memptr_t)1 << shift) throughout
  • Add overflow check for end = base + size
  • Add free_fpage_chain() helper for proper cleanup
  • Fix partial allocation leaks in assign_fpages_ext()
  • Add cycle guard in unmap_fpage() with CONFIG_MAX_FPAGES limit

Memory/Thread subsystem:

  • Add error handling for assign_fpages_ext() failures
  • Add panic on KIP fpage creation failure
  • Check map_fpage() return values in map_area()

jserv added 5 commits January 25, 2026 17:28
IRQ handling:
- Add memory clobbers to cpsid/cpsie to prevent reordering
- Fix irq_number() operand order (was reading garbage)
- Add isb after msr control for pipeline synchronization
- Restore r4-r11 in schedule_in_irq() when no context switch
- Make __irq_saved_regs volatile to prevent optimization issues
- Use explicit unrolled copy in __irq_save to prevent loop issues

IPC:
- Add MR bounds check in INACTIVE non-start path (security)
- Return error for send to T_INACTIVE without timeout (prevents hang)
- Return error for send to non-existent thread

Fpage management:
- Fix split_fpage() bounds validation (<= base, >= end)
- Add NULL checks for as/fpage parameters
- Fix shift UB: use ((memptr_t)1 << shift) throughout
- Add overflow check for end = base + size
- Add free_fpage_chain() helper for proper cleanup
- Fix partial allocation leaks in assign_fpages_ext()
- Add cycle guard in unmap_fpage() with CONFIG_MAX_FPAGES limit

Memory/Thread subsystem:
- Add error handling for assign_fpages_ext() failures
- Add panic on KIP fpage creation failure
- Check map_fpage() return values in map_area()
The CI was incorrectly passing when tests failed. Now it properly
detects "FAILED" in test output and fails the build.

Check order:
1. Crash detection (MEMFAULT/HardFault/panic) - immediate failure
2. Test failure detection ("FAILED") - immediate failure
3. Boot success verification (KDB/kernel messages)
4. Test pass count reporting

This will correctly fail CI on the "From parameter (local)" test
failure until C2.2 (L4_ExchangeRegisters unimplemented) is fixed.
The kernel's IPC returns the sender's global thread ID in the 'from'
parameter. The test was comparing against L4_LocalIdOf() which depends
on the unimplemented L4_ExchangeRegisters syscall, causing it to always
return 0.

Fix: Compare directly with the global ID (ipc_t2) since that's what
the kernel actually returns.

This resolves the CI failure where "From parameter (local)" was failing
with "Returned Id 0 != 0".
ktimer_enable() only updated ktimer_delta and ktimer_time if the timer
was not already enabled. This caused a bug when scheduling an earlier
event: it calls ktimer_enable(ticks) to "reset timer", but if ktimer_enabled
was already 1, the new delta was ignored.

Always update ktimer_delta and reset ktimer_time regardless of current
enabled state. This ensures proper timer rescheduling when inserting
events before the current queue head.
Print "L4/Pistachio test suite complete" after all tests finish.
This allows CI to detect successful test completion and exit early,
rather than waiting for the full timeout while pingpong runs forever.

Update CI workflow to:
- Exit successfully when "test suite complete" is detected
- Fail explicitly if tests started but didn't complete (timeout)
@jserv
jserv merged commit e36194f into master Jan 25, 2026
3 checks passed
@jserv
jserv deleted the fix-kprobe branch January 25, 2026 10:16
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.

1 participant