sgx_ioc_enclave_init(9)
π sgx_ioc_enclave_init(9) β kernel API manual, bestie edition β¨
okay so this is a page from the Kernel API Manual, and it's about sgx_ioc_enclave_init(9) β the handler that does the big β¨finalβ¨ step of building an SGX enclave. come sit with me, this one's short but it SLAPS.
π NAME π
sgx_ioc_enclave_init β literally the handler for %SGX_IOC_ENCLAVE_INIT. that's it, that's the gig π«Ά
πΈ SYNOPSIS πΈ
long sgx_ioc_enclave_init (struct sgx_encl *encl , void __user *arg );
π¦ ARGUMENTS π¦
enclβ an enclave pointer. it's giving "here's the enclave, go do your thing" π§argβ a userspace pointer to astruct sgx_enclave_initinstance. yes bestie it's a __user pointer, be normal about it π
π DESCRIPTION π
so first things first: it flushes any outstanding enqueued EADD operations, then it performs EINIT. no leftovers, no stragglers, we finish our plate before dessert π
and then the fancy part β the Launch Enclave Public Key Hash MSRs are rewritten as necessary to match the enclave's MRSIGNER, which is calculated from the provided sigstruct. so the MSRs get updated to line up with whatever MRSIGNER falls out of that sigstruct, and honestly? icon behaviour π
β RETURN β
0β Success. we ate, no crumbs π-EPERMβ Invalid SIGSTRUCT π-EIOβ EINIT failed because of a power cycle π like the machine literally lost the plot mid-init-errnoβ POSIX error, the classic catch-all, iykyk
π SEE ALSO π
the kernel file lives at ./arch/x86/kernel/cpu/sgx/ioctl.c, and the whole friend group is:
sgx_ioc_enclave_create(9)sgx_ioc_enclave_add_pages(9)sgx_ioc_enclave_provision(9)sgx_enclave_restrict_permissions(9)sgx_ioc_enclave_restrict_permissions(9)sgx_enclave_modify_types(9)sgx_ioc_enclave_modify_types(9)sgx_encl_remove_pages(9)sgx_ioc_enclave_remove_pages(9)
lowkey a reminder that some of these show up twice in the original list β that's not a typo on my end, I'm keeping it real and keeping every single entry fr fr π«Ά
okay that's the page!! it comes from ./arch/x86/kernel/cpu/sgx, dated October 2026, and the page is sgx_ioc_enclave_init(9) β go forth and EINIT responsibly bestie ππ₯
π¦ 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