lsds / sgx-lkl

SGX-LKL Library OS for running Linux applications inside of Intel SGX enclaves

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lthread _switch() only save/restore general purpose registers

bodzhang opened this issue · comments

lthread _switch() does not save/restore FP, SSE or other CPU context. If the multiple lthreads running use FP, SSE or other advanced feature set instructions, the context switch between lthreads might corrupt the CPU context.

It's known that many crypto implementations use SSE or other advanced feature set instructions for performance and security reason (for example, AES-NI based implementation to addresses certain side-channel attack risks).

I don’t believe this is a bug. The lthread switch routine is a cooperative switch and so needs only to preserve callee-save registers. In the SysV psABI For x86-64, all floating-point and vector register are caller-save. The x87 CW register may need saving.

The SSE2 CSW also probably needs saving / restoring.