Skip to content

Commit

Permalink
Kernel 4.20 and later: vmf_insert_pfn returns VM_FAULT_NOPAGE
Browse files Browse the repository at this point in the history
in success case

Signed-off-by: Serge Ayoun <[email protected]>
  • Loading branch information
sergeay committed Feb 5, 2019
1 parent 982c6e3 commit 56b7f9e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sgx_encl.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,11 @@ static bool sgx_process_add_page_req(struct sgx_add_page_req *req,

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
ret = vmf_insert_pfn(vma, encl_page->addr, PFN_DOWN(epc_page->pa));
if (ret != VM_FAULT_NOPAGE) {
#else
ret = vm_insert_pfn(vma, encl_page->addr, PFN_DOWN(epc_page->pa));
#endif
if (ret) {
#endif
sgx_put_backing(backing, 0);
return false;
}
Expand Down
5 changes: 4 additions & 1 deletion sgx_encl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ struct sgx_encl_page *sgx_encl_augment(struct vm_area_struct *vma,

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
ret = vmf_insert_pfn(vma, encl_page->addr, PFN_DOWN(epc_page->pa));
sgx_put_page(epc_va);
sgx_put_page(secs_va);
if (ret != VM_FAULT_NOPAGE) {
#else
ret = vm_insert_pfn(vma, encl_page->addr, PFN_DOWN(epc_page->pa));
#endif
sgx_put_page(epc_va);
sgx_put_page(secs_va);
if (ret) {
#endif
pr_err("sgx: vm_insert_pfn failure with ret=%d\n", ret);
goto out;
}
Expand Down
3 changes: 2 additions & 1 deletion sgx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,11 @@ static struct sgx_encl_page *sgx_do_fault(struct vm_area_struct *vma,

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
rc = vmf_insert_pfn(vma, entry->addr, PFN_DOWN(entry->epc_page->pa));
if (rc != VM_FAULT_NOPAGE) {
#else
rc = vm_insert_pfn(vma, entry->addr, PFN_DOWN(entry->epc_page->pa));
#endif
if (rc) {
#endif
/* Kill the enclave if vm_insert_pfn fails; failure only occurs
* if there is a driver bug or an unrecoverable issue, e.g. OOM.
*/
Expand Down

0 comments on commit 56b7f9e

Please sign in to comment.