STRUCT SGX_ENCLAVE_REMOVE_PAGES(9)
π 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:
- first, hit the
SGX_IOC_ENCLAVE_MODIFY_TYPESioctl to change the page type toPT_TRIMπ - once that succeeds, run
ENCLU[EACCEPT]from within the enclave π§ - and then
SGX_IOC_ENCLAVE_REMOVE_PAGEScan be used to complete the page removal β¨
bestie please do these in order. skip a step and it's giving chaos π
π SEE ALSO π
- kernel file
./arch/x86/include/uapi/asm/sgx.h enum sgx_page_flags(9)struct sgx_enclave_create(9)struct sgx_enclave_add_pages(9)struct sgx_enclave_init(9)struct sgx_enclave_provision(9)struct sgx_enclave_restrict_permissions(9)struct sgx_enclave_modify_types(9)sgx_enclave_user_handler_t(9)struct sgx_enclave_run(9)vdso_sgx_enter_enclave_t(9)
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
- 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