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

Unifying physical and virtual address types across the rust OS development ecosystem. #498

Open
jounathaen opened this issue Sep 20, 2024 · 0 comments

Comments

@jounathaen
Copy link

jounathaen commented Sep 20, 2024

Hi,

I think having the semantic differentiation between a PhysicalAddress and a VirtualAddress type provides a lot of value for OS development. What I think would be even better, is to have a [Physical|Virtual]Address type that is coherent across multiple crates AND across different architectures. This could simplify the reuse of code and the compatibility between projects.

Currently, the situation looks as follows:

  • x86_64 has type definitions for this, but this can only be used on x86_64. These types are apparently widely used in rust-osdev projects (and I use them in our hypervisor as well).
  • I have copycat-ed this into our aarch64 crate to have a compatible type for aarch64. However, riscv64 etc. is still not supported. (And that crate did really not receive the required love to be adopted elsewhere (yet)).
  • rust-vmm has a similar approach with their Address Trait. They are using it for GuestAddress'es, which is a use-case for address types I have as well.
  • In the Hermit OS, we are actually using the x86 PAddr and VAddr types for x86, the types from the aforementioned aarch64 crate for the ARM architecture and a custom type for RISC-V

So I was thinking of moving the addresses into a separate crate that is not x86_64 specific anymore. The types from that crate could be used and re-exported in the x86_64 crate without changing any interfaces. I guess it is possible to make it compatible with the x86 crate's types as well. And as I'm on it, I could also implement rust-vmm's traits and add a guest physical address type as well.

However, this only makes sense if there is interest in adopting this approach. Otherwise, we'll just end up with a XKCD927 situation. So, what are your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant