sgx_alloc_epc_page(9)
π sgx_alloc_epc_page(9) β okay bestie, let's talk EPC pages β¨
So this little cutie lives in the Kernel API Manual (section 9, kernel-space only, we're not messing with userland today bestie π«Ά) and it's genuinely one of the most main character allocators in the SGX corner of the kernel. Let's get into it π
β¨ NAME β¨
sgx_alloc_epc_page β allocate an EPC page π
That's it. That's the whole vibe. It hands you an Enclave Page Cache page and you say thank you. π
πΈ SYNOPSIS πΈ
struct sgx_epc_page * sgx_alloc_epc_page (void *owner , bool reclaim );
Look at that signature. Two args, one pointer back at you, no cap. π¦
π§ ARGUMENTS π§
ownerβ the owner of the EPC page π like, who does this page belong to? That's you, bestie.reclaimβ reclaim pages if necessary π yes this is the "make it work even when we're out" switch.
π DESCRIPTION π
Okay so what actually happens: it iterates through EPC sections and borrows a free EPC page for the caller. Lowkey a whole shopping trip through the sections looking for something that's in stock ποΈβ¨
β οΈ Listen to me very carefully bestie: when a page is no longer needed it must be released with sgx_free_epc_page. Must. Not "whenever you get around to it". Not "on your way out". It's giving leak alert if you forget, and we are not doing that π
If reclaim is set to true, it directly reclaims pages when we are out of pages. Iconic, resourceful, problem-solving queen behavior fr fr. π
π¨ But β and this is the important bit β no mm's can be locked whenreclaimis set totrue. Zero. None. Don't do it. Not even playfully. That's a real-ass constraint, not a vibe check you can shrug off π
Finally, it wakes up ksgxd when the number of pages goes below the watermark β before returning back to the caller. So like, the grown-up daemon gets pinged so it can go refill the stash π and then you get your page back. Order matters, bestie. π
β RETURN β
- an EPC page on success π
-errnoon error π (you already know what that means, iykyk)
π₯ SEE ALSO π₯
Kernel file ./arch/x86/kernel/cpu/sgx/main.c and all of these absolute legends:
__sgx_alloc_epc_page(9)sgx_mark_page_reclaimable(9)sgx_unmark_page_reclaimable(9)sgx_free_epc_page(9)sgx_set_attribute(9)sgx_update_svn(9)
Go read them. All of them. I'll wait π
So yeah β that's the page π written from ./arch/x86/kernel/cpu/sgx, dated October 2026, and it's the sgx_alloc_epc_page(9) manual page, now with 100% more personality and 0% fewer facts. Slay, stay safe, and free your pages bestie π
β¨
π¦ 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