x86/sgx: Handle VA page allocation failure for EAUG on PF.

VM_FAULT_NOPAGE is expected behaviour for -EBUSY failure path, when
augmenting a page, as this means that the reclaimer thread has been
triggered, and the intention is just to round-trip in ring-3, and
retry with a new page fault.

Fixes: 5a90d2c3f5ef ("x86/sgx: Support adding of pages to an initialized enclave")
Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20220906000221.34286-3-jarkko@kernel.org

authored by

Haitao Huang and committed by
Dave Hansen
81fa6fd1 133e049a

+4 -1
+4 -1
arch/x86/kernel/cpu/sgx/encl.c
··· 344 344 } 345 345 346 346 va_page = sgx_encl_grow(encl, false); 347 - if (IS_ERR(va_page)) 347 + if (IS_ERR(va_page)) { 348 + if (PTR_ERR(va_page) == -EBUSY) 349 + vmret = VM_FAULT_NOPAGE; 348 350 goto err_out_epc; 351 + } 349 352 350 353 if (va_page) 351 354 list_add(&va_page->list, &encl->va_pages);