|
CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
|
Helper class for accessing capability properties on pointers. More...
#include <cheri.hh>
Public Types | |
| using | PointerType |
Public Member Functions | |
| constexpr | Capability (std::nullptr_t) |
| Constructor from a null pointer. | |
| constexpr | Capability () |
| Default constructor, initialises with a null pointer. | |
| constexpr | Capability (decltype(ptr) p) |
| Constructor, takes an existing pointer to wrap. | |
| constexpr | Capability (const Capability &other)=default |
| Copy constructor, aliases the object that is pointed to by ptr. | |
| Capability & | operator= (const Capability &other)=default |
| Replace the pointer that this capability wraps with another. | |
| AddressProxy | address () |
| Access the address of the capability. | |
| ptraddr_t | address () const |
| Return the address as an integer from a const capability. | |
| BoundsProxy | bounds () |
| Access (read, set) the capability's bounds. | |
| ptrdiff_t | bounds () const |
| Return the bounds as an integer. | |
| PermissionsProxy | permissions () |
| Access the permissions of this capability. | |
| PermissionSet | permissions () const |
| Get a copy of the permissions from a const capability. | |
| template<std::same_as< Permission >... Permissions> | |
| void | without_permissions (Permissions... drop) |
| Remove some permissions from this capability. | |
| Capability | operator- (ptrdiff_t diff) |
| Pointer subtraction. | |
| Capability & | operator-= (ptrdiff_t diff) |
| Pointer subtraction. | |
| Capability | operator+ (ptrdiff_t diff) |
| Pointer addition. | |
| Capability & | operator+= (ptrdiff_t diff) |
| Pointer addition. | |
| bool | is_valid () const |
| Returns the tag bit indicating whether this is a valid capability. | |
| bool | is_valid_temporal () const |
| Returns the tag bit indicating whether this is a valid capability. | |
| bool | is_sealed () const |
| Return whether this is a sealed capability. | |
| uint32_t | type () const |
| Returns the type of this capability, 0 if this is not a sealed capability. | |
| ptraddr_t | base () const |
| Returns the base address of this capability. | |
| size_t | length () const |
| Returns the length of this capability. | |
| ptraddr_t | top () const |
| Returns the address of the top of this capability. | |
| constexpr std::partial_ordering | operator<=> (T *other) const |
| Capability comparison. | |
| constexpr std::partial_ordering | operator<=> (std::nullptr_t) const |
| Comparison against null pointer. | |
| constexpr bool | operator== (const Capability Other) const |
| constexpr std::partial_ordering | operator<=> (const Capability Other) const |
| Capability comparison. | |
| constexpr bool | operator== (std::nullptr_t) const |
| Equality operator, wraps the three-way compare operator. | |
| template<typename U = T> requires (!std::same_as<U, void> && !IsSealed) | |
| operator U* () const | |
| Implicit cast to the raw pointer type (unsealed version). | |
| template<typename U = T> requires (!std::same_as<U, void> && IsSealed) | |
| operator CHERI_SEALED (U *)() const | |
| Implicit cast to the raw pointer type (sealed version). | |
| operator void * () const | |
| Implicit cast to a raw pointer type. | |
| T * | operator-> () const |
| Access fields of the target as if this were a raw pointer. | |
| T * | get () const |
| Explicitly get the raw pointer. | |
| template<typename U = T> requires (!std::same_as<U, void> && !IsSealed) | |
| U & | operator* () const |
| Dereference operator. | |
| template<typename U> | |
| Capability< U, IsSealed > | cast () const |
| Cast this capability to some other type. | |
| template<typename U> | |
| bool | is_subset_of (Capability< U, IsSealed > other) const |
| Returns true if the tags of this and other match and if this conveys no rights that are not present in other. | |
| Capability< T, true > | seal (void *key) const |
| Seal this capability with the given key. | |
| Capability< T, false > | unseal (void *key) const |
| Unseal this capability with the given key. | |
| template<typename U = T> requires (!std::same_as<U, void>) | |
| U & | operator[] (size_t index) const |
| Subscript operator. | |
| bool | is_aligned (size_t align) const |
| Returns true if the capability is align-byte aligned, false otherwise. | |
| Capability & | align_down (size_t align) |
| Aligns the capability down to the nearest align-byte boundary. | |
| Capability & | align_up (size_t align) |
| Aligns the capability up to the nearest align-byte boundary. | |
Static Public Attributes | |
| static constexpr bool | IsSealed = IsSealedT |
Protected Attributes | |
| PointerType | ptr |
| The capability that this class wraps. | |
Friends | |
| class | PropertyProxyBase |
| The property proxy base is allowed to directly access the pointer that this class wraps. | |
Helper class for accessing capability properties on pointers.
| using CHERI::Capability< T, IsSealedT >::PointerType |
|
inlineconstexpr |
Constructor from a null pointer.
Definition at line 835 of file cheri.hh.
References ptr.
Referenced by align_down(), align_up(), Capability(), cast(), is_subset_of(), operator+(), operator+=(), operator-(), operator-=(), operator<=>(), operator<=>(), operator=(), seal(), and unseal().
|
inlineconstexpr |
|
inlineconstexpr |
|
inline |
Access the address of the capability.
Definition at line 851 of file cheri.hh.
Referenced by bounds(), StandardClint::init(), Revocation::BitmapDirect< WordT, TCMBaseAddr >::mark_set_one(), ds::pointer::offset(), and StandardPlic< MaxIntrID, SourceID, Priority >::StandardPlic().
|
inlinenodiscard |
|
inline |
Aligns the capability down to the nearest align-byte boundary.
Definition at line 1231 of file cheri.hh.
References Capability(), and ptr.
|
inline |
Aligns the capability up to the nearest align-byte boundary.
Definition at line 1240 of file cheri.hh.
References Capability(), and ptr.
|
inlinenodiscard |
Returns the base address of this capability.
Definition at line 1009 of file cheri.hh.
References ptr.
Referenced by Revocation::BitmapDirect< WordT, TCMBaseAddr >::mark_set_range(), and top().
|
inline |
Access (read, set) the capability's bounds.
Definition at line 867 of file cheri.hh.
Referenced by CHERI::check_pointer(), StandardClint::init(), and StandardPlic< MaxIntrID, SourceID, Priority >::StandardPlic().
|
inlinenodiscard |
|
inlinenodiscard |
Cast this capability to some other type.
Definition at line 1164 of file cheri.hh.
References Capability(), and ptr.
|
inlinenodiscard |
Explicitly get the raw pointer.
Definition at line 1144 of file cheri.hh.
References ptr.
Referenced by CHERI::check_pointer().
|
inlinenodiscard |
|
inlinenodiscard |
Return whether this is a sealed capability.
Definition at line 992 of file cheri.hh.
References ptr.
Referenced by operator<=>().
|
inlinenodiscard |
Returns true if the tags of this and other match and if this conveys no rights that are not present in other.
Returns false in all other cases.
Definition at line 1177 of file cheri.hh.
References Capability(), and ptr.
|
inlinenodiscard |
Returns the tag bit indicating whether this is a valid capability.
This returns a value subject to Common Subexpression Elimination (CSE): multiple calls to is_valid on the same capability may be optimized by the compiler into a single call. This may lead to stale results if the tag bit was cleared between the calls. See is_valid_temporal for a non-CSEable alternative.
Definition at line 955 of file cheri.hh.
References ptr.
|
inlinenodiscard |
|
inlinenodiscard |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineconstexpr |
Capability comparison.
Defines ordered comparison for capabilities with the same bounds and permissions. All other capabilities are either equivalent (identical bit pattern, including the tag bit) or unordered.
Callers may want to compare addresses, rather than capabilities, if they want a defined comparison that is stable between two objects.
Definition at line 1075 of file cheri.hh.
References Capability(), is_sealed(), and ptr.
|
inlineconstexpr |
|
inlineconstexpr |
Capability comparison.
Defines ordered comparison for capabilities with the same bounds and permissions. All other capabilities are either equivalent (identical bit pattern, including the tag bit) or unordered.
Definition at line 1040 of file cheri.hh.
References Capability().
|
inlineconstexpr |
|
inlineconstexpr |
|
inline |
|
inline |
Access the permissions of this capability.
Definition at line 883 of file cheri.hh.
Referenced by CHERI::check_pointer(), and without_permissions().
|
inlinenodiscard |
|
inlinenodiscard |
Seal this capability with the given key.
Definition at line 1185 of file cheri.hh.
References Capability(), and ptr.
|
inlinenodiscard |
Returns the address of the top of this capability.
Definition at line 1025 of file cheri.hh.
References base(), length(), and ptr.
Referenced by bounds(), Revocation::BitmapDirect< WordT, TCMBaseAddr >::mark_set_range(), and anonymous_namespace{debug.hh}::StackUsageCheck< Mode, Expected, Fn >::~StackUsageCheck().
|
inlinenodiscard |
|
inlinenodiscard |
Unseal this capability with the given key.
Definition at line 1195 of file cheri.hh.
References Capability(), and ptr.
|
inline |
Remove some permissions from this capability.
Because this function computes the permission mask by clearing bits in the PermissionSet::omnipotent() all-ones mask, rather than from the set of permissions currently held by this Capability, it is safe to use to clear Global permission on a sealed capability.
Definition at line 905 of file cheri.hh.
References CHERI::PermissionSet::omnipotent(), permissions(), and CHERI::PermissionSet::without().
|
friend |
|
staticconstexpr |
|
protected |
The capability that this class wraps.
Definition at line 490 of file cheri.hh.
Referenced by address(), align_down(), align_up(), base(), Capability(), Capability(), Capability(), cast(), get(), is_aligned(), is_sealed(), is_subset_of(), is_valid(), is_valid_temporal(), length(), operator CHERI_SEALED(), operator U*(), operator void *(), operator*(), operator+(), operator+=(), operator-(), operator-=(), operator->(), operator<=>(), operator<=>(), operator[](), permissions(), seal(), top(), type(), and unseal().