sgx_encl_may_map(9)
π NAME π
sgx_encl_may_map β bestie, this is the vibe check for whether a requested VMA mapping is actually allowed β¨
(also hi, you're reading the Kernel API Manual, welcome to the function-call side of the group chat π«Ά)
π SYNOPSIS π
int sgx_encl_may_map (struct sgx_encl *encl , unsigned long start ,
unsigned long end , vm_flags_t vm_flags );
πΈ ARGUMENTS πΈ
enclβ an enclave pointer π (yes, the whole enclave, main character energy)startβ the lower bound of the address range, and it's inclusive (sostartis invited to the party)endβ the upper bound of the address range, and it's exclusive (soendis literally not invited, no cap)vm_flagsβ the VMA flags, aka the permissions being requested π¦
π§ DESCRIPTION π§
Okay so here's what it does: it iterates through the enclave pages contained within [start, end) to verify that the permissions requested by a subset of {VM_READ, VM_WRITE, VM_EXEC} do not contain any permissions that are not contained in the build time permissions of any of the enclave pages within the given address range. π
Translation for the besties: it walks every page in that range and makes sure nobody's asking for more access than what was declared way back at build time.
An enclave creator must declare the strongest permissions that will be needed for each enclave page. This ensures that mappings have the identical or weaker permissions than the earlier declared permissions. So like β you can't just show up later and demand more than what was originally promised, that's not how this works π
β RETURN β
0on success π-EACCESotherwise π (permission said no, and honestly? fair)
π₯ SEE ALSO π₯
Kernel file ./arch/x86/kernel/cpu/sgx/encl.c β that's where the lore lives π
And the whole friend group of related functions:
reclaimer_writing_to_pcmd(9)sgx_encl_eaug_page(9)sgx_encl_release(9)sgx_encl_cpumask(9)__sgx_encl_get_backing(9)sgx_encl_alloc_backing(9)sgx_encl_lookup_backing(9)sgx_encl_put_backing(9)sgx_encl_test_and_clear_young(9)sgx_zap_enclave_ptes(9)sgx_alloc_va_page(9)sgx_alloc_va_slot(9)sgx_free_va_slot(9)sgx_va_page_full(9)sgx_encl_free_epc_page(9)
Ok that's the whole page, no skips, no summaries, we ate and left no crumbs π
Later bestie β this one shipped from ./arch/x86/kernel/cpu/sgx and it's stamped October 2026, so mark your calendar and stan responsibly ππ
π¦ 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