Re: [RFC PATCH 0/4] SGX shmem backing store issue

Dave Hansen
2022-05-04T23:29:04Z

On 5/4/22 15:13, Reinette Chatre wrote:
> - if (pcmd_page_empty) {
> + if (pcmd_page_empty && !pcmd_page_in_use(encl, pcmd_first_page)) {
> ida_free(&encl->pcmd_in_backing, PFN_DOWN(page_pcmd_off));
> sgx_encl_truncate_backing_page(encl, PFN_DOWN(page_pcmd_off));
> }

One other thing. The role of encl->lock here is very important.
Without it, two concurrent page faults could do their individual
memset(), each see !pcmd_page_empty, then decline to truncate the page.

Also, given the challenges here, I do think we should check the
pcmd_page after truncate to ensure it is still all zero's.