STRUCT SGX_ENCLAVE_REMOVE_PAGES(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct sgx_...remove_pages(9) β€” Kernel API Manual πŸŽ€

okay bestie so this page is from the Kernel API Manual, and it's all about struct sgx_enclave_remove_pages β€” the parameter block for %SGX_IOC_ENCLAVE_REMOVE_PAGES. yes the % is literally part of the name, we don't make the rules πŸ’–


✨ NAME ✨

struct sgx_enclave_remove_pages β€” the parameter struct for %SGX_IOC_ENCLAVE_REMOVE_PAGES, no cap 🫢


🌸 SYNOPSIS 🌸

struct sgx_enclave_remove_pages {
    __u64 offset;
    __u64 length;
    __u64 count;
 };

look at her, three __u64s and a dream ✨

πŸ¦‹ Members πŸ¦‹

  • offset β€” the starting page offset. it's page aligned and it's relative to the enclave base address that's defined in SECS, okay? don't forget the SECS part, iykyk πŸ’…
  • length β€” how long the memory is. must be a multiple of the page size, periodt πŸ”₯
  • count β€” this one's (output)! it's how many bytes were successfully changed, and yup, also a multiple of page size πŸ’–

πŸ‘‘ Description πŸ‘‘

so here's the vibe: regular pages (PT_REG) or TCS pages (PT_TCS) can be removed from an initialized enclave β€” but only if the system supports SGX2. that's the vibe check right there, no cap 😭

the order of operations is literally sacred, do not freestyle this:

  1. first, hit the SGX_IOC_ENCLAVE_MODIFY_TYPES ioctl to change the page type to PT_TRIM πŸŽ€
  2. once that succeeds, run ENCLU[EACCEPT] from within the enclave 🧚
  3. and then SGX_IOC_ENCLAVE_REMOVE_PAGES can be used to complete the page removal ✨
bestie please do these in order. skip a step and it's giving chaos πŸ’€

🌈 SEE ALSO 🌈


and that's the whole page, bestie πŸ’œ this one lives at ./arch/x86/include/uapi/asm and it's dated October 2026 β€” go read it again, it's iconic πŸŽ€βœ¨

πŸ“¦ where this page comes from