Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSpace aarch64 相关方法移植 #23

Open
llh730 opened this issue Jul 4, 2024 · 6 comments
Open

VSpace aarch64 相关方法移植 #23

llh730 opened this issue Jul 4, 2024 · 6 comments
Assignees

Comments

@llh730
Copy link
Contributor

llh730 commented Jul 4, 2024

可以参考:src/arch/arm/64/kernel/vspace.c
已实现,可能存在bug:
map_kernel_window
write_it_asid_pool
lookup_pt_slot
findVSpaceForASID
pte_t中实现了一些功能性函数,可以具体看
即将写:
setCurrentUserVSpaceRoot
set_vm_root

@Huzhiwen1208 完成

  1. unmapPageTable DONE
  2. arch_get_n_paging DONE
  3. create_unmapped_it_frame_cap DONE
  4. activate_kernel_vspace DONE
  5. create_it_address_space DONE
@llh730 llh730 converted this from a draft issue Jul 4, 2024
@llh730 llh730 changed the title 就是淦 VS pa ce Jul 4, 2024
@llh730 llh730 changed the title VS pa ce VSpace a arch Jul 4, 2024
@llh730 llh730 changed the title VSpace a arch VSpace aarch64 相关方法移植 Jul 4, 2024
@yfblock yfblock moved this to In progress in Mi Dev Jul 4, 2024
@llh730
Copy link
Contributor Author

llh730 commented Jul 4, 2024

rust_map_kernel_window 存在bug尚未修复

@yfblock
Copy link

yfblock commented Jul 8, 2024

在 vspace 中的 armKSGlobalKernelPGD

#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalKernelPGD: [pte_t; BIT!(PT_INDEX_BITS)] =
[pte_t(0); BIT!(PT_INDEX_BITS)];
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalKernelPUD: [pte_t; BIT!(PT_INDEX_BITS)] =
[pte_t(0); BIT!(PT_INDEX_BITS)];
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalKernelPDs: [[pte_t; BIT!(PT_INDEX_BITS)]; BIT!(PT_INDEX_BITS)] =
[[pte_t(0); BIT!(PT_INDEX_BITS)]; BIT!(PT_INDEX_BITS)];
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalUserVSpace: [pte_t; BIT!(PT_INDEX_BITS)] =
[pte_t(0); BIT!(PT_INDEX_BITS)];
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalKernelPT: [pte_t; BIT!(PT_INDEX_BITS)] =
[pte_t(0); BIT!(PT_INDEX_BITS)];
没有 4k 对齐,在 mi_dev 分支的 27d930e 中修复了这个问题
pub const PageAlignedLen: usize = BIT!(PT_INDEX_BITS);
#[repr(align(4096))]
#[derive(Clone, Copy)]
pub struct PageAligned<T>([T; PageAlignedLen]);
impl<T: Copy> PageAligned<T> {
pub const fn new(v: T) -> Self {
Self([v; PageAlignedLen])
}
}
impl<T> Deref for PageAligned<T> {
type Target = [T; PageAlignedLen];
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<T> DerefMut for PageAligned<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalKernelPGD: PageAligned<pte_t> = PageAligned::new(pte_t(0));
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalKernelPUD: PageAligned<pte_t> = PageAligned::new(pte_t(0));
// #[no_mangle]
// #[link_section = ".page_table"]
// pub(crate) static mut armKSGlobalKernelPDs: [[pte_t; BIT!(PT_INDEX_BITS)]; BIT!(PT_INDEX_BITS)] =
// [[pte_t(0); BIT!(PT_INDEX_BITS)]; BIT!(PT_INDEX_BITS)];
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalKernelPDs: PageAligned<PageAligned<pte_t>> =
PageAligned::new(PageAligned::new(pte_t(0)));
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalUserVSpace: PageAligned<pte_t> = PageAligned::new(pte_t(0));
#[no_mangle]
#[link_section = ".page_table"]
pub(crate) static mut armKSGlobalKernelPT: PageAligned<pte_t> = PageAligned::new(pte_t(0));

@llh730
Copy link
Contributor Author

llh730 commented Jul 9, 2024

新的vspace.c 分工如下:

-------------------------
llh:
//APFromVMRights
//maskVMRights
map_kernel_frame
//map_kernel_window
map_it_frame_cap
//create_it_frame_cap
map_it_pt_cap
create_it_pt_cap
map_it_pd_cap
create_it_pd_cap
//arch_get_n_paging
//create_it_address_space
create_unmapped_it_frame_cap
//create_mapped_it_frame_cap
//activate_kernel_vspace
//?write_it_asid_pool
findMapForASID
//?findVSpaceForASID
lookupFrame
isVTableRoot
isValidNativeRoot
isValidVTableRoot


-------------------------
hzw:
makeUser3rdLevel
makeUser2ndLevel
makeUser1stLevel
setVMRootForFlush
pageUpperDirectoryMapped
pageDirectoryMapped
invalidateTLBByASID
invalidateTLBByASIDVA
pageTableMapped
unmapPageUpperDirectory
unmapPageDirectory
//unmapPageTable
//?unmapPage
//?deleteASID
//?deleteASIDPool
doFlush
lookupIPCBuffer
checkValidIPCBuffer  == check_ipc_buffer_valid


-------------------------
zy:
//lookupPGDSlot
//lookupPUDSlot
//lookupPDSlot
//lookupPTSlot
performVSpaceFlush
performPageDirectoryInvocationMap 
performPageDirectoryInvocationUnmap
performPageTableInvocationMap == decode_page_table_map
performPageTableInvocationUnmap == decode_page_table_unmap
performHugePageInvocationMap
performLargePageInvocationMap
performSmallPageInvocationMap
performPageInvocationUnmap
performPageFlush
performPageGetAddress
//performASIDControlInvocation == decode_asid_control
decodeARMVSpaceRootInvocation
decodeARMPageDirectoryInvocation
//decodeARMPageTableInvocation == decode_page_table_invocation
//decodeARMFrameInvocation == decode_frame_invocation
//decodeARMMMUInvocation == decode_mmu_invocation 

@yfblock
Copy link

yfblock commented Jul 12, 2024

支持 aarch64 启动到第一个 user 程序相关的 commit

seL4_c_impl.git: 00b28169595eb3e0903f8ddf357256510b470981
driver-collect: d974f8613aec34e73bc1d7d197d54f38bec0b5b3
rel4_kernel.git: 9255e9a6a894856a9e1ff4ddddde1c4501975421
sel4_common: 800dd51b60fc3934ccecb5b3b1266f668940dbc9
sel4_cspace: ee65906b8cabce801d78e921189f9c5ea4a5e0fe
sel4_ipc: e5a7e27ecdccdc9f4272bf9f74444163afef1e27
sel4_task: ced5fee03e172ee9e327f1b969483bf974bacd21
sel4_vspace: 61daada42d457ca511dd0048c72f33a9016e14f1
serial-frame: e7616371b86fe65d7464dbc0239d49f959b14d81
serial-impl-pl011: 0a821ec3476a515208c934d07515939b2340ad44
serial-impl-sbi: 1cd1af47fb1029a1b272ac59f574598bb3dad284

@yfblock
Copy link

yfblock commented Jul 13, 2024

aarch64 和 riscv64 的 exception 处理不太一样,在 fastpath 的情况下是不保存 tls 的,需要在进入 slowpath 之前保存 tls 寄存器 tpidr_el0tpidrro_el0

@ZhiQiu-ovO
Copy link

支持aarch64 seltest的各仓库commit id:

seL4_c_impl.git: a09ba320d0d0182bfa3bc6e819944a5c372455c1
driver-collect: d974f8613aec34e73bc1d7d197d54f38bec0b5b3
rel4_kernel.git: bdc98a2ec7e6e2783c045cb29cb6230c0cd4725d
sel4_common: be256e394e29142220fa55cbc62d21b7126434b3
sel4_cspace: a592624c0f82e14f4a71ba775a6e83e23b53c82f
sel4_ipc: cdd75c6945ee0bed7b1eec6cdd1d403a63fb3f80
sel4_task: 80dd33993057c2f3fd156a0a778039e7546e2fc5
sel4_vspace: a8eedeca08e1c4426ae99f6450dce4cf26e0d20f
serial-frame: e7616371b86fe65d7464dbc0239d49f959b14d81
serial-impl-pl011: 0a821ec3476a515208c934d07515939b2340ad44
serial-impl-sbi: 1cd1af47fb1029a1b272ac59f574598bb3dad284

llh730 pushed a commit that referenced this issue Dec 24, 2024
* start add some of the mcs features

* add lot's of mcs todo codes and add the new pbf of aarch64

* add the no mcs case framework

* pass the rel4_complier

* put in all the symbols

* update the fastpath_reply_recv

* try to add the riscv pbf support

* fill in the real riscv pbf

* adjust the archtecture of the timer

* add the time functions for the qemu-arm-virt and spike

* add some timer functions

* add the framework of the sched_context

* update some of the mcs functions

* continue add the sched_context part

* fix previous bugs

* try to add some code but have bugs

* fill in some of the code again

* add some boot code,but have some panics

* add the alloc root task sched context part

* update the schedule and fix the previous bug

* finish the boot part code, start debug

* update the syscall num

* add some necessery mcs codes

* continue add mcs code

* add some thing about the interrupt entry

* fix one assert

* use is_schedulable to replace the is_runable

* try to fix the handle_fault on mcs and no mcs

* fix sysgetclock bug

* successfully go into the tests

* add the framework of handle syscall

* complete the handlesyscall

* add the reply

* finish the functions of reply

* add the do reply part

* update the ci

* add the some functions

* finish fill in sched control code

* add some of the mcs feature in the handlesyscall

* pass the tcb set space function

* finish the TCBSetTimeoutEndpoint part

* update the decode sched context invocation

* try to add the decodeSchedContext_Bind code

* fix bugs

* update the rece code

* add restart part

* add the handle yield

* fix some bugs

* fix the cnode bug

* try to fix more bugs of convert

* fix bugs

* fix some bugs

* fix another bug

* add the invoke sc unbind and pass all bind tests

* fix some bugs

* add something but seems cannot fix the bugsd

* fix the bug of cancelallipc

* try to fix version

* try to fix bugs

* fix the no mcs feature bugs

* try to fix

* change dir

* Adapt dependencies

* fix a bug that might fail in riscv of cancel all ipc

* add some of the code but still cannot fix the bug

* fix the ksconsumed counting bug

* try to fix bug but fail

* try to fix more

* update

* try to fix bugs

* fix the call stack new parameter order bug

* fix another bug

* fix another bug

* try to fix bugs

* continue fix bugs

* fix the bug of sc control judge and add mcs code of cancel badged sends

* update the sc yieldto codes

* add the timeout fault data structure and code

* fix previous bug

* add complete signal mcs code, but cannot fix bugs

* update the tcb enqueue, add the mcs ep append and handle unknown syscall

* fix the do_fault_reply_transfer position bug

* seems fix the bugs

* update the ci timeout time

---------

Co-authored-by: jackhu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

No branches or pull requests

4 participants