Skip to content

Commit

Permalink
add lots of debug msg
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhiQiu-ovO committed Jul 17, 2024
1 parent a99e93d commit 1820cc0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/arch/aarch64/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ extern "C" fn decodeARMMMUInvocation(
call: bool,
buffer: Option<&seL4_IPCBuffer>,
) -> exception_t {
// todo!("decodeARMMMUInvocation")
log::debug!("in decodeARMMMUInvocation");
decode_mmu_invocation(invLabel, length, cte, call, buffer)
}
25 changes: 24 additions & 1 deletion src/syscall/invocation/decode/arch/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn decode_mmu_invocation(
call: bool,
buffer: Option<&seL4_IPCBuffer>,
) -> exception_t {
log::debug!("in decode_mmu_invocation ,MessageLabel:{:?}", label);
match slot.cap.get_cap_type() {
CapTag::CapPageGlobalDirectoryCap => {
decode_vspace_root_invocation(label, length, slot, buffer)
Expand Down Expand Up @@ -140,6 +141,7 @@ fn decode_frame_map(
frame_slot: &mut cte_t,
buffer: Option<&seL4_IPCBuffer>,
) -> exception_t {
log::debug!("in decode_frame_map");
if length < 3 || get_extra_cap_by_index(0).is_none() {
debug!("ARMPageMap: Truncated message.");
unsafe {
Expand All @@ -156,21 +158,26 @@ fn decode_frame_map(
seL4_CapRights_t::from_word(get_syscall_arg(1, buffer)),
);
if let Some((vspaceRoot, asid)) = get_vspace(&vspaceRootCap) {
log::debug!("in Some((vspaceRoot, asid)) = get_vspace(&vspaceRootCap)");
let frame_size = frame_slot.cap.get_frame_size();
if unlikely(!checkVPAlignment(frame_size, vaddr)) {
unsafe {
current_syscall_error._type = seL4_AlignmentError;
}
log::debug!("out decode_frame_map, checkVPAlignment not pass");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
let frame_asid = frame_slot.cap.get_frame_mapped_asid();
log::debug!("prepare check frame_asid");
if frame_asid != asidInvalid {
log::debug!("frame_asid valid");
if frame_asid != asid {
debug!("ARMPageMap: Attempting to remap a frame that does not belong to the passed address space");
unsafe {
current_syscall_error._type = seL4_InvalidCapability;
current_syscall_error.invalidArgumentNumber = 0;
}
log::debug!("out decode_frame_map, frame_asid == asid not pass");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}

Expand All @@ -180,31 +187,38 @@ fn decode_frame_map(
current_syscall_error._type = seL4_InvalidArgument;
current_syscall_error.invalidArgumentNumber = 2;
}
log::debug!("out decode_frame_map, frame_slot.cap.get_frame_mapped_address() == vaddr not pass");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
} else {
log::debug!("frame_asid valid");
let vtop = vaddr + BIT!(pageBitsForSize(frame_size)) - 1;
if unlikely(vtop >= USER_TOP) {
unsafe {
current_syscall_error._type = seL4_InvalidArgument;
current_syscall_error.invalidArgumentNumber = 0;
}
log::debug!("out decode_frame_map, vtop < USER_TOP not pass");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
}
let base = pptr_to_paddr(frame_slot.cap.get_frame_base_ptr());

log::debug!("prepare check frame_size :{}", frame_size);
if frame_size == ARM_Small_Page {
log::debug!("in ARM_Small_Page");
let lu_ret = vspaceRoot.lookup_pt_slot(vaddr);
log::debug!("out lookup_pt_slot");
if lu_ret.status != exception_t::EXCEPTION_NONE {
unsafe {
current_syscall_error._type = seL4_FailedLookup;
current_syscall_error.failedLookupWasSource = 0;
}
log::debug!("out decode_frame_map, lu_ret.status!=exception_t::EXCEPTION_NONE");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
set_thread_state(get_currenct_thread(), ThreadState::ThreadStateRestart);
let ptSlot = convert_to_mut_type_ref::<PTE>(lu_ret.ptSlot as usize);
log::debug!("out decode_frame_map , prepare invoke_small_page_map");
invoke_small_page_map(
vaddr,
asid,
Expand All @@ -219,10 +233,12 @@ fn decode_frame_map(
current_syscall_error._type = seL4_FailedLookup;
current_syscall_error.failedLookupWasSource = 0;
}
log::debug!("out decode_frame_map, lu_ret.status!=exception_t::EXCEPTION_NONE");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
set_thread_state(get_currenct_thread(), ThreadState::ThreadStateRestart);
let pdSlot = convert_to_mut_type_ref::<PDE>(lu_ret.pdSlot as usize);
log::debug!("out decode_frame_map , prepare invoke_large_page_map");
invoke_large_page_map(
vaddr,
asid,
Expand All @@ -237,10 +253,12 @@ fn decode_frame_map(
current_syscall_error._type = seL4_FailedLookup;
current_syscall_error.failedLookupWasSource = 0;
}
log::debug!("out decode_frame_map, lu_ret.status!=exception_t::EXCEPTION_NONE");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
set_thread_state(get_currenct_thread(), ThreadState::ThreadStateRestart);
let pudSlot = convert_to_mut_type_ref::<PUDE>(lu_ret.pudSlot as usize);
log::debug!("out decode_frame_map , prepare invoke_huge_page_map");
invoke_huge_page_map(
vaddr,
asid,
Expand All @@ -249,9 +267,11 @@ fn decode_frame_map(
pudSlot,
)
} else {
log::debug!("out decode_frame_map, frame_size unknown");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
} else {
log::debug!("out decode_frame_map , in get_vspace(&lvl1pt_cap) == None");
return exception_t::EXCEPTION_SYSCALL_ERROR;
}
}
Expand All @@ -275,6 +295,7 @@ fn decode_page_table_map(
pt_cte: &mut cte_t,
buffer: Option<&seL4_IPCBuffer>,
) -> exception_t {
log::debug!("in decode_page_table_map");
if unlikely(length < 2 || get_extra_cap_by_index(0).is_none()) {
debug!("ARMPageTableMap: truncated message");
unsafe {
Expand Down Expand Up @@ -329,6 +350,7 @@ fn decode_page_table_map(
}

fn get_vspace(vspaceRootCap: &cap_t) -> Option<(&mut PGDE, usize)> {
log::debug!("in get_vspace");
if vspaceRootCap.get_cap_type() != CapTag::CapPageGlobalDirectoryCap
|| vspaceRootCap.get_pgd_is_mapped() == asidInvalid
{
Expand Down Expand Up @@ -362,6 +384,7 @@ fn get_vspace(vspaceRootCap: &cap_t) -> Option<(&mut PGDE, usize)> {
}
return None;
}
log::debug!("out get_vspace");
Some((vspaceRoot, asid))
}

Expand Down
1 change: 1 addition & 0 deletions src/syscall/invocation/decode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub fn decode_invocation(
call: bool,
buffer: Option<&seL4_IPCBuffer>,
) -> exception_t {
log::debug!("in decode_invocation");
match cap.get_cap_type() {
CapTag::CapNullCap | CapTag::CapZombieCap => {
debug!(
Expand Down
2 changes: 2 additions & 0 deletions src/syscall/invocation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::syscall::{handle_fault, lookup_extra_caps_with_buf};

#[no_mangle]
pub fn handleInvocation(isCall: bool, isBlocking: bool) -> exception_t {
log::debug!("in handleInvocation");
let thread = get_currenct_thread();
let info =
seL4_MessageInfo_t::from_word_security(thread.tcbArch.get_register(ArchReg::MsgInfo));
Expand Down Expand Up @@ -78,5 +79,6 @@ pub fn handleInvocation(isCall: bool, isBlocking: bool) -> exception_t {
}
set_thread_state(thread, ThreadState::ThreadStateRunning);
}
log::debug!("out handleInvocation");
return exception_t::EXCEPTION_NONE;
}

0 comments on commit 1820cc0

Please sign in to comment.