Skip to content

Commit

Permalink
fix the bug of sc control judge and add mcs code of cancel badged sends
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhiyuanSue committed Dec 22, 2024
1 parent 609779c commit 7090ddc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ pub fn decode_sched_control_invocation(
&convert_to_mut_type_ref::<cte_t>(unsafe { current_extra_caps.excaprefs[0] })
.capability;
if unlikely(targetCap.get_tag() != cap_tag::cap_sched_context_cap) {
debug!("SchedControl_ConfigureFlags: budget out of range.");
debug!("SchedControl_ConfigureFlags: target cap not a scheduling context cap");
unsafe {
current_syscall_error._type = seL4_RangeError;
current_syscall_error.rangeErrorMin = MIN_BUDGET_US();
current_syscall_error.rangeErrorMax = MAX_PERIOD_US();
current_syscall_error._type = seL4_InvalidCapability;
current_syscall_error.invalidCapNumber = 1;
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
}
Expand Down
43 changes: 37 additions & 6 deletions sel4_ipc/src/endpoint.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::transfer::Transfer;
use sel4_common::arch::ArchReg;
use sel4_common::structures_gen::endpoint;
#[cfg(feature = "KERNEL_MCS")]
use sel4_common::structures_gen::seL4_Fault_tag::seL4_Fault_NullFault;
use sel4_common::structures_gen::endpoint;
use sel4_common::utils::{convert_to_mut_type_ref, convert_to_option_mut_type_ref};
use sel4_common::arch::ArchReg;
#[cfg(feature = "KERNEL_MCS")]
use sel4_task::{ksCurSC, reply::reply_t, sched_context::sched_context_t};
use sel4_task::{
possible_switch_to, rescheduleRequired, schedule_tcb, set_thread_state, tcb_queue_t, tcb_t,
ThreadState,
thread_state_func, ThreadState,
};
use sel4_vspace::pptr_t;

Expand Down Expand Up @@ -180,10 +180,40 @@ impl endpoint_func for endpoint {
while thread_ptr != 0 {
let thread = convert_to_mut_type_ref::<tcb_t>(thread_ptr);
thread_ptr = thread.tcbEPNext;
#[cfg(feature = "KERNEL_MCS")]
{
assert!(thread.tcbState.get_replyObject() == 0);
}
if thread.tcbState.get_blockingIPCBadge() as usize == badge {
set_thread_state(thread, ThreadState::ThreadStateRestart);
thread.sched_enqueue();
queue.ep_dequeue(thread);
#[cfg(not(feature = "KERNEL_MCS"))]
{
set_thread_state(thread, ThreadState::ThreadStateRestart);
thread.sched_enqueue();
queue.ep_dequeue(thread);
}
#[cfg(feature = "KERNEL_MCS")]
{
if thread.tcbFault.get_tag() == seL4_Fault_NullFault {
set_thread_state(thread, ThreadState::ThreadStateRestart);
if convert_to_mut_type_ref::<sched_context_t>(
thread.tcbSchedContext,
)
.sc_sporadic()
{
assert!(thread.tcbSchedContext != unsafe { ksCurSC });
if thread.tcbSchedContext != unsafe { ksCurSC } {
convert_to_mut_type_ref::<sched_context_t>(
thread.tcbSchedContext,
)
.refill_unblock_check();
}
}
possible_switch_to(thread);
} else {
set_thread_state(thread, ThreadState::ThreadStateInactive);
}
queue.ep_dequeue(thread);
}
}
}
self.set_queue(&queue);
Expand Down Expand Up @@ -495,6 +525,7 @@ impl endpoint_func for endpoint {
convert_to_mut_type_ref::<reply_t>(replyptr)
.push(sender, thread, canDonate);
} else {
sel4_common::println!("receive ipc inactive");
set_thread_state(sender, ThreadState::ThreadStateInactive);
}
} else {
Expand Down

0 comments on commit 7090ddc

Please sign in to comment.