sgx_ioc_encl...remove_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 a struct sgx_enclave_remove_pages instance 🌸

πŸ¦‹ 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:

  1. The user changes the type of the pages to be removed to SGX_PAGE_TYPE_TRIM using the SGX_IOC_ENCLAVE_MODIFY_TYPES ioctl. ✨
  2. The user approves the page removal by running ENCLU[EACCEPT] from within the enclave. 🧚
  3. The user initiates the actual page removal using the SGX_IOC_ENCLAVE_REMOVE_PAGES ioctl β€” 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:


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