/* -*- linux-c -*- * * Try to trigger DRAM disturbance errors, as described in * * https://www.ece.cmu.edu/~safari/pubs/kim-isca14.pdf * * Copyright 2014 Pavel Machek , GPLv2+. */ #include #include #include void disturb(char *where) { unsigned int i; for (i=0; i<0x1000000; i++) { __asm__ __volatile__( "movl 0(%0), %%eax \n" \ "movl 64(%0), %%eax \n" \ "clflush 0(%0) \n" \ "clflush 64(%0) \n" \ "mfence" :: "r" (where) : "eax" ); } } int main(int argc, char *argv[]) { long size = 1*1024*1024; long i; unsigned char *mem; mem = malloc(size); memset(mem, 0xff, size); for (i=0; i<128; i+=4) disturb(mem+i); for (i=0; i