Enhance the SGX_IOC_ENCLAVE_ADD_PAGE{S} ioctl so that userspace can add multiple pages to an enclave in a single syscall. Also provide a flag that allows replicating a single source page to multiple target pages so that userspace doesn't need to allocate a giant chunk of memory when initializing things like the enlave's .bss, heap, etc... People that actually develop runtimes, please weigh in. Jarkko also suggested going with a fully flexible ioctl, e.g. essentially creating an array of the existing struct so that mrmask and/or secinfo can be unique per page. AFAICT that's overkill and more cumbersome to use as it forces userspace to allocate the full array. My understanding is that the majority of enclaves will have contiguous blocks of pages with identical mrmask and secinfo, e.g. code segments, ro data, etc..., thus the less flexible but easier-in-theory to use approach proposed here. Sean Christopherson (7): x86/sgx: Modify ADD_PAGE ioctl to take offset instead of full address selftests/x86/sgx: Update test to account for ADD_PAGE change x86/sgx: Tweak ADD_PAGE ioctl to allow adding multiple pages selftests/x86/sgx: Update enclave build flow to do multi-page add x86/sgx: Add a flag to ADD_PAGES to allow replicating the source page selftests/x86/sgx: Update selftest to account for ADD_PAGES flag selftests/x86/sgx: Add test coverage for reclaim and replicate arch/x86/include/uapi/asm/sgx.h | 25 +++++--- arch/x86/kernel/cpu/sgx/ioctl.c | 77 +++++++++++++++++------ tools/testing/selftests/x86/sgx/defines.h | 28 +++++++++ tools/testing/selftests/x86/sgx/main.c | 40 ++++++------ tools/testing/selftests/x86/sgx/sgxsign.c | 20 +++++- 5 files changed, 140 insertions(+), 50 deletions(-) -- 2.22.0