sgx_ioc_enclave_add_pages(9)
π sgx_ioc_enclave_add_pages(9) β like, the kernel API manual, bestie β¨
okay so picture this: it's a page from the Kernel API Manual and it's all about sgx_ioc_enclave_add_pages and honestly? she's lowkey iconic. let's get into it π«Ά
πΈ NAME πΈ
sgx_ioc_enclave_add_pages β the handler for %SGX_IOC_ENCLAVE_ADD_PAGES π
β¨ SYNOPSIS β¨
long sgx_ioc_enclave_add_pages (struct sgx_encl *encl , void __user *arg
);
π ARGUMENTS π
enclβ an enclave pointer, bestie. that's the whole vibe.argβ a user pointer to astruct sgx_enclave_add_pagesinstance π¦
π DESCRIPTION π
So what she does: she adds one or more pages to an uninitialized enclave, and optionally extends the measurement with the contents of the page. and the SECINFO + the measurement mask? those get applied to all the pages. periodt. π
Now, a SECINFO for a TCS is required to always contain zero permissions, because the CPU silently zeros them π. Allowing anything else would cause a mismatch in the measurement β so like, don't.
mmap's protection bits are capped by the page permissions. For each page address, the maximum protection bits are computed with the following heuristics:
- A regular page:
PROT_R,PROT_WandPROT_Xmatch the SECINFO permissions. - A TCS page:
PROT_R | PROT_W.
mmap is not allowed to surpass the minimum of the maximum protection bits within the given address range. no cap, fr fr π
β οΈ The function deinitializes kernel data structures for enclave and returns -EIO in any of the following conditions:
- Enclave Page Cache (EPC), the physical memory holding enclaves, has been invalidated. This will cause EADD and EEXTEND to fail. π
- If the source address is corrupted somehow when executing EADD.
π₯ RETURN π₯
0: Success. slay π-EACCES: The source page is located in a noexec partition.-ENOMEM: Out of EPC pages. π-EINTR: The call was interrupted before data was processed.-EIO: Either EADD or EEXTEND failed because invalid source address or power cycle.-errno: POSIX error.
π SEE ALSO π
Kernel file ./arch/x86/kernel/cpu/sgx/ioctl.c π«
sgx_ioc_enclave_create(9)sgx_ioc_enclave_init(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)
and that's the whole page, bestie π§ ngl she lives at ./arch/x86/kernel/cpu/sgx, stamped October 2026 β go off, king ππ
π¦ 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