Skip to content

Commit 236ab6e

Browse files
raoulstrackxJethro Beekman
authored and
Jethro Beekman
committed
sanitize MXCSR/FPU control registers
1 parent aeedc9d commit 236ab6e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: src/libstd/sys/sgx/abi/entry.S

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ IMAGE_BASE:
3030

3131
/* We can store a bunch of data in the gap between MXCSR and the XSAVE header */
3232

33+
/* MXCSR initialization value for ABI */
34+
.Lmxcsr_init:
35+
.int 0x1f80
36+
37+
/* x87 FPU control word initialization value for ABI */
38+
.Lfpucw_init:
39+
.int 0x037f
40+
3341
/* The following symbols point at read-only data that will be filled in by the */
3442
/* post-linker. */
3543

@@ -173,6 +181,9 @@ sgx_entry:
173181
mov %gs:tcsls_last_rsp,%r11
174182
test %r11,%r11
175183
jnz .Lusercall_ret
184+
/* reset user state */
185+
ldmxcsr .Lmxcsr_init(%rip)
186+
fldcw .Lfpucw_init(%rip)
176187
/* setup stack */
177188
mov %gs:tcsls_tos,%rsp /* initially, RSP is not set to the correct value */
178189
/* here. This is fixed below under "adjust stack". */

0 commit comments

Comments
 (0)