STRUCT SGX_ENCLAVE_RUN(9)
π struct sgx_enclave_run(9)
okay so bestie, welcome to the Kernel API Manual β¨ like yes, we're reading kernel headers today and honestly? we're thriving. this is the whole vibe of struct sgx_enclave_run β the execution context for __vdso_sgx_enter_enclave(). it's giving "backstage pass for your enclave" π
πΈ NAME πΈ
struct sgx_enclave_run β the execution context of __vdso_sgx_enter_enclave(). that's it, that's the whole name, and it ate π
π¦ SYNOPSIS π¦
like, here's the struct, copied exactly, do not touch, no edits, we respect the source π
struct sgx_enclave_run {
__u64 tcs;
__u32 function;
__u16 exception_vector;
__u16 exception_error_code;
__u64 exception_addr;
__u64 user_handler;
__u64 user_data;
__u8 reserved[216];
};
β¨ Members β¨
bestie, let's go field by field, no skipping, we do not skip here π
tcsβ the TCS used to enter the enclave. that's the ticket they check at the door ποΈfunctionβ the last seen ENCLU function, so it's one ofEENTER,ERESUMEorEEXIT. it's literally remembering what just happened, king behavior πexception_vectorβ the interrupt vector of the exception πexception_error_codeβ the exception error code, pulled straight out of the stack. scooped it up ourselves, iconic πexception_addrβ the address that triggered the exception. the scene of the crime, if you will π₯user_handlerβ a user provided callback that gets run on exception π«Άuser_dataβ the data passed to the user handler. little gift bag for your callback πreservedβ reserved for future extensions. don't touch it, it's saving that seat for someone π
π Description π
okay so this is the important part, listen up π§
If user_handler is provided, the handler will be invoked on all return paths of the normal flow. literally all of them, no skipping, the handler is main character energy π
The user handler may transfer control β e.g. via a longjmp call or a C++ exception β without returning to __vdso_sgx_enter_enclave. yep, it can just dip π¨ like it never even said bye. so don't be out here assuming it always comes back, because it fr fr might not π
π₯ SEE ALSO π₯
the whole friend group, iykyk:
- Kernel file
./arch/x86/include/uapi/asm/sgx.henumsgx_page_flags(9) struct sgx_enclave_create(9)struct sgx_enclave_add_pages(9)struct sgx_enclave_init(9)struct sgx_enclave_provision(9)struct sgx_enclave_restrict_permissions(9)struct sgx_enclave_modify_types(9)struct sgx_enclave_remove_pages(9)sgx_enclave_user_handler_t(9)vdso_sgx_enter_enclave_t(9)
alright bestie, that's the page π huge shoutout to ./arch/x86/include/uapi/asm and the October 2026 date stamp for making this possible β mwah, slay, periodt π«Άβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms