15#include <revoker/bitmap_direct.hh>
17#if !DEVICE_EXISTS(revoker) && !defined(CLANG_TIDY)
18# error Memory map was not configured with a revoker device
27 template<
typename WordT, ptraddr_t TCMBaseAddr>
34 struct RevokerInterface
59 uint32_t interruptStatus;
64 uint32_t interruptRequested;
70 __always_inline
volatile RevokerInterface &revoker_device()
75 static inline const uint32_t *interruptFutex;
95 extern char __revoker_scan_start, __export_mem_heap_end;
97 auto base = LA_ABS(__revoker_scan_start);
98 auto top = LA_ABS(__export_mem_heap_end);
99 auto &device = revoker_device();
105 Debug::Assert((device.control >> 16) == 0x5500,
106 "Device not present: {} (should be 0x55000000)",
108 Debug::Invariant(base < top,
109 "Memory map has unexpected layout, base {} is "
110 "expected to be below top {}",
120 using namespace CHERI;
124 Debug::Assert(cap.bounds() ==
sizeof(uint32_t),
125 "Interrupt futexes are not properly bounded: {}",
130 "Interrupt futexes are not properly permissioned: {}",
142 return revoker_device().epoch;
152 template<
bool AllowPartial = false>
161 std::make_signed_t<
decltype(current)> distance = current - epoch;
164 return distance >= 0;
169 Debug::Assert((epoch & 1) == 0,
"Epoch must be even");
173 decltype(distance) minimumRequired = 1 + (epoch & 1);
174 return distance > minimumRequired;
186 auto &device = revoker_device();
196 uint32_t interruptValue;
201 interruptValue = *interruptFutex;
204 __c11_atomic_signal_fence(__ATOMIC_SEQ_CST);
211 revoker_device().interruptRequested = 1;
239 return interruptFutex;
252 revoker_device().interruptRequested = 1;
257template<
typename WordT, ptraddr_t TCMBaseAddr>
Helper class for accessing capability properties on pointers.
Class encapsulating a set of permissions.
void system_bg_revoker_kick()
Start a revocation sweep.
void init()
Initialise a revoker instance.
const uint32_t * interrupt_futex()
Reveal the interrupt futex word.
void request_interrupt()
Request the delivery of an IRQ when the revoker finishes its current scan.
uint32_t has_revocation_finished_for_epoch(uint32_t epoch)
Queries whether the specified revocation epoch has finished, or, if AllowPartial is true,...
static constexpr bool IsAsynchronous
This is an asynchronous hardware revoker.
uint32_t system_epoch_get()
Returns the revocation epoch.
bool wait_for_completion(TimeoutArgument timeout, uint32_t epoch)
Block until the revocation epoch specified by epoch has completed.
Class for interacting with the shadow bitmap.
void init()
Initialise this class with a capability to the shadow bitmap.
Macros for interacting with the compartmentalisation model in CHERIoT.
#define STATIC_SEALED_VALUE(name)
Returns a sealed capability to the named object created with DECLARE_STATIC_SEALED_VALUE.
#define MMIO_CAPABILITY(type, name)
Provide a capability of the type volatile type * referring to the MMIO region exported in the linker ...
Futex (compare-and-wait) APIs.
int futex_timed_wait(TimeoutArgument timeout, const volatile uint32_t *address, uint32_t expected, uint32_t flags)
Compare the value at address to expected and, if they match, sleep the thread until a wake event is s...
This file describes the interfaces for compartments to wait for interrupts.
#define DECLARE_AND_DEFINE_INTERRUPT_CAPABILITY( name, number, mayWait, mayComplete)
Helper macro to define an interrupt capability without a separate declaration.
const uint32_t * interrupt_futex_get(InterruptCapability interruptcapability)
Request the futex associated with an interrupt.