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

feat: user address space functionality #246

Merged
merged 22 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7ce84c3
feat: implement `USER` permission
JonasKruckenberg Jan 17, 2025
740a25e
rename `MmapSlice` to `UserMmap`
JonasKruckenberg Jan 17, 2025
ec71fd8
typo
JonasKruckenberg Jan 17, 2025
ada9d7b
remove `UnwindSafe` bound on `catch_traps`
JonasKruckenberg Jan 18, 2025
43ed56c
remove `copy_from_user` & `copy_to_user` in favor of the more univers…
JonasKruckenberg Jan 18, 2025
1940e74
fix: clear sum when entering trap handler
JonasKruckenberg Jan 18, 2025
2c54feb
fixes
JonasKruckenberg Jan 18, 2025
2e8f064
fix riscv register field setting and clearing
JonasKruckenberg Jan 18, 2025
281f389
Update mod.rs
JonasKruckenberg Jan 18, 2025
965f005
fix: `with_user_memory_access` passthrough return value
JonasKruckenberg Jan 18, 2025
e4fbc92
refactor: use `VirtualAddress` in error type
JonasKruckenberg Jan 18, 2025
62842e4
fix: kernel counter creation
JonasKruckenberg Jan 18, 2025
c251643
more helpful assert messages
JonasKruckenberg Jan 18, 2025
b679b0d
feat: implement `core::iter::Step` for address types
JonasKruckenberg Jan 18, 2025
175749e
fix: respect `VMContext` field alignments
JonasKruckenberg Jan 18, 2025
673eeb8
feat: exit `array_to_wasm_trampoline` with trap instead of return
JonasKruckenberg Jan 18, 2025
28d4cdb
refactor: move allocator and addressspace into store
JonasKruckenberg Jan 18, 2025
e58874c
fix `UserMmap`
JonasKruckenberg Jan 18, 2025
b1ede09
run wasm tests
JonasKruckenberg Jan 18, 2025
cff2de3
correct jumpt to userspace
JonasKruckenberg Jan 18, 2025
04ae00b
fmt & clippy
JonasKruckenberg Jan 18, 2025
e1dc9fa
Update main.rs
JonasKruckenberg Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: implement core::iter::Step for address types
  • Loading branch information
JonasKruckenberg committed Jan 18, 2025
commit b679b0d9f4cfb8fc7a7ccc733ca15bad370a9bfc
1 change: 1 addition & 0 deletions kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#![feature(debug_closure_helpers)]
#![expect(internal_features, reason = "panic internals")]
#![feature(std_internals, panic_can_unwind, fmt_internals)]
#![feature(step_trait)]
#![expect(dead_code, reason = "TODO")] // TODO remove
#![expect(edition_2024_expr_fragment_specifier, reason = "vetted")]

Expand Down
36 changes: 36 additions & 0 deletions kernel/src/vm/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,38 @@ macro_rules! address_impl {
.finish()
}
}

impl core::iter::Step for $addr {
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
core::iter::Step::steps_between(&start.0, &end.0)
}

fn forward_checked(start: Self, count: usize) -> Option<Self> {
core::iter::Step::forward_checked(start.0, count).map(Self)
}

fn forward(start: Self, count: usize) -> Self {
Self(core::iter::Step::forward(start.0, count))
}

unsafe fn forward_unchecked(start: Self, count: usize) -> Self {
// Safety: checked by the caller
Self(unsafe { core::iter::Step::forward_unchecked(start.0, count) })
}

fn backward_checked(start: Self, count: usize) -> Option<Self> {
core::iter::Step::backward_checked(start.0, count).map(Self)
}

fn backward(start: Self, count: usize) -> Self {
Self(core::iter::Step::backward(start.0, count))
}

unsafe fn backward_unchecked(start: Self, count: usize) -> Self {
// Safety: checked by the caller
Self(unsafe { core::iter::Step::backward_unchecked(start.0, count) })
}
}
};
}

Expand Down Expand Up @@ -291,6 +323,9 @@ macro_rules! address_range_impl {
let b = Range::from(other.end..self.end);
((!a.is_empty()).then_some(a), (!b.is_empty()).then_some(b))
}
fn clamp(&self, range: Self) -> Self {
Range::from(self.start.max(range.start)..self.end.min(range.end))
}
};
}

Expand Down Expand Up @@ -363,6 +398,7 @@ pub trait AddressRangeExt {
fn difference(&self, other: Self) -> (Option<Self>, Option<Self>)
where
Self: Sized;
fn clamp(&self, range: Self) -> Self;
}

impl AddressRangeExt for Range<PhysicalAddress> {
Expand Down