Skip to content

Remove Ptr, RawPtr, GuestPtr, Offset, AddressSpace, GuestAddressSpace #767

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Aug 5, 2025

Certain drivers used RawPtr and others used u64. To unify these in preparation for a refactor, they are replaced them with u64 instead.

The removed types were mostly unused and provided minimal benefit over a simple u64. Instead they just introduced overhead of converting to and from the pointer types. In the future we should think about introducing some type to abstract over phys/virtual addresses etc, or provide new pointer types with some security benefit like bounds checking or something else useful.

@ludfjig ludfjig added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Aug 5, 2025
Certain drivers used RawPtr and others used u64. To unify these in
preperation for a refactor, they are replaced them with u64 instead.

The removed types were mostly unused and provided minimal benefit over a simple u64. In
the future we should think about introducing some type to abstract over
phys/virtual addresses etc instead.

Signed-off-by: Ludvig Liljenberg <[email protected]>
@syntactically
Copy link
Member

syntactically commented Aug 6, 2025

In preparation for making Hyperlight more portable, one small thing from a commit series near the beginning of my big guest-CoW branch incidentally adds the types hyperlight_common::vm::{Virt,Phys}Addr, which are aliased to architecture-specific definition that are (for x86_64 and arm64) presently aliased to u64. I don't know if we ever plan to support non-64-bit targets, and the fact that they are aliases rather than newtypes makes them extremely lightweight, so they are more for documentation than anything else---but I think it does help documentation to be clear in this way when something is expecting a virtual vs. physical address. Would it be interesting to use those types instead of raw u64 here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants