summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorRaoul Strackx <raoul.strackx@fortanix.com>2020-02-07 10:49:47 +0100
committerJethro Beekman <jethro@fortanix.com>2020-02-10 20:57:30 +0100
commit236ab6e6d631f073a8c3c7439af6b2ec58ce1f25 (patch)
treef66e18e5e348ffa31336b6a1484271f77bebc7a6 /src/libstd
parentaeedc9dea9e0460488e0b6ce7fe3aaf50395774c (diff)
downloadrust-236ab6e6d631f073a8c3c7439af6b2ec58ce1f25.tar.gz
rust-236ab6e6d631f073a8c3c7439af6b2ec58ce1f25.zip
sanitize MXCSR/FPU control registers
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys/sgx/abi/entry.S11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libstd/sys/sgx/abi/entry.S b/src/libstd/sys/sgx/abi/entry.S
index 7c273a8a83d..a08caec3c2b 100644
--- a/src/libstd/sys/sgx/abi/entry.S
+++ b/src/libstd/sys/sgx/abi/entry.S
@@ -30,6 +30,14 @@ IMAGE_BASE:
 
 /*  We can store a bunch of data in the gap between MXCSR and the XSAVE header */
 
+/* MXCSR initialization value for ABI */
+.Lmxcsr_init:
+    .int 0x1f80
+
+/* x87 FPU control word initialization value for ABI */
+.Lfpucw_init:
+    .int 0x037f
+
 /*  The following symbols point at read-only data that will be filled in by the */
 /*  post-linker. */
 
@@ -173,6 +181,9 @@ sgx_entry:
     mov %gs:tcsls_last_rsp,%r11
     test %r11,%r11
     jnz .Lusercall_ret
+/*  reset user state */
+    ldmxcsr .Lmxcsr_init(%rip)
+    fldcw .Lfpucw_init(%rip)
 /*  setup stack */
     mov %gs:tcsls_tos,%rsp /*  initially, RSP is not set to the correct value */
                            /*  here. This is fixed below under "adjust stack". */