1. 22 Oct, 2021 2 commits
    • Paolo Bonzini's avatar
      x86/sgx/virt: implement SGX_IOC_VEPC_REMOVE ioctl · ae095b16
      Paolo Bonzini authored
      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: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20211021201155.1523989-3-pbonzini@redhat.com
      ae095b16
    • Paolo Bonzini's avatar
      x86/sgx/virt: extract sgx_vepc_remove_page · fd5128e6
      Paolo Bonzini authored
      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: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20211021201155.1523989-2-pbonzini@redhat.com
      fd5128e6
  2. 18 Oct, 2021 17 commits
  3. 17 Oct, 2021 3 commits
  4. 16 Oct, 2021 18 commits