selftests/sgx: Test complete changing of page type flow
authorReinette Chatre <reinette.chatre@intel.com>
Tue, 10 May 2022 18:09:03 +0000 (11:09 -0700)
committerDave Hansen <dave.hansen@linux.intel.com>
Thu, 7 Jul 2022 17:13:04 +0000 (10:13 -0700)
commit33c5aac3bf32c3ef120ad6d2eb5c65ab64a5fec4
tree2557e70d84919f12d5af5d6a98479f106673fc80
parentb564982fda13be6314e49f2344e7c422565e34d3
selftests/sgx: Test complete changing of page type flow

Support for changing an enclave page's type enables an initialized
enclave to be expanded with support for more threads by changing the
type of a regular enclave page to that of a Thread Control Structure
(TCS).  Additionally, being able to change a TCS or regular enclave
page's type to be trimmed (SGX_PAGE_TYPE_TRIM) initiates the removal
of the page from the enclave.

Test changing page type to TCS as well as page removal flows
in two phases: In the first phase support for a new thread is
dynamically added to an initialized enclave and in the second phase
the pages associated with the new thread are removed from the enclave.
As an additional sanity check after the second phase the page used as
a TCS page during the first phase is added back as a regular page and
ensured that it can be written to (which is not possible if it was a
TCS page).

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lkml.kernel.org/r/d05b48b00338683a94dcaef9f478540fc3d6d5f9.1652137848.git.reinette.chatre@intel.com
tools/testing/selftests/sgx/load.c
tools/testing/selftests/sgx/main.c
tools/testing/selftests/sgx/main.h