From 35916e22d97c5912123ccd9fa997e2d2d71ffb41 Mon Sep 17 00:00:00 2001 From: jason-nitro Date: Mon, 4 Nov 2024 10:44:15 -0600 Subject: [PATCH] Added a block comment of description --- programs/bpf_loader/src/syscalls/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index f8b9a34333a3cd..3857120d562b7a 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -235,6 +235,14 @@ pub struct VmSlice<'a, T> { resource_type: PhantomData, } +// 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 {