islet-project / islet

An on-device confidential computing platform
Apache License 2.0
93 stars 17 forks source link

[Draft] Pagetable with no function overriding for adopting stable rust #349

Open zpzigi754 opened 3 months ago

zpzigi754 commented 3 months ago

The purpose of this change is removing function overriding (specialization feature) in the page table implementation which prevents us from using a stable rust. Level trait bound in struct PageTable, which is the main place for function overriding, has been removed.

This PR is just for the reference; it is not aimed to be merged, because it is not the final form of page table I have in mind.

[before]

pub struct PageTable<A, L, E, const N: usize> {
     entries: [E; N],
     level: PhantomData<L>,
     address: PhantomData<A>,
}

[after]

pub struct PageTable<A, E, const N: usize> {
     entries: [E; N],
     address: PhantomData<A>,
 }
bokdeuk-jeong commented 3 months ago

I fully understand your motivation. However, level managment seems to be more of PageTable's role rather than Entry's. Could you come up with another approach?

jinbpark commented 3 months ago

Should we look at how other Rust-based OS projects deal with page table management, in the context of 1) using a minimal number of unsafe keyword, 2) using stable rust as much as possible? That might help to some extent. (Also, I'm curious about how other people do this stuff)

bokdeuk-jeong commented 3 months ago

Our code is inspired by https://os.phil-opp.com/page-tables/. With the same motivation behind your question, the projects that I have investigated thus far had simpler configurations, which are different from ours, like with a fixed root level and a predetermined number of root pages.