[PAL/Linux-SGX] Use XSAVEC
or XSAVEOPT
instead of XSAVE
instruction
#1939
Labels
XSAVEC
or XSAVEOPT
instead of XSAVE
instruction
#1939
Description of the feature
Gramine-SGX currently uses the XSAVE instruction on EEXIT and XRSTOR on EENTER:
gramine/pal/src/host/linux-sgx/enclave_entry.S
Line 883 in ac61ae1
gramine/pal/src/host/linux-sgx/enclave_entry.S
Line 918 in ac61ae1
There is anecdotal evidence that optimized instructions XSAVEC and XSAVEOPT can benefit workloads that perform many EEXIT/EENTER (e.g., workloads that perform many OCALLs).
Interestingly, Intel SGX PSW already uses XSAVEC instead of XSAVE, assuming that XSAVEC is always available on SGX-supporting processors: https://github.com/intel/linux-sgx/blob/c1ceb4fe146e0feb1097dee81c7e89925443e43c/psw/urts/se_detect.cpp#L80-L81
Two more notes:
Why Gramine should implement it?
XSAVE is used on every EEXIT. Each OCALL leads to an EEXIT, as well as each return from an interrupt handler. So the overhead of saving this state can be significant.
XSAVEC and XSAVEOPT can reduce this overhead, leading to overall performance improvement in OCALL-heavy workloads, e.g. Redis.
The text was updated successfully, but these errors were encountered: