linux/arch/x86/kernel/cpu/sgx
Paolo Bonzini ae095b16fc x86/sgx/virt: implement SGX_IOC_VEPC_REMOVE ioctl
For bare-metal SGX on real hardware, the hardware provides guarantees
SGX state at reboot.  For instance, all pages start out uninitialized.
The vepc driver provides a similar guarantee today for freshly-opened
vepc instances, but guests such as Windows expect all pages to be in
uninitialized state on startup, including after every guest reboot.

Some userspace implementations of virtual SGX would rather avoid having
to close and reopen the /dev/sgx_vepc file descriptor and re-mmap the
virtual EPC.  For example, they could sandbox themselves after the guest
starts and forbid further calls to open(), in order to mitigate exploits
from untrusted guests.

Therefore, add a ioctl that does this with EREMOVE.  Userspace can
invoke the ioctl to bring its vEPC pages back to uninitialized state.
There is a possibility that some pages fail to be removed if they are
SECS pages, and the child and SECS pages could be in separate vEPC
regions.  Therefore, the ioctl returns the number of EREMOVE failures,
telling userspace to try the ioctl again after it's done with all
vEPC regions.  A more verbose description of the correct usage and
the possible error conditions is documented in sgx.rst.

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lkml.kernel.org/r/20211021201155.1523989-3-pbonzini@redhat.com
2021-10-22 08:32:12 -07:00
..
driver.c x86/sgx: Move provisioning device creation out of SGX driver 2021-04-06 19:18:46 +02:00
driver.h x86/sgx: Add SGX_IOC_ENCLAVE_PROVISION 2020-11-18 18:02:50 +01:00
encl.c x86/sgx: Correct kernel-doc's arg name in sgx_encl_release() 2021-06-11 10:42:38 +02:00
encl.h x86/sgx: use vma_lookup() in sgx_encl_find() 2021-06-29 10:53:51 -07:00
encls.h x86/sgx: Add encls_faulted() helper 2021-04-06 09:43:42 +02:00
ioctl.c x86/sgx: Move provisioning device creation out of SGX driver 2021-04-06 19:18:46 +02:00
main.c Trivial cleanups and fixes all over the place. 2021-04-26 09:25:47 -07:00
Makefile x86/sgx: Introduce virtual EPC for use by KVM guests 2021-04-06 09:43:17 +02:00
sgx.h x86/sgx: Add helper to update SGX_LEPUBKEYHASHn MSRs 2021-04-06 09:43:42 +02:00
virt.c x86/sgx/virt: implement SGX_IOC_VEPC_REMOVE ioctl 2021-10-22 08:32:12 -07:00