sgx_ioc_encl...remove_pages(9)
π sgx_ioc_enclave_remove_pages π
okay bestie so this is a page from the Kernel API Manual β the manpage name is sgx_ioc_encl...remove_pages(9) (yes the title got truncated in the header, iconic of it honestly) β and it's about the very last step of yeeting pages out of an SGX enclave. let's get into it π«Ά
β¨ NAME β¨
sgx_ioc_enclave_remove_pages β the handler for %SGX_IOC_ENCLAVE_REMOVE_PAGES, no cap π₯
πΈ SYNOPSIS πΈ
long sgx_ioc_enclave_remove_pages (struct sgx_encl *encl , void __user
*arg );
π ARGUMENTS π
enclβ an enclave pointer, like literally the enclave you're messing with πargβ a userspace pointer to astruct sgx_enclave_remove_pagesinstance πΈ
π¦ DESCRIPTION π¦
So this is the final step of the whole flow that removes pages from an initialized enclave. The complete flow is giving three-part season finale, and here's the order:
- The user changes the type of the pages to be removed to
SGX_PAGE_TYPE_TRIMusing theSGX_IOC_ENCLAVE_MODIFY_TYPESioctl. β¨ - The user approves the page removal by running
ENCLU[EACCEPT]from within the enclave. π§ - The user initiates the actual page removal using the
SGX_IOC_ENCLAVE_REMOVE_PAGESioctl β and that's the one handled right here, bestie. π
What happens first: remove any page table entries pointing to the page, then proceed with the actual removal of the enclave page and the data in support of it. Order matters, don't skip ahead π
β οΈ heads up: VA pages are not affected by this removal. So it's totally possible that the enclave may end up with more VA pages than needed to support all its pages. not a bug, just a little leftovers situation π
π RETURN π
0β Success, slay π-errnoβ Otherwise π
π SEE ALSO π
Kernel file ./arch/x86/kernel/cpu/sgx/ioctl.c (the source of truth, iykyk) and these lovely neighbours:
sgx_ioc_enclave_create(9)sgx_ioc_enclave_add_pages(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)
and that's the whole page, bestie β brought to you by the kernel tree at ./arch/x86/kernel/cpu/sgx, dated October 2026. go forth and remove those pages responsibly πβ¨
π¦ 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