fix: ignore 0xffffff..
This commit is contained in:
parent
394884c1a9
commit
b2c0a86cc0
@ -1,25 +1,25 @@
|
||||
#include "include/hammer-suite.h"
|
||||
|
||||
#include "include/memory.h"
|
||||
#include "include/utils.h"
|
||||
#include "include/addr-mapper.h"
|
||||
#include "include/allocator.h"
|
||||
#include "include/dram-address.h"
|
||||
#include "include/addr-mapper.h"
|
||||
#include "include/memory.h"
|
||||
#include "include/params.h"
|
||||
#include "include/utils.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sched.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <sched.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define REFRESH_VAL "stdrefi"
|
||||
#define OUT_HEAD "f_og, f_new, vict_addr, aggr_addr\n"
|
||||
@ -60,15 +60,12 @@ int g_bk;
|
||||
FILE *out_fd = NULL;
|
||||
static uint64_t CL_SEED = 0x7bc661612e71168c;
|
||||
|
||||
static inline __attribute((always_inline))
|
||||
char *cl_rand_gen(DRAMAddr * d_addr)
|
||||
static inline __attribute((always_inline)) char *
|
||||
cl_rand_gen(DRAMAddr *d_addr)
|
||||
{
|
||||
static uint64_t cl_buff[8];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
cl_buff[i] =
|
||||
__builtin_ia32_crc32di(CL_SEED,
|
||||
(d_addr->row + d_addr->bank +
|
||||
(d_addr->col + i*8)));
|
||||
cl_buff[i] = __builtin_ia32_crc32di(CL_SEED, (d_addr->row + d_addr->bank + (d_addr->col + i * 8)));
|
||||
}
|
||||
return (char *) cl_buff;
|
||||
}
|
||||
@ -95,7 +92,8 @@ typedef struct {
|
||||
int (*hammer_test)(void *self);
|
||||
} HammerSuite;
|
||||
|
||||
char *dAddr_2_str(DRAMAddr d_addr, uint8_t fields)
|
||||
char *
|
||||
dAddr_2_str(DRAMAddr d_addr, uint8_t fields)
|
||||
{
|
||||
static char ret_str[64];
|
||||
char tmp_str[10];
|
||||
@ -107,17 +105,13 @@ char *dAddr_2_str(DRAMAddr d_addr, uint8_t fields)
|
||||
strcat(ret_str, tmp_str);
|
||||
}
|
||||
if (fields & BK_FIELD) {
|
||||
if (!first) {
|
||||
strcat(ret_str, ".");
|
||||
}
|
||||
if (!first) { strcat(ret_str, "."); }
|
||||
sprintf(tmp_str, "bk%02ld", d_addr.bank);
|
||||
strcat(ret_str, tmp_str);
|
||||
first = false;
|
||||
}
|
||||
if (fields & COL_FIELD) {
|
||||
if (!first) {
|
||||
strcat(ret_str, ".");
|
||||
}
|
||||
if (!first) { strcat(ret_str, "."); }
|
||||
sprintf(tmp_str, "col%04ld", d_addr.col);
|
||||
strcat(ret_str, tmp_str);
|
||||
first = false;
|
||||
@ -125,7 +119,8 @@ char *dAddr_2_str(DRAMAddr d_addr, uint8_t fields)
|
||||
return ret_str;
|
||||
}
|
||||
|
||||
char *hPatt_2_str(HammerPattern * h_patt, int fields)
|
||||
char *
|
||||
hPatt_2_str(HammerPattern *h_patt, int fields)
|
||||
{
|
||||
static char patt_str[256];
|
||||
char *dAddr_str;
|
||||
@ -135,86 +130,80 @@ char *hPatt_2_str(HammerPattern * h_patt, int fields)
|
||||
for (int i = 0; i < h_patt->len; i++) {
|
||||
dAddr_str = dAddr_2_str(h_patt->d_lst[i], fields);
|
||||
strcat(patt_str, dAddr_str);
|
||||
if (i + 1 != h_patt->len) {
|
||||
strcat(patt_str, "/");
|
||||
}
|
||||
|
||||
if (i + 1 != h_patt->len) { strcat(patt_str, "/"); }
|
||||
}
|
||||
return patt_str;
|
||||
}
|
||||
|
||||
void print_start_attack(HammerPattern *h_patt)
|
||||
void
|
||||
print_start_attack(HammerPattern *h_patt)
|
||||
{
|
||||
fprintf(out_fd, "%s : ", hPatt_2_str(h_patt, ROW_FIELD | BK_FIELD));
|
||||
fflush(out_fd);
|
||||
}
|
||||
|
||||
void print_end_attack()
|
||||
void
|
||||
print_end_attack()
|
||||
{
|
||||
fprintf(out_fd, "\n");
|
||||
fflush(out_fd);
|
||||
}
|
||||
|
||||
void export_flip(FlipVal * flip)
|
||||
void
|
||||
export_flip(FlipVal *flip)
|
||||
{
|
||||
if (p->g_flags & F_VERBOSE) {
|
||||
fprintf(stdout, "[FLIP] - (%02x => %02x)\t vict: %s \taggr: %s \n",
|
||||
flip->f_og, flip->f_new, dAddr_2_str(flip->d_vict, ALL_FIELDS),
|
||||
hPatt_2_str(flip->h_patt, ROW_FIELD | BK_FIELD));
|
||||
fprintf(stdout, "[FLIP] - (%02x => %02x)\t vict: %s \taggr: %s \n", flip->f_og, flip->f_new,
|
||||
dAddr_2_str(flip->d_vict, ALL_FIELDS), hPatt_2_str(flip->h_patt, ROW_FIELD | BK_FIELD));
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
#ifdef FLIPTABLE
|
||||
fprintf(out_fd, "%02x,%02x,%s ", flip->f_og, flip->f_new,
|
||||
dAddr_2_str(flip->d_vict, ALL_FIELDS));
|
||||
fprintf(out_fd, "%02x,%02x,%s ", flip->f_og, flip->f_new, dAddr_2_str(flip->d_vict, ALL_FIELDS));
|
||||
#else
|
||||
fprintf(out_fd, "%02x,%02x,%s,%s\n", flip->f_og, flip->f_new,
|
||||
dAddr_2_str(flip->d_vict, ALL_FIELDS), hPatt_2_str(flip->h_patt,
|
||||
ROW_FIELD | BK_FIELD | P_FIELD));
|
||||
fprintf(out_fd, "%02x,%02x,%s,%s\n", flip->f_og, flip->f_new, dAddr_2_str(flip->d_vict, ALL_FIELDS),
|
||||
hPatt_2_str(flip->h_patt, ROW_FIELD | BK_FIELD | P_FIELD));
|
||||
#endif
|
||||
fflush(out_fd);
|
||||
}
|
||||
|
||||
void export_cfg(HammerSuite * suite)
|
||||
void
|
||||
export_cfg(HammerSuite *suite)
|
||||
{
|
||||
SessionConfig *cfg = suite->cfg;
|
||||
|
||||
if (p->g_flags & F_VERBOSE) {
|
||||
fprintf(stdout,
|
||||
"Config: { h_cfg: %s, d_cfg: %s, h_rows: %ld, h_rounds: %ld, base: %s}\n",
|
||||
config_str[cfg->h_cfg], data_str[cfg->d_cfg],
|
||||
cfg->h_rows, cfg->h_rounds, dAddr_2_str(suite->d_base,
|
||||
ROW_FIELD |
|
||||
BK_FIELD));
|
||||
fprintf(stdout, "Config: { h_cfg: %s, d_cfg: %s, h_rows: %ld, h_rounds: %ld, base: %s}\n",
|
||||
config_str[cfg->h_cfg], data_str[cfg->d_cfg], cfg->h_rows, cfg->h_rounds,
|
||||
dAddr_2_str(suite->d_base, ROW_FIELD | BK_FIELD));
|
||||
}
|
||||
|
||||
fprintf(out_fd,
|
||||
"# { h_cfg: %s, d_cfg: %s, h_rows: %ld, h_rounds: %ld, base: %s}\n",
|
||||
config_str[cfg->h_cfg], data_str[cfg->d_cfg], cfg->h_rows,
|
||||
cfg->h_rounds, dAddr_2_str(suite->d_base,
|
||||
ROW_FIELD | BK_FIELD));
|
||||
fprintf(out_fd, "# { h_cfg: %s, d_cfg: %s, h_rows: %ld, h_rounds: %ld, base: %s}\n", config_str[cfg->h_cfg],
|
||||
data_str[cfg->d_cfg], cfg->h_rows, cfg->h_rounds, dAddr_2_str(suite->d_base, ROW_FIELD | BK_FIELD));
|
||||
fflush(out_fd);
|
||||
}
|
||||
|
||||
void swap(char **lst, int i, int j)
|
||||
void
|
||||
swap(char **lst, int i, int j)
|
||||
{
|
||||
char *tmp = lst[i];
|
||||
lst[i] = lst[j];
|
||||
lst[j] = tmp;
|
||||
}
|
||||
|
||||
int random_int(int min, int max)
|
||||
int
|
||||
random_int(int min, int max)
|
||||
{
|
||||
int number = min + rand() % (max - min);
|
||||
return number;
|
||||
}
|
||||
|
||||
uint64_t hammer_it(HammerPattern* patt, MemoryBuffer* mem) {
|
||||
uint64_t
|
||||
hammer_it(HammerPattern *patt, MemoryBuffer *mem)
|
||||
{
|
||||
|
||||
char **v_lst = (char **) malloc(sizeof(char *) * patt->len);
|
||||
for (size_t i = 0; i < patt->len; i++) {
|
||||
v_lst[i] = phys_2_virt(dram_2_phys(patt->d_lst[i]), mem);
|
||||
}
|
||||
for (size_t i = 0; i < patt->len; i++) { v_lst[i] = phys_2_virt(dram_2_phys(patt->d_lst[i]), mem); }
|
||||
|
||||
sched_yield();
|
||||
if (p->threshold > 0) {
|
||||
@ -228,26 +217,21 @@ uint64_t hammer_it(HammerPattern* patt, MemoryBuffer* mem) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint64_t cl0, cl1;
|
||||
cl0 = realtime_now();
|
||||
for (int i = 0; i < patt->rounds; i++) {
|
||||
mfence();
|
||||
for (size_t j = 0; j < patt->len; j++) {
|
||||
*(volatile char*) v_lst[j];
|
||||
}
|
||||
for (size_t j = 0; j < patt->len; j++) {
|
||||
clflushopt(v_lst[j]);
|
||||
}
|
||||
for (size_t j = 0; j < patt->len; j++) { *(volatile char *) v_lst[j]; }
|
||||
for (size_t j = 0; j < patt->len; j++) { clflushopt(v_lst[j]); }
|
||||
}
|
||||
cl1 = realtime_now();
|
||||
|
||||
free(v_lst);
|
||||
return (cl1 - cl0) / 1000000;
|
||||
|
||||
}
|
||||
|
||||
void __test_fill_random(char *addr, size_t size)
|
||||
void
|
||||
__test_fill_random(char *addr, size_t size)
|
||||
{
|
||||
int fd;
|
||||
if ((fd = open("/dev/urandom", O_RDONLY)) == -1) {
|
||||
@ -259,21 +243,21 @@ void __test_fill_random(char *addr, size_t size)
|
||||
exit(1);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
}
|
||||
|
||||
// DRAMAddr needs to be a copy in order to leave intact the original address
|
||||
void fill_stripe(DRAMAddr d_addr, uint8_t val, ADDRMapper * mapper)
|
||||
void
|
||||
fill_stripe(DRAMAddr d_addr, uint8_t val, ADDRMapper *mapper)
|
||||
{
|
||||
for (size_t col = 0; col < ROW_SIZE; col += (1 << 6)) {
|
||||
d_addr.col = col;
|
||||
DRAM_pte d_pte = get_dram_pte(mapper, &d_addr);
|
||||
memset(d_pte.v_addr, val, CL_SIZE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void fill_row(HammerSuite *suite, DRAMAddr *d_addr, HammerData data_patt, int reverse)
|
||||
void
|
||||
fill_row(HammerSuite *suite, DRAMAddr *d_addr, HammerData data_patt, int reverse)
|
||||
{
|
||||
if (p->vpat != (void *) NULL && p->tpat != (void *) NULL) {
|
||||
uint8_t pat = reverse ? *p->vpat : *p->tpat;
|
||||
@ -281,9 +265,7 @@ void fill_row(HammerSuite *suite, DRAMAddr *d_addr, HammerData data_patt, int re
|
||||
return;
|
||||
}
|
||||
|
||||
if (reverse) {
|
||||
data_patt = (HammerData)((int)data_patt ^(int)REVERSE);
|
||||
}
|
||||
if (reverse) { data_patt = (HammerData) ((int) data_patt ^ (int) REVERSE); }
|
||||
|
||||
switch (data_patt) {
|
||||
case RANDOM:
|
||||
@ -300,28 +282,28 @@ void fill_row(HammerSuite *suite, DRAMAddr *d_addr, HammerData data_patt, int re
|
||||
// exit(1);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void cl_rand_fill(DRAM_pte * pte)
|
||||
void
|
||||
cl_rand_fill(DRAM_pte *pte)
|
||||
{
|
||||
char *rand_data = cl_rand_gen(&pte->d_addr);
|
||||
memcpy(pte->v_addr, rand_data, CL_SIZE);
|
||||
}
|
||||
|
||||
uint64_t cl_rand_comp(DRAM_pte * pte)
|
||||
uint64_t
|
||||
cl_rand_comp(DRAM_pte *pte)
|
||||
{
|
||||
char *rand_data = cl_rand_gen(&pte->d_addr);
|
||||
uint64_t res = 0;
|
||||
for (int i = 0; i < CL_SIZE; i++) {
|
||||
if (*(pte->v_addr + i) != rand_data[i]) {
|
||||
res |= 1UL<<i;
|
||||
}
|
||||
if (*(pte->v_addr + i) != rand_data[i]) { res |= 1UL << i; }
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void init_random(HammerSuite * suite)
|
||||
void
|
||||
init_random(HammerSuite *suite)
|
||||
{
|
||||
int fd;
|
||||
if ((fd = open("/dev/urandom", O_RDONLY)) == -1) {
|
||||
@ -351,7 +333,8 @@ void init_random(HammerSuite * suite)
|
||||
}
|
||||
}
|
||||
|
||||
void init_stripe(HammerSuite * suite, uint8_t val)
|
||||
void
|
||||
init_stripe(HammerSuite *suite, uint8_t val)
|
||||
{
|
||||
ADDRMapper *mapper = suite->mapper;
|
||||
DRAMAddr d_tmp;
|
||||
@ -362,13 +345,14 @@ void init_stripe(HammerSuite * suite, uint8_t val)
|
||||
for (size_t col = 0; col < ROW_SIZE; col += (1 << 6)) {
|
||||
d_tmp.col = col;
|
||||
DRAM_pte d_pte = get_dram_pte(mapper, &d_tmp);
|
||||
memset(d_pte.v_addr, val, CL_SIZE);
|
||||
if (~(uint64_t) d_pte.v_addr) { memset(d_pte.v_addr, val, CL_SIZE); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_chunk(HammerSuite * suite)
|
||||
void
|
||||
init_chunk(HammerSuite *suite)
|
||||
{
|
||||
|
||||
if (p->vpat != (void *) NULL && p->tpat != (void *) NULL) {
|
||||
@ -388,14 +372,14 @@ void init_chunk(HammerSuite * suite)
|
||||
init_stripe(suite, 0x00);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "[ERROR] - Wrong data pattern %d\n",
|
||||
cfg->d_cfg);
|
||||
fprintf(stderr, "[ERROR] - Wrong data pattern %d\n", cfg->d_cfg);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void scan_random(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows)
|
||||
void
|
||||
scan_random(HammerSuite *suite, HammerPattern *h_patt, size_t adj_rows)
|
||||
{
|
||||
ADDRMapper *mapper = suite->mapper;
|
||||
SessionConfig *cfg = suite->cfg;
|
||||
@ -416,8 +400,7 @@ void scan_random(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows)
|
||||
if (res) {
|
||||
char *rand_data = cl_rand_gen(&pte.d_addr);
|
||||
for (int off = 0; off < CL_SIZE; off++) {
|
||||
if (!((res >> off) & 1))
|
||||
continue;
|
||||
if (!((res >> off) & 1)) continue;
|
||||
d_tmp.col += off;
|
||||
|
||||
flip.d_vict = d_tmp;
|
||||
@ -426,7 +409,6 @@ void scan_random(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows)
|
||||
flip.h_patt = h_patt;
|
||||
assert(flip.f_og != flip.f_new);
|
||||
export_flip(&flip);
|
||||
|
||||
}
|
||||
memcpy((char *) (pte.v_addr), rand_data, CL_SIZE);
|
||||
}
|
||||
@ -434,13 +416,15 @@ void scan_random(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows)
|
||||
}
|
||||
}
|
||||
|
||||
int find_flip(HammerSuite * suite, HammerPattern * h_patt, FlipVal *orig)
|
||||
int
|
||||
find_flip(HammerSuite *suite, HammerPattern *h_patt, FlipVal *orig)
|
||||
{
|
||||
ADDRMapper *mapper = suite->mapper;
|
||||
SessionConfig *cfg = suite->cfg;
|
||||
|
||||
DRAMAddr d_tmp;
|
||||
FlipVal flip;;
|
||||
FlipVal flip;
|
||||
;
|
||||
|
||||
d_tmp.bank = orig->d_vict.bank;
|
||||
d_tmp.row = orig->d_vict.row;
|
||||
@ -450,23 +434,22 @@ int find_flip(HammerSuite * suite, HammerPattern * h_patt, FlipVal *orig)
|
||||
clflush(pte.v_addr);
|
||||
cpuid();
|
||||
int off = cl_rand_comp(&pte);
|
||||
if (off != -1) {
|
||||
return 1;
|
||||
}
|
||||
if (off != -1) { return 1; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool in_hPatt(DRAMAddr * d_addr, HammerPattern * h_patt)
|
||||
bool
|
||||
in_hPatt(DRAMAddr *d_addr, HammerPattern *h_patt)
|
||||
{
|
||||
for (int i = 0; i < h_patt->len; i++) {
|
||||
if (d_addr_eq_row(&h_patt->d_lst[i], d_addr))
|
||||
return true;
|
||||
if (d_addr_eq_row(&h_patt->d_lst[i], d_addr)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t cl_stripe_cmp(DRAM_pte * pte, uint8_t val)
|
||||
uint64_t
|
||||
cl_stripe_cmp(DRAM_pte *pte, uint8_t val)
|
||||
{
|
||||
uint64_t res = 0;
|
||||
#ifdef POINTER_CHAISING
|
||||
@ -474,15 +457,13 @@ uint64_t cl_stripe_cmp(DRAM_pte * pte, uint8_t val)
|
||||
#else
|
||||
for (int i = 0; i < CL_SIZE; i++) {
|
||||
#endif
|
||||
if (*(uint8_t*) (pte->v_addr + i) != val) {
|
||||
res |= 1UL<<i;
|
||||
}
|
||||
if (*(uint8_t *) (pte->v_addr + i) != val) { res |= 1UL << i; }
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void scan_stripe(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows,
|
||||
uint8_t val)
|
||||
void
|
||||
scan_stripe(HammerSuite *suite, HammerPattern *h_patt, size_t adj_rows, uint8_t val)
|
||||
{
|
||||
ADDRMapper *mapper = suite->mapper;
|
||||
SessionConfig *cfg = suite->cfg;
|
||||
@ -511,8 +492,7 @@ void scan_stripe(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows,
|
||||
uint64_t res = cl_stripe_cmp(&pte, t_val);
|
||||
if (res) {
|
||||
for (int off = 0; off < CL_SIZE; off++) {
|
||||
if (!((res >> off) & 1))
|
||||
continue;
|
||||
if (!((res >> off) & 1)) continue;
|
||||
d_tmp.col += off;
|
||||
|
||||
flip.d_vict = d_tmp;
|
||||
@ -529,7 +509,8 @@ void scan_stripe(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows,
|
||||
}
|
||||
|
||||
// TODO adj_rows should tell how many rows to scan out of the bank. Not currently used
|
||||
void scan_rows(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows)
|
||||
void
|
||||
scan_rows(HammerSuite *suite, HammerPattern *h_patt, size_t adj_rows)
|
||||
{
|
||||
if (p->vpat != (void *) NULL && p->tpat != (void *) NULL) {
|
||||
scan_stripe(suite, h_patt, adj_rows, (uint8_t) *p->vpat);
|
||||
@ -549,14 +530,14 @@ void scan_rows(HammerSuite * suite, HammerPattern * h_patt, size_t adj_rows)
|
||||
scan_stripe(suite, h_patt, adj_rows, 0x00);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "[ERROR] - Wrong data pattern %d\n",
|
||||
cfg->d_cfg);
|
||||
fprintf(stderr, "[ERROR] - Wrong data pattern %d\n", cfg->d_cfg);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int free_triple_sided_test(HammerSuite * suite)
|
||||
int
|
||||
free_triple_sided_test(HammerSuite *suite)
|
||||
{
|
||||
MemoryBuffer *mem = suite->mem;
|
||||
SessionConfig *cfg = suite->cfg;
|
||||
@ -577,8 +558,7 @@ int free_triple_sided_test(HammerSuite * suite)
|
||||
h_patt.d_lst[0] = d_base;
|
||||
for (int r0 = 1; r0 < cfg->h_rows; r0++) {
|
||||
for (int r1 = r0; r1 < cfg->h_rows; r1++) {
|
||||
if (r0 == r1)
|
||||
continue;
|
||||
if (r0 == r1) continue;
|
||||
|
||||
h_patt.d_lst[1].row = h_patt.d_lst[0].row + r0;
|
||||
h_patt.d_lst[2].row = h_patt.d_lst[0].row + r1;
|
||||
@ -591,16 +571,12 @@ int free_triple_sided_test(HammerSuite * suite)
|
||||
h_patt.d_lst[1].bank = bk;
|
||||
h_patt.d_lst[2].bank = bk;
|
||||
// fill all the aggressor rows
|
||||
for (int idx = 0; idx < 3; idx++) {
|
||||
fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 0);
|
||||
}
|
||||
for (int idx = 0; idx < 3; idx++) { fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 0); }
|
||||
uint64_t time = hammer_it(&h_patt, mem);
|
||||
fprintf(stderr, "%ld ", time);
|
||||
|
||||
scan_rows(suite, &h_patt, 0);
|
||||
for (int idx = 0; idx < 3; idx++) {
|
||||
fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 1);
|
||||
}
|
||||
for (int idx = 0; idx < 3; idx++) { fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 1); }
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
@ -608,7 +584,8 @@ int free_triple_sided_test(HammerSuite * suite)
|
||||
free(h_patt.d_lst);
|
||||
}
|
||||
|
||||
int assisted_double_sided_test(HammerSuite * suite)
|
||||
int
|
||||
assisted_double_sided_test(HammerSuite *suite)
|
||||
{
|
||||
MemoryBuffer *mem = suite->mem;
|
||||
SessionConfig *cfg = suite->cfg;
|
||||
@ -630,15 +607,11 @@ int assisted_double_sided_test(HammerSuite * suite)
|
||||
for (int r0 = 1; r0 < cfg->h_rows; r0++) {
|
||||
h_patt.d_lst[1].row = d_base.row + r0;
|
||||
h_patt.d_lst[2].row = h_patt.d_lst[1].row + 2;
|
||||
h_patt.d_lst[0].row =
|
||||
d_base.row + get_rnd_int(0, cfg->h_rows - 1);
|
||||
while (h_patt.d_lst[0].row == h_patt.d_lst[1].row
|
||||
|| h_patt.d_lst[0].row == h_patt.d_lst[2].row)
|
||||
h_patt.d_lst[0].row =
|
||||
d_base.row + get_rnd_int(0, cfg->h_rows - 1);
|
||||
h_patt.d_lst[0].row = d_base.row + get_rnd_int(0, cfg->h_rows - 1);
|
||||
while (h_patt.d_lst[0].row == h_patt.d_lst[1].row || h_patt.d_lst[0].row == h_patt.d_lst[2].row)
|
||||
h_patt.d_lst[0].row = d_base.row + get_rnd_int(0, cfg->h_rows - 1);
|
||||
|
||||
if (h_patt.d_lst[2].row >= d_base.row + cfg->h_rows)
|
||||
break;
|
||||
if (h_patt.d_lst[2].row >= d_base.row + cfg->h_rows) break;
|
||||
|
||||
h_patt.d_lst[0].bank = 0;
|
||||
h_patt.d_lst[1].bank = 0;
|
||||
@ -658,16 +631,15 @@ int assisted_double_sided_test(HammerSuite * suite)
|
||||
fprintf(stderr, "%ld ", time);
|
||||
|
||||
scan_rows(suite, &h_patt, 0);
|
||||
for (int idx = 0; idx<3; idx++) {
|
||||
fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 1);
|
||||
}
|
||||
for (int idx = 0; idx < 3; idx++) { fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 1); }
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
free(h_patt.d_lst);
|
||||
}
|
||||
|
||||
int n_sided_test(HammerSuite * suite)
|
||||
int
|
||||
n_sided_test(HammerSuite *suite)
|
||||
{
|
||||
MemoryBuffer *mem = suite->mem;
|
||||
SessionConfig *cfg = suite->cfg;
|
||||
@ -697,30 +669,23 @@ int n_sided_test(HammerSuite * suite)
|
||||
h_patt.d_lst[k].row = h_patt.d_lst[k - 1].row + 2;
|
||||
h_patt.d_lst[k].bank = 0;
|
||||
}
|
||||
if (h_patt.d_lst[k - 1].row >= d_base.row + cfg->h_rows)
|
||||
break;
|
||||
if (h_patt.d_lst[k - 1].row >= d_base.row + cfg->h_rows) break;
|
||||
|
||||
fprintf(stderr, "[HAMMER] - %s: ", hPatt_2_str(&h_patt, ROW_FIELD));
|
||||
for (size_t bk = 0; bk < get_banks_cnt(); bk++) {
|
||||
|
||||
for (int s = 0; s < cfg->aggr_n; s++) {
|
||||
h_patt.d_lst[s].bank = bk;
|
||||
}
|
||||
for (int s = 0; s < cfg->aggr_n; s++) { h_patt.d_lst[s].bank = bk; }
|
||||
#ifdef FLIPTABLE
|
||||
print_start_attack(&h_patt);
|
||||
#endif
|
||||
// fill all the aggressor rows
|
||||
for (int idx = 0; idx < cfg->aggr_n; idx++) {
|
||||
fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 0);
|
||||
}
|
||||
for (int idx = 0; idx < cfg->aggr_n; idx++) { fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 0); }
|
||||
|
||||
uint64_t time = hammer_it(&h_patt, mem);
|
||||
fprintf(stderr, "%ld ", time);
|
||||
|
||||
scan_rows(suite, &h_patt, 0);
|
||||
for (int idx = 0; idx<h_patt.len; idx++) {
|
||||
fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 1);
|
||||
}
|
||||
for (int idx = 0; idx < h_patt.len; idx++) { fill_row(suite, &h_patt.d_lst[idx], cfg->d_cfg, 1); }
|
||||
#ifdef FLIPTABLE
|
||||
print_end_attack();
|
||||
#endif
|
||||
@ -730,7 +695,8 @@ int n_sided_test(HammerSuite * suite)
|
||||
free(h_patt.d_lst);
|
||||
}
|
||||
|
||||
void fuzz(HammerSuite *suite, int d, int v)
|
||||
void
|
||||
fuzz(HammerSuite *suite, int d, int v)
|
||||
{
|
||||
int i;
|
||||
HammerPattern h_patt;
|
||||
@ -761,24 +727,18 @@ void fuzz(HammerSuite *suite, int d, int v)
|
||||
}
|
||||
|
||||
fprintf(stderr, "[HAMMER] - %s: ", hPatt_2_str(&h_patt, ROW_FIELD));
|
||||
for (int bk = 0; bk < get_banks_cnt(); bk++)
|
||||
{
|
||||
for (int idx = 0; idx < h_patt.len; idx++) {
|
||||
h_patt.d_lst[idx].bank = bk;
|
||||
}
|
||||
for (int bk = 0; bk < get_banks_cnt(); bk++) {
|
||||
for (int idx = 0; idx < h_patt.len; idx++) { h_patt.d_lst[idx].bank = bk; }
|
||||
#ifdef FLIPTABLE
|
||||
print_start_attack(&h_patt);
|
||||
#endif
|
||||
for (int idx = 0; idx < h_patt.len; idx++)
|
||||
fill_row(suite, &h_patt.d_lst[idx], suite->cfg->d_cfg, 0);
|
||||
for (int idx = 0; idx < h_patt.len; idx++) fill_row(suite, &h_patt.d_lst[idx], suite->cfg->d_cfg, 0);
|
||||
|
||||
uint64_t time = hammer_it(&h_patt, suite->mem);
|
||||
fprintf(stderr, "%lu ", time);
|
||||
|
||||
scan_rows(suite, &h_patt, 0);
|
||||
for (int idx = 0; idx<h_patt.len; idx++) {
|
||||
fill_row(suite, &h_patt.d_lst[idx], suite->cfg->d_cfg, 1);
|
||||
}
|
||||
for (int idx = 0; idx < h_patt.len; idx++) { fill_row(suite, &h_patt.d_lst[idx], suite->cfg->d_cfg, 1); }
|
||||
|
||||
#ifdef FLIPTABLE
|
||||
print_end_attack();
|
||||
@ -788,15 +748,15 @@ void fuzz(HammerSuite *suite, int d, int v)
|
||||
free(h_patt.d_lst);
|
||||
}
|
||||
|
||||
void create_dir(const char* dir_name)
|
||||
void
|
||||
create_dir(const char *dir_name)
|
||||
{
|
||||
struct stat st = {0};
|
||||
if (stat(dir_name, &st) == -1) {
|
||||
mkdir(dir_name, 0777);
|
||||
}
|
||||
if (stat(dir_name, &st) == -1) { mkdir(dir_name, 0777); }
|
||||
}
|
||||
|
||||
void fuzzing_session(SessionConfig * cfg, MemoryBuffer * mem)
|
||||
void
|
||||
fuzzing_session(SessionConfig *cfg, MemoryBuffer *mem)
|
||||
{
|
||||
int d, v, aggrs;
|
||||
|
||||
@ -850,7 +810,8 @@ void fuzzing_session(SessionConfig * cfg, MemoryBuffer * mem)
|
||||
}
|
||||
}
|
||||
|
||||
void hammer_session(SessionConfig * cfg, MemoryBuffer * memory)
|
||||
void
|
||||
hammer_session(SessionConfig *cfg, MemoryBuffer *memory)
|
||||
{
|
||||
MemoryBuffer mem = *memory;
|
||||
|
||||
@ -896,9 +857,8 @@ void hammer_session(SessionConfig * cfg, MemoryBuffer * memory)
|
||||
}
|
||||
out_fd = fopen(out_name, "w+");
|
||||
|
||||
fprintf(stderr,
|
||||
"[LOG] - Hammer session! access pattern: %s\t data pattern: %s\n",
|
||||
config_str[cfg->h_cfg], data_str[cfg->d_cfg]);
|
||||
fprintf(stderr, "[LOG] - Hammer session! access pattern: %s\t data pattern: %s\n", config_str[cfg->h_cfg],
|
||||
data_str[cfg->d_cfg]);
|
||||
fprintf(stderr, "[LOG] - File: %s\n", out_name);
|
||||
|
||||
HammerSuite *suite = (HammerSuite *) malloc(sizeof(HammerSuite));
|
||||
@ -914,26 +874,20 @@ void hammer_session(SessionConfig * cfg, MemoryBuffer * memory)
|
||||
#endif
|
||||
|
||||
switch (cfg->h_cfg) {
|
||||
case ASSISTED_DOUBLE_SIDED:
|
||||
{
|
||||
suite->hammer_test =
|
||||
(int (*)(void *))assisted_double_sided_test;
|
||||
case ASSISTED_DOUBLE_SIDED: {
|
||||
suite->hammer_test = (int (*)(void *)) assisted_double_sided_test;
|
||||
break;
|
||||
}
|
||||
case FREE_TRIPLE_SIDED:
|
||||
{
|
||||
suite->hammer_test =
|
||||
(int (*)(void *))free_triple_sided_test;
|
||||
case FREE_TRIPLE_SIDED: {
|
||||
suite->hammer_test = (int (*)(void *)) free_triple_sided_test;
|
||||
break;
|
||||
}
|
||||
case N_SIDED:
|
||||
{
|
||||
case N_SIDED: {
|
||||
assert(cfg->aggr_n > 1);
|
||||
suite->hammer_test = (int (*)(void *)) n_sided_test;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
suite->hammer_test = (int (*)(void *)) n_sided_test;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user