On Mon, Mar 30, 2020 at 09:54:52PM +0300, Jarkko Sakkinen wrote: > sgx_encl_may_map() always succeeding when PROT_NONE is given is not that > useful behaviour as one can just well as do an anonymous mapping as > demonstrated by the change in this patch to the test program. As a > consequence, remove the special case. > > Pratically any possible way to make sure that you don't overwrite anything > useful in the memory, should be fine. MAP_FIXED does not care what's > underneath (if you want't it to care you ought to use > MAP_FIXED_NO_REPLACE). > > After this change, the selftest run called sgx_mmap() only three times > (TCS, text, data) instead of four. > > test_sgx-1811 [002] .... 586.907585: sgx_mmap <-mmap_region > test_sgx-1811 [002] .... 586.911752: sgx_mmap <-mmap_region > test_sgx-1811 [002] .... 586.911756: sgx_mmap <-mmap_region > > This also gives more angles to segregate enclave building and mapping as > the mmap()'s need to be applied only when the enclave is fully built: > > Cc: luto@xxxxxxxxxx > Cc: Haitao Huang <haitao.huang@xxxxxxxxxxxxxxx> > Cc: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> Sean, would be cool if you can try this out soonish because I'm building on top of this. I tried you vdso change on a GLK NUC and they seem to work. /Jarkko