Skip to content

Commit

Permalink
x86/sgx: Silence softlockup detection when releasing large enclaves
Browse files Browse the repository at this point in the history
Vijay reported that the "unclobbered_vdso_oversubscribed" selftest
triggers the softlockup detector.

Actual SGX systems have 128GB of enclave memory or more.  The
"unclobbered_vdso_oversubscribed" selftest creates one enclave which
consumes all of the enclave memory on the system. Tearing down such a
large enclave takes around a minute, most of it in the loop where
the EREMOVE instruction is applied to each individual 4k enclave page.

Spending one minute in a loop triggers the softlockup detector.

Add a cond_resched() to give other tasks a chance to run and placate
the softlockup detector.

Cc: stable@vger.kernel.org
Fixes: 1728ab5 ("x86/sgx: Add a page reclaimer")
Reported-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>  (kselftest as sanity check)
Link: https://lkml.kernel.org/r/ced01cac1e75f900251b0a4ae1150aa8ebd295ec.1644345232.git.reinette.chatre@intel.com
  • Loading branch information
Reinette Chatre authored and Dave Hansen committed Feb 10, 2022
1 parent dfd42fa commit 8795359
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/x86/kernel/cpu/sgx/encl.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ void sgx_encl_release(struct kref *ref)
}

kfree(entry);
/* Invoke scheduler to prevent soft lockups. */
cond_resched();
}

xa_destroy(&encl->page_array);
Expand Down

0 comments on commit 8795359

Please sign in to comment.