Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote: > On Thu, Dec 07, 2017 at 02:46:39PM +0000, Christopherson, Sean J wrote: > > > + for (i = 0; i < 2; i++) { > > > + va_page = list_first_entry(&encl->va_pages, > > > + struct sgx_va_page, list); > > > + va_offset = sgx_alloc_va_slot(va_page); > > > + if (va_offset < PAGE_SIZE) > > > + break; > > > + > > > + list_move_tail(&va_page->list, &encl->va_pages); > > > + } > > > > This is broken, there is no guarantee that the next VA page will have > > a free slot. You have to walk over all VA pages to guarantee a slot > > is found, e.g. this caused EWB and ELDU errors. > > I did run some extensive stress tests on this and did not experience any > issues. Full VA pages are always put to the end. Please point me to the > test where this breaks so that I can fix the issue if it persists. Three VA pages in the enclave: A, B and C. Evict all pages in the enclave, i.e. consume all slots in A, B and C. The list can be in any order at this point, but for the sake of argument let's say the order is C->A->B, i.e. C was originally the last VA page in the list. Fault in page X, whose VA is in B. Evict X. This code looks at C and A, and finds no available slot, but continues with VA page A and a va_offset of PAGE_SIZE.