sgx_alloc_epc_page(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 when reclaim is set to true. 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 πŸŽ‰
  • -errno on 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:

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