sgx: Reset the vEPC regions during VM reboot
commit2c3132279b9a962c27adaea53b4c8e8480385706
authorYang Zhong <yang.zhong@intel.com>
Mon, 1 Nov 2021 16:20:09 +0000 (1 12:20 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 10 Nov 2021 21:57:40 +0000 (10 22:57 +0100)
tree26b93682da34ce418950d80e112776fac80ca9d4
parentbd989ed44f847cba20b46a743770c152e188f365
sgx: Reset the vEPC regions during VM reboot

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.

Qemu 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 Qemu to try the ioctl again after it's done with all vEPC regions.

The related kernel patches:
Link: https://lkml.kernel.org/r/20211021201155.1523989-3-pbonzini@redhat.com
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
Message-Id: <20211101162009.62161-6-yang.zhong@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/i386/sgx.c