Commit dc32f426 authored by Haitao Huang's avatar Haitao Huang Committed by Zhiquan Li
Browse files

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

mainline inclusion
from mainline-v6.1-rc1
commit 81fa6fd1
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I6X1FF
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=81fa6fd13b5c43601fba8486f2385dbd7c1935e2



Intel-SIG: commit 81fa6fd1 x86/sgx: Handle VA page allocation
failure for EAUG on PF.
Incremental backporting patches for SGX on Intel Xeon platform.

--------------------------------

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: 5a90d2c3 ("x86/sgx: Support adding of pages to an initialized enclave")
Signed-off-by: default avatarHaitao Huang <haitao.huang@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Tested-by: default avatarVijay Dhanraj <vijay.dhanraj@intel.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20220906000221.34286-3-jarkko@kernel.org


[ Zhiquan: amend commit log. ]
Signed-off-by: default avatarZhiquan Li <zhiquan1.li@intel.com>
parent 16d50f53
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -344,8 +344,11 @@ static vm_fault_t sgx_encl_eaug_page(struct vm_area_struct *vma,
	}

	va_page = sgx_encl_grow(encl, false);
	if (IS_ERR(va_page))
	if (IS_ERR(va_page)) {
		if (PTR_ERR(va_page) == -EBUSY)
			vmret = VM_FAULT_NOPAGE;
		goto err_out_epc;
	}

	if (va_page)
		list_add(&va_page->list, &encl->va_pages);