On Thu, Jun 13, 2019 at 10:14:51AM -0700, Sean Christopherson wrote: > > I don't get this. The swapper takes a read lock on mm->mmap_sem, which locks > > the vma, which in turn reference counts vma->vm_file. Why is the internal > > refcount still needed? > > mmap_sem is only held when reclaim is touching PTEs, e.g. to test/clear > its accessed bit and to zap the PTE. The liveliness of the enclave needs > to be guaranteed for the entire duration of reclaim, e.g. we can't have > the enclave disappearing when we go to do EWB. It's also worth nothing > that a single reclaim may operate on more than one mmap_sem, as enclaves > can be shared across processes (mm_structs). Anyway, the takeaway I got from this is that encl->refcount does not need to be updated for VMAs (sent a patch to linux-sgx that I plan merge). /Jarkko