On Thu Sep 26, 2024 at 4:48 AM EEST, Jarkko Sakkinen wrote: > > 7f8f08121000-7f8f0814a000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > 7f8f0814a000-7f8f08162000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > 7f8f08162000-7f8f08177000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > 7f8f08177000-7f8f081a0000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > 7f8f081a0000-7f8f081c1000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > 7f8f081c1000-7f8f081d6000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > 7f8f081d6000-7f8f081ff000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > 7f8f081ff000-7f8f08228000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > 7f8f08228000-7f8ffffff000 ---p 00000000 00:00 0 > > 7f8ffffff000-7f9000000000 rw-s 00000000 00:05 84 /dev/sgx_enclave > > Just giving ridiculous answer to a ridiculous question. > > You clearly started commenting w/o reading the original thread. It is two years since I did my own merging algorithm in user space [1]. If I recall correctly, since SGX driver does not have vm_close() by mapping over in brk() shim you can fixup that. Obviously this needs [1] so that you can check up from somewhere that you're doing adjacent map with matching perms. If nothing is done in user space, then VMA space can literally blow up depending on the memory access pattern of the payload (in the case Enarx it is an arbitrary program compiled to wasm, the enclave includes WASM JIT as static payload). I totally get if this absolute NO for core mm. Just thinking that is SGX really the only existing location in kernel where you have: 1. pfnmap 2. bunch of regions 3. regions have varying permissions And could there be some minimal weaker set of constraints that would allow merges. Obviously it cannot be "any pfnmap" will go. If not, **** it, I don't care, that's just life ;-) Stronger than pfnmap, weaker than "struct page". [1] https://github.com/enarx/mmledger/blob/main/src/lib.rs BR, Jarkko