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

Add CapbilityPtr and Add SuccessAddr and SuccessPtr syscall variants #4174

Merged
merged 47 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
12abe15
MetaPtr + usize/u32 changes
Aug 17, 2024
c32507d
Have MetaPtr wrap a pointer not usize
Oct 14, 2024
677183f
Link to CHERI tracking issue
Oct 14, 2024
6254b9e
Add explicit return codes for usize/ptr
Oct 14, 2024
a5ee396
Better comment for MetaPtr
Oct 14, 2024
fd51098
Fix typo
Oct 14, 2024
c97deea
Apply comment suggestions
LawrenceEsswood Oct 21, 2024
291c8f4
Rename MetaPtr -> CapabilityPtr
Oct 29, 2024
695af1b
Add comment saying into_compat is for legacy only
Oct 29, 2024
7ec6bdd
capability_ptr: update doc to reflect meaning
alevy Nov 4, 2024
d0fa5fc
Update kernel/src/syscall.rs
LawrenceEsswood Nov 8, 2024
be62a66
Update kernel/src/process.rs
LawrenceEsswood Nov 8, 2024
950deb2
Revert notes change
Nov 8, 2024
236a8ac
Remove extra cast step
Nov 8, 2024
a4e5936
Preface internal Google bug tracker
Nov 8, 2024
9ac666b
Remove as_checked_ptr until CHERI lands
Nov 8, 2024
010bf22
Change panic for assert and checked alignment too
Nov 8, 2024
604460c
Make the oddly chosen ANY permission a NONE permission
Nov 8, 2024
79b2b8d
Add provenance notes
Nov 8, 2024
6feb692
Refine CapabilityPtr description slightly
Nov 8, 2024
f800ddd
Minor changes to encode
Nov 8, 2024
2cd33d2
Move capability_ptr to utilities
Nov 8, 2024
bf24e72
Update kernel/src/process.rs
LawrenceEsswood Nov 11, 2024
d569776
Rename into_compat
Nov 11, 2024
743c8cd
Document what authority the CapabilityPtr from brk/sbrk should have
Nov 11, 2024
144269e
Do not pollute scope with Execute
Nov 11, 2024
cc0b53e
Add comment to construction of intial fn
Nov 11, 2024
45f8a44
Remove mention of CHERI
Nov 11, 2024
391dfc8
Use .cast_mut(), not as
Nov 11, 2024
8f8ce44
Document all methods on CapabilityPtr
Nov 11, 2024
a5e5a6d
More formatting/comments/name change for permissions
Nov 11, 2024
f3feec6
Style changes
Nov 11, 2024
a001b33
kernel/syscall: split out encode_syscall_return, create TRD104 subset
lschuermann Nov 8, 2024
7ea663f
kernel: fix rustdoc links
lschuermann Nov 12, 2024
9560125
Merge remote-tracking branch 'upstream/master' into meta_ptr
alevy Nov 13, 2024
670a5d0
kernel: handle_syscall: elaborate on NonNull change for CapabilityPtr
lschuermann Nov 13, 2024
3810ca8
kernel/capability_ptr: make new_with_metadata an unsafe method
lschuermann Nov 13, 2024
0709e6a
kernel/arch_helpers: remove 32bit infix from encode_syscall_return_tr…
lschuermann Nov 13, 2024
1ebf509
kernel: remove CapabilityPtr aliases for now
alevy Nov 14, 2024
d23676d
kernel: remove stale reference in upcall doc
alevy Nov 14, 2024
38a5188
kernel: remove unused syscall return variant
alevy Nov 14, 2024
08caaa5
kernel: rename capability_ptr constructor
alevy Nov 14, 2024
c6156c8
kernel: documentation nits
alevy Nov 14, 2024
a803e1e
kernel: remove SuccessUsize in favor of SuccessPtr
alevy Nov 14, 2024
096536c
kernel: fix import order nit
alevy Nov 14, 2024
3c1876b
kernel: memop: add provenance to memop returns
alevy Nov 14, 2024
37cb959
Merge remote-tracking branch 'upstream/master' into meta_ptr
lschuermann Nov 14, 2024
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
kernel: remove SuccessUsize in favor of SuccessPtr
Noting that SuccessPtr can return a `CapabilityPtr` with no authority
granted.
  • Loading branch information
alevy committed Nov 14, 2024
commit a803e1e27910444d94e247129642c06a962c7189
16 changes: 8 additions & 8 deletions kernel/src/memop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ pub(crate) fn memop(process: &dyn Process, op_type: usize, r1: usize) -> Syscall
.unwrap_or(SyscallReturn::Failure(ErrorCode::NOMEM)),

// Op Type 2: Process memory start
2 => SyscallReturn::SuccessUsize(process.get_addresses().sram_start),
2 => SyscallReturn::SuccessPtr(process.get_addresses().sram_start.into()),

// Op Type 3: Process memory end
3 => SyscallReturn::SuccessUsize(process.get_addresses().sram_end),
3 => SyscallReturn::SuccessPtr(process.get_addresses().sram_end.into()),

// Op Type 4: Process flash start
4 => SyscallReturn::SuccessUsize(process.get_addresses().flash_start),
4 => SyscallReturn::SuccessPtr(process.get_addresses().flash_start.into()),

// Op Type 5: Process flash end
5 => SyscallReturn::SuccessUsize(process.get_addresses().flash_end),
5 => SyscallReturn::SuccessPtr(process.get_addresses().flash_end.into()),

// Op Type 6: Grant region begin
6 => SyscallReturn::SuccessUsize(process.get_addresses().sram_grant_start),
6 => SyscallReturn::SuccessPtr(process.get_addresses().sram_grant_start.into()),

// Op Type 7: Number of defined writeable regions in the TBF header.
7 => SyscallReturn::SuccessUsize(process.number_writeable_flash_regions()),
7 => SyscallReturn::SuccessU32(process.number_writeable_flash_regions() as u32),

// Op Type 8: The start address of the writeable region indexed by r1.
8 => {
Expand All @@ -80,7 +80,7 @@ pub(crate) fn memop(process: &dyn Process, op_type: usize, r1: usize) -> Syscall
if size == 0 {
SyscallReturn::Failure(ErrorCode::FAIL)
} else {
SyscallReturn::SuccessUsize(flash_start + offset)
SyscallReturn::SuccessPtr((flash_start + offset).into())
}
}

Expand All @@ -93,7 +93,7 @@ pub(crate) fn memop(process: &dyn Process, op_type: usize, r1: usize) -> Syscall
if size == 0 {
SyscallReturn::Failure(ErrorCode::FAIL)
} else {
SyscallReturn::SuccessUsize(flash_start + offset + size)
SyscallReturn::SuccessPtr((flash_start + offset + size).into())
}
}

Expand Down
10 changes: 3 additions & 7 deletions kernel/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,9 @@ pub enum SyscallReturn {
/// Generic success case, with an additional 32-bit and 64-bit data field
SuccessU32U64(u32, u64),

/// Generic success case, with an additional usize data field
SuccessUsize(usize),

/// Generic success case, with an additional pointer with metadata
/// On CHERI, this grants authority.
/// Access to this return is therefore privileged.
/// Generic success case, with an additional pointer.
/// This pointer may or may imply access permission to the
/// process.
SuccessPtr(CapabilityPtr),

alevy marked this conversation as resolved.
Show resolved Hide resolved
// These following types are used by the scheduler so that it can return
Expand Down Expand Up @@ -504,7 +501,6 @@ impl SyscallReturn {
SyscallReturn::AllowReadOnlyFailure(_, _, _) => false,
SyscallReturn::SubscribeFailure(_, _, _) => false,
SyscallReturn::YieldWaitFor(_, _, _) => true,
SyscallReturn::SuccessUsize(_) => true,
}
}
}
Expand Down
1 change: 0 additions & 1 deletion kernel/src/utilities/arch_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ impl TRD104SyscallReturn {
SyscallReturn::YieldWaitFor(a, b, c) => TRD104SyscallReturn::YieldWaitFor(a, b, c),

// Compatibility mapping:
SyscallReturn::SuccessUsize(a) => TRD104SyscallReturn::SuccessU32(a as u32),
SyscallReturn::SuccessPtr(a) => {
TRD104SyscallReturn::SuccessU32(a.as_ptr::<()>() as u32)
}
Expand Down
3 changes: 2 additions & 1 deletion kernel/src/utilities/capability_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ impl From<CapabilityPtr> for usize {
}

impl From<usize> for CapabilityPtr {
/// Constructs a [`CapabilityPtr`] with a given address.
/// Constructs a [`CapabilityPtr`] with a given address and no authority
///
/// Provenance note: may have null provenance.
#[inline]
fn from(from: usize) -> Self {
Expand Down
Loading