From ac964136b9d38c9993992497497ddabfc6605a07 Mon Sep 17 00:00:00 2001 From: ZhiQiu-Ovo Date: Mon, 15 Jul 2024 21:01:16 +0800 Subject: [PATCH] merge with mi_dev --- src/arch/aarch64/pg.rs | 14 ++++++------ src/boot/root_server.rs | 5 +---- src/compatibility.rs | 8 +++---- src/interfaces_impl/cspace.rs | 8 +++---- src/kernel/fastpath.rs | 10 ++++----- src/syscall/invocation/decode/arch/aarch64.rs | 14 ++++++------ src/syscall/invocation/decode/arch/riscv64.rs | 14 ++++++------ src/syscall/invocation/invoke_mmu_op.rs | 22 +++++++++---------- 8 files changed, 46 insertions(+), 49 deletions(-) diff --git a/src/arch/aarch64/pg.rs b/src/arch/aarch64/pg.rs index e1f15222..c08a8940 100644 --- a/src/arch/aarch64/pg.rs +++ b/src/arch/aarch64/pg.rs @@ -3,7 +3,7 @@ use sel4_common::arch::MessageLabel; use sel4_common::structures::exception_t; use sel4_common::structures::seL4_IPCBuffer; use sel4_cspace::interface::{cap_t, cte_t}; -use sel4_vspace::{pte_t, vptr_t}; +use sel4_vspace::{PTE, vptr_t}; #[repr(C)] struct lookupPGDSlot_ret_t { @@ -24,22 +24,22 @@ struct lookupPUDSlot_ret_t { } #[no_mangle] -extern "C" fn lookupPGDSlot(vspace: *mut pte_t, vptr: vptr_t) -> lookupPGDSlot_ret_t { - // which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of pte_t in this commit +extern "C" fn lookupPGDSlot(vspace: *mut PTE, vptr: vptr_t) -> lookupPGDSlot_ret_t { + // which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of PTE in this commit // ZhiyuanSue todo!("lookupPGDSlot") } #[no_mangle] -extern "C" fn lookupPDSlot(vspace: *mut pte_t, vptr: vptr_t) -> lookupPDSlot_ret_t { - // which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of pte_t in this commit +extern "C" fn lookupPDSlot(vspace: *mut PTE, vptr: vptr_t) -> lookupPDSlot_ret_t { + // which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of PTE in this commit // ZhiyuanSue todo!("lookupPDSlot") } #[no_mangle] -extern "C" fn lookupPUDSlot(vspace: *mut pte_t, vptr: vptr_t) -> lookupPUDSlot_ret_t { - // which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of pte_t in this commit +extern "C" fn lookupPUDSlot(vspace: *mut PTE, vptr: vptr_t) -> lookupPUDSlot_ret_t { + // which is realized under sel4_vspace/src/arch/aarch64/pte.rs as a member function of PTE in this commit // ZhiyuanSue todo!("lookupPUDSlot") } diff --git a/src/boot/root_server.rs b/src/boot/root_server.rs index 524fe241..bd883781 100644 --- a/src/boot/root_server.rs +++ b/src/boot/root_server.rs @@ -546,7 +546,7 @@ fn rust_create_frames_of_region( true, ); } else { - frame_cap = rust_create_unmapped_it_frame_cap(f, false); + frame_cap = create_unmapped_it_frame_cap(f, false); } if !provide_cap(root_cnode_cap, frame_cap) { @@ -575,9 +575,6 @@ unsafe fn create_bi_frame_cap(root_cnode_cap: &cap_t, pd_cap: &cap_t, vptr: usiz write_slot(ptr.add(seL4_CapBootInfoFrame), cap); } -fn rust_create_unmapped_it_frame_cap(pptr: pptr_t, _use_large: bool) -> cap_t { - cap_t::new_frame_cap(0, pptr, 0, 0, 0, 0) -} unsafe fn rust_populate_bi_frame( node_id: usize, diff --git a/src/compatibility.rs b/src/compatibility.rs index 41317b4c..ae31c12c 100644 --- a/src/compatibility.rs +++ b/src/compatibility.rs @@ -1,7 +1,7 @@ use sel4_common::structures::seL4_IPCBuffer; use sel4_cspace::interface::{cap_t, cte_t}; use sel4_task::{set_thread_state, tcb_t, ThreadState}; -use sel4_vspace::{pte_t, vptr_t}; +use sel4_vspace::{PTE, vptr_t}; #[inline] #[no_mangle] @@ -41,16 +41,16 @@ pub fn lookupIPCBuffer(isReceiver: bool, thread: *mut tcb_t) -> usize { } #[no_mangle] -pub fn pte_next(_phys_addr: usize, _is_leaf: bool) -> pte_t { +pub fn pte_next(_phys_addr: usize, _is_leaf: bool) -> PTE { panic!("should not be invoked!") } #[no_mangle] -pub fn isPTEPageTable(_pte: *mut pte_t) -> bool { +pub fn isPTEPageTable(_pte: *mut PTE) -> bool { panic!("should not be invoked!") } #[no_mangle] -pub extern "C" fn lookupPTSlot(_lvl1pt: *mut pte_t, _vptr: vptr_t) { +pub extern "C" fn lookupPTSlot(_lvl1pt: *mut PTE, _vptr: vptr_t) { panic!("should not be invoked!") } diff --git a/src/interfaces_impl/cspace.rs b/src/interfaces_impl/cspace.rs index 1c5fad86..20537c3f 100644 --- a/src/interfaces_impl/cspace.rs +++ b/src/interfaces_impl/cspace.rs @@ -11,7 +11,7 @@ use sel4_cspace::interface::{cap_t, finaliseCap_ret, CapTag}; use sel4_ipc::{endpoint_t, notification_t, Transfer}; use sel4_task::{get_currenct_thread, ksWorkUnitsCompleted, tcb_t}; use sel4_vspace::{ - asid_pool_t, asid_t, delete_asid, delete_asid_pool, find_vspace_for_asid, pte_t, unmapPage, + asid_pool_t, asid_t, delete_asid, delete_asid_pool, find_vspace_for_asid, PTE, unmapPage, }; #[cfg(target_arch = "riscv64")] @@ -41,9 +41,9 @@ pub fn Arch_finaliseCap(cap: &cap_t, final_: bool) -> finaliseCap_ret { if find_ret.status == exception_t::EXCEPTION_NONE && find_ret.vspace_root.unwrap() as usize == pte { - deleteASID(asid, pte as *mut pte_t); + deleteASID(asid, pte as *mut PTE); } else { - convert_to_mut_type_ref::(pte) + convert_to_mut_type_ref::(pte) .unmap_page_table(asid, cap.get_pt_mapped_address()); } if let Some(lookup_fault) = find_ret.lookup_fault { @@ -201,7 +201,7 @@ pub fn preemptionPoint() -> exception_t { } #[no_mangle] -pub fn deleteASID(asid: asid_t, vspace: *mut pte_t) { +pub fn deleteASID(asid: asid_t, vspace: *mut PTE) { unsafe { if let Err(lookup_fault) = delete_asid( asid, diff --git a/src/kernel/fastpath.rs b/src/kernel/fastpath.rs index 02af6f5c..f41777a6 100644 --- a/src/kernel/fastpath.rs +++ b/src/kernel/fastpath.rs @@ -75,7 +75,7 @@ pub fn endpoint_ptr_mset_epQueue_tail_state(ptr: *mut endpoint_t, tail: usize, s #[inline] #[no_mangle] -pub fn switchToThread_fp(thread: *mut tcb_t, vroot: *mut pte_t, stored_hw_asid: pte_t) { +pub fn switchToThread_fp(thread: *mut tcb_t, vroot: *mut PTE, stored_hw_asid: PTE) { let asid = stored_hw_asid.0; unsafe { #[cfg(target_arch = "riscv64")] @@ -199,8 +199,8 @@ pub fn fastpath_call(cptr: usize, msgInfo: usize) { ); fastpath_copy_mrs(length, current, dest); dest.tcbState.words[0] = ThreadState::ThreadStateRunning as usize; - let cap_pd = new_vtable.get_pt_base_ptr() as *mut pte_t; - let stored_hw_asid: pte_t = pte_t(new_vtable.get_pt_mapped_asid()); + let cap_pd = new_vtable.get_pt_base_ptr() as *mut PTE; + let stored_hw_asid: PTE = PTE(new_vtable.get_pt_mapped_asid()); switchToThread_fp(dest as *mut tcb_t, cap_pd, stored_hw_asid); info.set_caps_unwrapped(0); let msgInfo1 = info.to_word(); @@ -296,8 +296,8 @@ pub fn fastpath_reply_recv(cptr: usize, msgInfo: usize) { fastpath_copy_mrs(length, current, caller); caller.tcbState.words[0] = ThreadState::ThreadStateRunning as usize; - let cap_pd = new_vtable.get_pt_base_ptr() as *mut pte_t; - let stored_hw_asid: pte_t = pte_t(new_vtable.get_pt_mapped_asid()); + let cap_pd = new_vtable.get_pt_base_ptr() as *mut PTE; + let stored_hw_asid: PTE = PTE(new_vtable.get_pt_mapped_asid()); switchToThread_fp(caller, cap_pd, stored_hw_asid); info.set_caps_unwrapped(0); let msg_info1 = info.to_word(); diff --git a/src/syscall/invocation/decode/arch/aarch64.rs b/src/syscall/invocation/decode/arch/aarch64.rs index 88adfdb3..1a371129 100644 --- a/src/syscall/invocation/decode/arch/aarch64.rs +++ b/src/syscall/invocation/decode/arch/aarch64.rs @@ -22,7 +22,7 @@ use sel4_common::{ MASK, }; use sel4_cspace::interface::{cap_t, cte_t, CapTag}; -use sel4_vspace::{checkVPAlignment, find_vspace_for_asid, pptr_to_paddr, pte_t, vm_attributes_t}; +use sel4_vspace::{checkVPAlignment, find_vspace_for_asid, pptr_to_paddr, vm_attributes_t, PTE}; use crate::syscall::invocation::invoke_mmu_op::{ invoke_asid_control, invoke_asid_pool, invoke_huge_page_map, invoke_large_page_map, @@ -196,7 +196,7 @@ fn decode_frame_map( return exception_t::EXCEPTION_SYSCALL_ERROR; } set_thread_state(get_currenct_thread(), ThreadState::ThreadStateRestart); - let ptSlot = convert_to_mut_type_ref::(lu_ret.ptSlot as usize); + let ptSlot = convert_to_mut_type_ref::(lu_ret.ptSlot as usize); invoke_small_page_map(asid, frame_slot, ptSlot) } else if frame_size == ARM_Large_Page { let lu_ret = lvl1pt.lookup_pd_slot(vaddr); @@ -208,7 +208,7 @@ fn decode_frame_map( return exception_t::EXCEPTION_SYSCALL_ERROR; } set_thread_state(get_currenct_thread(), ThreadState::ThreadStateRestart); - let pdSlot = convert_to_mut_type_ref::(lu_ret.pdSlot as usize); + let pdSlot = convert_to_mut_type_ref::(lu_ret.pdSlot as usize); invoke_large_page_map(asid, frame_slot, pdSlot) } else if frame_size == ARM_Huge_Page { let lu_ret = lvl1pt.lookup_pud_slot(vaddr); @@ -220,7 +220,7 @@ fn decode_frame_map( return exception_t::EXCEPTION_SYSCALL_ERROR; } set_thread_state(get_currenct_thread(), ThreadState::ThreadStateRestart); - let pudSlot = convert_to_mut_type_ref::(lu_ret.pudSlot as usize); + let pudSlot = convert_to_mut_type_ref::(lu_ret.pudSlot as usize); invoke_large_page_map(asid, frame_slot, pudSlot) } else { return exception_t::EXCEPTION_SYSCALL_ERROR; @@ -294,7 +294,7 @@ fn decode_page_table_map( } return exception_t::EXCEPTION_SYSCALL_ERROR; } - let pdSlot = convert_to_mut_type_ref::(pd_ret.pdSlot as usize); + let pdSlot = convert_to_mut_type_ref::(pd_ret.pdSlot as usize); set_thread_state(get_currenct_thread(), ThreadState::ThreadStateRestart); return invoke_page_table_map(cap, pdSlot, asid, vaddr & !MASK!(PD_INDEX_OFFSET)); } else { @@ -302,7 +302,7 @@ fn decode_page_table_map( } } -fn get_vspace(lvl1pt_cap: &cap_t) -> Option<(&mut pte_t, usize)> { +fn get_vspace(lvl1pt_cap: &cap_t) -> Option<(&mut PTE, usize)> { if lvl1pt_cap.get_cap_type() != CapTag::CapPageGlobalDirectoryCap || lvl1pt_cap.get_pt_is_mapped() == asidInvalid { @@ -314,7 +314,7 @@ fn get_vspace(lvl1pt_cap: &cap_t) -> Option<(&mut pte_t, usize)> { return None; } - let lvl1pt = convert_to_mut_type_ref::(lvl1pt_cap.get_pt_base_ptr()); + let lvl1pt = convert_to_mut_type_ref::(lvl1pt_cap.get_pt_base_ptr()); let asid = lvl1pt_cap.get_pt_mapped_asid(); let find_ret = find_vspace_for_asid(asid); diff --git a/src/syscall/invocation/decode/arch/riscv64.rs b/src/syscall/invocation/decode/arch/riscv64.rs index e29babcd..05326abb 100644 --- a/src/syscall/invocation/decode/arch/riscv64.rs +++ b/src/syscall/invocation/decode/arch/riscv64.rs @@ -19,7 +19,7 @@ use sel4_common::{BIT, MASK}; use sel4_cspace::interface::{cap_t, cte_t, CapTag}; use sel4_task::{get_currenct_thread, set_thread_state, ThreadState}; use sel4_vspace::{ - checkVPAlignment, find_vspace_for_asid, get_asid_pool_by_index, pte_t, vm_attributes_t, + checkVPAlignment, find_vspace_for_asid, get_asid_pool_by_index, PTE, vm_attributes_t, }; use crate::{ @@ -294,7 +294,7 @@ fn decode_frame_map( return exception_t::EXCEPTION_SYSCALL_ERROR; } - let pt_slot = convert_to_mut_type_ref::(lu_ret.ptSlot as usize); + let pt_slot = convert_to_mut_type_ref::(lu_ret.ptSlot as usize); let frame_asid = frame_slot.cap.get_frame_mapped_asid(); if frame_asid != asidInvalid { if frame_asid != asid { @@ -315,7 +315,7 @@ fn decode_frame_map( return exception_t::EXCEPTION_SYSCALL_ERROR; } - if pt_slot.is_pte_table() { + if pt_slot.is_PTEable() { debug!("RISCVPageMap: no mapping to remap."); unsafe { current_syscall_error._type = seL4_DeleteFirst; @@ -357,7 +357,7 @@ fn decode_page_table_unmap(pt_cte: &mut cte_t) -> exception_t { if cap.get_pt_is_mapped() != 0 { let asid = cap.get_pt_mapped_asid(); let find_ret = find_vspace_for_asid(asid); - let pte_ptr = cap.get_pt_base_ptr() as *mut pte_t; + let pte_ptr = cap.get_pt_base_ptr() as *mut PTE; if find_ret.status == exception_t::EXCEPTION_NONE && find_ret.vspace_root.unwrap() == pte_ptr { @@ -411,7 +411,7 @@ fn decode_page_table_map( if let Some((lvl1pt, asid)) = get_vspace(&lvl1pt_cap) { let lu_ret = lvl1pt.lookup_pt_slot(vaddr); - let lu_slot = convert_to_mut_type_ref::(lu_ret.ptSlot as usize); + let lu_slot = convert_to_mut_type_ref::(lu_ret.ptSlot as usize); #[cfg(target_arch = "riscv64")] if lu_ret.ptBitsLeft == seL4_PageBits || lu_slot.get_valid() != 0 { debug!("RISCVPageTableMap: All objects mapped at this address"); @@ -427,7 +427,7 @@ fn decode_page_table_map( } } -fn get_vspace(lvl1pt_cap: &cap_t) -> Option<(&mut pte_t, usize)> { +fn get_vspace(lvl1pt_cap: &cap_t) -> Option<(&mut PTE, usize)> { if lvl1pt_cap.get_cap_type() != CapTag::CapPageTableCap || lvl1pt_cap.get_pt_is_mapped() == asidInvalid { @@ -439,7 +439,7 @@ fn get_vspace(lvl1pt_cap: &cap_t) -> Option<(&mut pte_t, usize)> { return None; } - let lvl1pt = convert_to_mut_type_ref::(lvl1pt_cap.get_pt_base_ptr()); + let lvl1pt = convert_to_mut_type_ref::(lvl1pt_cap.get_pt_base_ptr()); let asid = lvl1pt_cap.get_pt_mapped_asid(); let find_ret = find_vspace_for_asid(asid); diff --git a/src/syscall/invocation/invoke_mmu_op.rs b/src/syscall/invocation/invoke_mmu_op.rs index 392b5bce..28048865 100644 --- a/src/syscall/invocation/invoke_mmu_op.rs +++ b/src/syscall/invocation/invoke_mmu_op.rs @@ -13,7 +13,7 @@ use sel4_common::{ use sel4_cspace::interface::{cap_t, cte_insert, cte_t}; use sel4_task::{get_currenct_thread, set_thread_state, ThreadState}; use sel4_vspace::{ - asid_pool_t, pptr_t, pptr_to_paddr, pte_t, set_asid_pool_by_index, unmapPage, vm_attributes_t, + asid_pool_t, pptr_t, pptr_to_paddr, PTE, set_asid_pool_by_index, unmapPage, vm_attributes_t, PTEFlags, }; #[cfg(target_arch = "riscv64")] @@ -23,7 +23,7 @@ use crate::{kernel::boot::current_lookup_fault, utils::clear_memory}; pub fn invoke_page_table_unmap(cap: &mut cap_t) -> exception_t { if cap.get_pt_is_mapped() != 0 { - let pt = convert_to_mut_type_ref::(cap.get_pt_base_ptr()); + let pt = convert_to_mut_type_ref::(cap.get_pt_base_ptr()); pt.unmap_page_table(cap.get_pt_mapped_asid(), cap.get_pt_mapped_address()); clear_memory(pt.get_ptr() as *mut u8, seL4_PageTableBits) } @@ -33,19 +33,19 @@ pub fn invoke_page_table_unmap(cap: &mut cap_t) -> exception_t { pub fn invoke_page_table_map( pt_cap: &mut cap_t, - pt_slot: &mut pte_t, + pt_slot: &mut PTE, asid: usize, vaddr: usize, ) -> exception_t { let paddr = pptr_to_paddr(pt_cap.get_pt_base_ptr()); #[cfg(target_arch = "riscv64")] { - let pte = pte_t::new(paddr >> seL4_PageBits, PTEFlags::V); + let pte = PTE::new(paddr >> seL4_PageBits, PTEFlags::V); *pt_slot = pte; } #[cfg(target_arch = "aarch64")] { - let pde = pte_t::new(paddr >> seL4_PageBits, PTEFlags::VALID); + let pde = PTE::new(paddr >> seL4_PageBits, PTEFlags::VALID); *pt_slot = pde; } pt_cap.set_pt_is_mapped(1); @@ -102,7 +102,7 @@ pub fn invoke_page_map( vaddr: usize, asid: usize, attr: vm_attributes_t, - pt_slot: &mut pte_t, + pt_slot: &mut PTE, frame_slot: &mut cte_t, ) -> exception_t { let frame_vm_rights = unsafe { core::mem::transmute(frame_slot.cap.get_frame_vm_rights()) }; @@ -113,9 +113,9 @@ pub fn invoke_page_map( #[cfg(target_arch = "riscv64")] let executable = attr.get_execute_never() == 0; #[cfg(target_arch = "riscv64")] - let pte = pte_t::make_user_pte(frame_addr, executable, vm_rights); + let pte = PTE::make_user_pte(frame_addr, executable, vm_rights); #[cfg(target_arch = "aarch64")] - let pte = pte_t::make_user_pte(frame_addr, vm_rights, attr, frame_slot.cap.get_frame_size()); + let pte = PTE::make_user_pte(frame_addr, vm_rights, attr, frame_slot.cap.get_frame_size()); set_thread_state(get_currenct_thread(), ThreadState::ThreadStateRestart); pt_slot.update(pte); exception_t::EXCEPTION_NONE @@ -124,7 +124,7 @@ pub fn invoke_page_map( pub fn invoke_huge_page_map( asid: usize, frame_slot: &mut cte_t, - pudSlot: &mut pte_t, + pudSlot: &mut PTE, ) -> exception_t { exception_t::EXCEPTION_NONE } @@ -133,7 +133,7 @@ pub fn invoke_huge_page_map( pub fn invoke_large_page_map( asid: usize, frame_slot: &mut cte_t, - pdSlot: &mut pte_t, + pdSlot: &mut PTE, ) -> exception_t { exception_t::EXCEPTION_NONE } @@ -142,7 +142,7 @@ pub fn invoke_large_page_map( pub fn invoke_small_page_map( asid: usize, frame_slot: &mut cte_t, - pdSlot: &mut pte_t, + pdSlot: &mut PTE, ) -> exception_t { exception_t::EXCEPTION_NONE }