class RestrictedState

Defined at line 34 of file ../../zircon/kernel/include/kernel/restricted_state.h

Encapsulates a thread's restricted mode state.

Note everything in this class should be accessed only by the thread that it belongs to,

since there is no internal locking for efficiency reasons.

Public Methods

zx::result<ktl::unique_ptr<RestrictedState>> Create (user_out_ptr<zx_exception_report_t> exception_report_ptr)

Create a |RestrictedState| with an optional exception report pointer.

When |exception_report_ptr| is null, the exception report will be delivered

via mode state VMO. When non-null, the exception report will by copied here.

Defined at line 20 of file ../../zircon/kernel/kernel/restricted_state.cc

void RestrictedState (const RestrictedState & )

Defined at line 44 of file ../../zircon/kernel/include/kernel/restricted_state.h

void RestrictedState (RestrictedState && )

Defined at line 44 of file ../../zircon/kernel/include/kernel/restricted_state.h

RestrictedState & operator= (const RestrictedState & )

Defined at line 44 of file ../../zircon/kernel/include/kernel/restricted_state.h

RestrictedState & operator= (RestrictedState && )

Defined at line 44 of file ../../zircon/kernel/include/kernel/restricted_state.h

bool in_restricted ()

Defined at line 46 of file ../../zircon/kernel/include/kernel/restricted_state.h

uintptr_t vector_ptr ()

Defined at line 47 of file ../../zircon/kernel/include/kernel/restricted_state.h

uintptr_t context ()

Defined at line 48 of file ../../zircon/kernel/include/kernel/restricted_state.h

user_out_ptr<zx_exception_report_t> exception_report_ptr ()

Defined at line 49 of file ../../zircon/kernel/include/kernel/restricted_state.h

const ArchSavedNormalState & arch_normal_state ()

Defined at line 50 of file ../../zircon/kernel/include/kernel/restricted_state.h

ArchSavedNormalState & arch_normal_state ()

Defined at line 51 of file ../../zircon/kernel/include/kernel/restricted_state.h

template <typename T>
T * state_ptr_as ()

Defined at line 53 of file ../../zircon/kernel/include/kernel/restricted_state.h

zx_restricted_state_t * state_ptr ()

Defined at line 57 of file ../../zircon/kernel/include/kernel/restricted_state.h

void set_in_restricted (bool r)

Defined at line 61 of file ../../zircon/kernel/include/kernel/restricted_state.h

void set_vector_ptr (uintptr_t v)

Defined at line 62 of file ../../zircon/kernel/include/kernel/restricted_state.h

void set_context (uintptr_t c)

Defined at line 63 of file ../../zircon/kernel/include/kernel/restricted_state.h

void ~RestrictedState ()

Defined at line 201 of file ../../src/tests/microbenchmarks/restricted_enter.cc

fbl::RefPtr<VmObjectPaged> vmo ()

Defined at line 92 of file ../../zircon/kernel/kernel/restricted_state.cc

zx_status_t ArchValidateStatePreRestrictedEntry (const zx_restricted_state_t & state)

Each arch must fill out the following routines prefixed with Arch:

Prior to entering restricted mode, ask the arch layer to validate the saved register state is

valid. Return ZX_OK if valid.

Possible invalid states: program counter outside of user space, invalid processor flags, etc.

Defined at line 38 of file ../../zircon/kernel/arch/x86/restricted.cc

void ArchSaveStatePreRestrictedEntry (ArchSavedNormalState & state)

Just prior to entering restricted mode, give the arch layer a chance to save any state it

may need for the return trip back to normal mode into the ArchSavedNormalState state argument.

For example, the GS/FS base is saved here for x86.

Defined at line 109 of file ../../zircon/kernel/arch/x86/restricted.cc

void ArchEnterRestricted (const zx_restricted_state_t & state)

Use an architcturally-specific mechanism to directly enter user space in restricted mode.

Does not return.

Defined at line 114 of file ../../zircon/kernel/arch/x86/restricted.cc

void ArchSaveRestrictedSyscallState (zx_restricted_state_t & state, const syscall_regs_t & regs)

Having just exited from restricted mode via a syscall, save the necessary restricted mode

state from a pointer to the syscall state saved by the exception handler.

Defined at line 209 of file ../../zircon/kernel/arch/x86/restricted.cc

void ArchSaveRestrictedIframeState (zx_restricted_state_t & state, const iframe_t & frame)

Having just exited from restricted mode via an interrupt, save the necessary restricted mode

state from a pointer to the interrupt frame state saved by the exception handler.

Defined at line 237 of file ../../zircon/kernel/arch/x86/restricted.cc

void ArchSaveRestrictedExceptionState (zx_restricted_state_t & state)

Having exited from restricted mode via a synchronous exception, save the necessary

restricted mode state.

Defined at line 175 of file ../../zircon/kernel/arch/x86/restricted.cc

void ArchRedirectRestrictedExceptionToNormal (const ArchSavedNormalState & arch_state, uintptr_t vector_table, uintptr_t context, zx_restricted_reason_t reason)

Update the exception context so that we will return to normal mode to allow normal

mode to handle a restricted exception.

Defined at line 158 of file ../../zircon/kernel/arch/x86/restricted.cc

void ArchEnterFull (const ArchSavedNormalState & arch_state, uintptr_t vector_table, uintptr_t context, uint64_t code)

Enter normal mode at the address pointed to by vector_table with arguments code and context

in an architecturally specific register in an architecturally specific way.

Defined at line 268 of file ../../zircon/kernel/arch/x86/restricted.cc

void ArchDump (const zx_restricted_state_t & state)

Dump the architecturally specific state out of the restricted mode state

Defined at line 25 of file ../../zircon/kernel/arch/x86/restricted.cc

void RestrictedState (uintptr_t pc)

Defined at line 182 of file ../../src/tests/microbenchmarks/restricted_enter.cc