Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MXCSR configuration dependent timing #111139

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion library/std/src/sys/sgx/abi/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IMAGE_BASE:
.Lxsave_clear:
.org .+24
.Lxsave_mxcsr:
.short 0x1f80
.short 0x1fbf

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

Expand Down Expand Up @@ -178,6 +178,7 @@ sgx_entry:
mov $-1, %rax
mov $-1, %rdx
xrstor .Lxsave_clear(%rip)
lfence
mov %r10, %rdx

/* check if returning from usercall */
Expand Down Expand Up @@ -311,6 +312,9 @@ usercall:
movq $0,%gs:tcsls_last_rsp
/* restore callee-saved state, cf. "save" above */
mov %r11,%rsp
/* MCDT mitigation requires an lfence after ldmxcsr _before_ any of the affected */
/* vector instructions is used. We omit the lfence here as one is required before */
/* the jmp instruction anyway. */
ldmxcsr (%rsp)
fldcw 4(%rsp)
add $8, %rsp
Expand Down