From 5992881c468dfd7ef6a3cfcbe26d9d227cd1af07 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Fri, 3 May 2019 16:13:56 -0700 Subject: [PATCH] [Pal/Linux-SGX] Clear RFLAGS before calling _DkExceptionHandler This is follow up of https://github.com/oscarlab/graphene/pull/643 RFLAGS.DF must be cleared when calling a C function. --- 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 ea23bb18..abeb7050 100644 --- a/Pal/src/host/Linux-SGX/enclave_entry.S +++ b/Pal/src/host/Linux-SGX/enclave_entry.S @@ -230,6 +230,9 @@ enclave_entry: andq $STACK_ALIGN, %rsi movq %rsi, SGX_GPR_RSP(%rbx) + # clear rflags to conform the ABI which requires RFLAGS.DF = 0 + movq $0, SGX_GPR_RFLAGS(%rbx) + # new RIP is the exception handler leaq _DkExceptionHandler(%rip), %rdi movq %rdi, SGX_GPR_RIP(%rbx)