OSDN Git Service

x86/sgx/virt: extract sgx_vepc_remove_page
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 21 Oct 2021 20:11:54 +0000 (16:11 -0400)
committerDave Hansen <dave.hansen@linux.intel.com>
Fri, 22 Oct 2021 15:30:09 +0000 (08:30 -0700)
commitfd5128e622d7834bb3f7ee23c2bbea8db63cebaf
tree9788da90ab62f21613a53474876d045e4fd535ed
parent519d81956ee277b4419c723adfb154603c2565ba
x86/sgx/virt: extract sgx_vepc_remove_page

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.

One way to do this is to simply close and reopen the /dev/sgx_vepc file
descriptor and re-mmap the virtual EPC.  However, this is problematic
because it prevents sandboxing the userspace (for example forbidding
open() after the guest starts; this is doable with heavy use of SCM_RIGHTS
file descriptor passing).

In order to implement this, we will need a ioctl that performs
EREMOVE on all pages mapped by a /dev/sgx_vepc file descriptor:
other possibilities, such as closing and reopening the device,
are racy.

Start the implementation by creating a separate function with just
the __eremove wrapper.

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.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-2-pbonzini@redhat.com
arch/x86/kernel/cpu/sgx/virt.c