From 2de42097fe425c8a3f8153143f2df7f6ebdbe06a Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Wed, 24 Apr 2019 16:37:59 -0700 Subject: [PATCH] [Pal/Linux-SGX] Clear RFLAGS.DF on enclave entry SYSV x86-64 ABI requires RFLAGS.DF to be cleared when entering a function (other flags are undefined) and we can't trust non-SGX side to do this. --- Pal/src/host/Linux-SGX/enclave_entry.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Pal/src/host/Linux-SGX/enclave_entry.S b/Pal/src/host/Linux-SGX/enclave_entry.S index 4189ea0b..458d4dd6 100644 --- a/Pal/src/host/Linux-SGX/enclave_entry.S +++ b/Pal/src/host/Linux-SGX/enclave_entry.S @@ -17,6 +17,9 @@ enclave_entry: # On EENTER/ERESUME, RAX is the current SSA, RBX is the address of TCS, # RCX is the address of AEP. Other registers are not trusted. + # x86-64 sysv abi requires %rFLAGS.DF = 0 on entry to function call. + cld + # current SSA is in RAX (Trusted) cmpq $0, %rax jne .Lhandle_resume