Skip to content

Instantly share code, notes, and snippets.

@jlisic
Created January 6, 2018 20:14
Show Gist options
  • Save jlisic/1cc6c6504e2f102efa469c20245c7b7b to your computer and use it in GitHub Desktop.
Save jlisic/1cc6c6504e2f102efa469c20245c7b7b to your computer and use it in GitHub Desktop.
A simple program that shows the impact of meltdown.
/* a simple program that invokes the kernel */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <linux/random.h>
int main() {
/* declare our data */
size_t i,n = 10000000;
void * random_buffer = NULL;
random_buffer = malloc(8);
for(i=0;i<n;i++)
syscall( SYS_getrandom, random_buffer, 8, GRND_NONBLOCK);
free(random_buffer);
return 0;
}
@jlisic
Copy link
Author

jlisic commented Jan 6, 2018

Compile as:
gcc -O1 meltdown_test.c

time run as:
time ./a.out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment