@@ -144,13 +144,15 @@ elf_entry:
144
144
145
145
/* This code needs to be called *after* the enclave stack has been setup. */
146
146
/* There are 3 places where this needs to happen, so this is put in a macro. */
147
- .macro sanitize_rflags
147
+ .macro entry_sanitize_final
148
148
/* Sanitize rflags received from user */
149
149
/* - DF flag: x86-64 ABI requires DF to be unset at function entry/exit */
150
150
/* - AC flag: AEX on misaligned memory accesses leaks side channel info */
151
151
pushfq
152
152
andq $~0x40400 , (%rsp )
153
153
popfq
154
+ bt $0 ,.Laborted(%rip )
155
+ jc .Lreentry_panic
154
156
.endm
155
157
156
158
.text
@@ -174,9 +176,6 @@ sgx_entry:
174
176
jz .Lskip_debug_init
175
177
mov %r10 ,%gs :tcsls_debug_panic_buf_ptr
176
178
.Lskip_debug_init:
177
- /* check for abort */
178
- bt $0 ,.Laborted(%rip )
179
- jc .Lreentry_panic
180
179
/* check if returning from usercall */
181
180
mov %gs :tcsls_last_rsp,%r11
182
181
test %r11 ,%r11
@@ -194,7 +193,7 @@ sgx_entry:
194
193
lea IMAGE_BASE(%rip ),%rax
195
194
add %rax ,%rsp
196
195
mov %rsp ,%gs :tcsls_tos
197
- sanitize_rflags
196
+ entry_sanitize_final
198
197
/* call tcs_init */
199
198
/* store caller-saved registers in callee-saved registers */
200
199
mov %rdi ,%rbx
@@ -212,7 +211,7 @@ sgx_entry:
212
211
mov %r15 ,%r9
213
212
jmp .Lafter_init
214
213
.Lskip_init:
215
- sanitize_rflags
214
+ entry_sanitize_final
216
215
.Lafter_init:
217
216
/* call into main entry point */
218
217
load_tcsls_flag_secondary_bool cx /* RCX = entry() argument: secondary: bool */
@@ -311,10 +310,10 @@ usercall:
311
310
movq $0 ,%gs :tcsls_last_rsp
312
311
/* restore callee-saved state, cf. "save" above */
313
312
mov %r11 ,%rsp
314
- sanitize_rflags
315
313
ldmxcsr (%rsp )
316
314
fldcw 4 (%rsp )
317
315
add $8 , %rsp
316
+ entry_sanitize_final
318
317
pop %rbx
319
318
pop %rbp
320
319
pop %r12
0 commit comments