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

Added VmSlice class, a slice in the virtual address space. #12

Merged
merged 7 commits into from
Dec 19, 2024
Prev Previous commit
Next Next commit
Added a block comment of description
jason-nitro committed Nov 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 35916e22d97c5912123ccd9fa997e2d2d71ffb41
8 changes: 8 additions & 0 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
@@ -235,6 +235,14 @@ pub struct VmSlice<'a, T> {
resource_type: PhantomData<T>,
}

// The VmSlice class is used for cases when you need a slice that is stored in the BPF
// interpreter's virtual address space. Because this source code can be compiled with
// addresses of different bit depths, we cannot assume that the 64-bit BPF interpreter's
// pointer sizes can be mapped to physical pointer sizes. In particular, if you need a
// slice-of-slices in the virtual space, the inner slices will be different sizes in a
// 32-bit app build than in the 64-bit virtual space. Therefore instead of a slice-of-slices,
// you should implement a slice-of-VmSlices, which can then use VmSlice::translate() to
// map to the physical address.
impl<'a, T> VmSlice<'a, T> {
pub fn new(memory_mapping: &'a MemoryMapping, ptr: u64, len: u64) -> Self {
VmSlice {