Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.
Open
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
17 changes: 12 additions & 5 deletions double_sided_rowhammer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ uint64_t number_of_seconds_to_hammer = 3600;
// The number of memory reads to try.
uint64_t number_of_reads = 1000*1024;

// The number of dimm modules
uint64_t number_of_channels = 2;

// Obtain the size of the physical memory of the system.
uint64_t GetPhysicalMemorySize() {
struct sysinfo info;
Expand Down Expand Up @@ -152,8 +155,8 @@ uint64_t HammerAllReachablePages(uint64_t presumed_row_size,
// We should have some pages for most rows now.
for (uint64_t row_index = 0; row_index + 2 < pages_per_row.size();
++row_index) {
if ((pages_per_row[row_index].size() != 64) ||
(pages_per_row[row_index+2].size() != 64)) {
if ((pages_per_row[row_index].size() != 32*number_of_channels) ||
(pages_per_row[row_index+2].size() != 32*number_of_channels)) {
printf("[!] Can't hammer row %ld - only got %ld/%ld pages "
"in the rows above/below\n",
row_index+1, pages_per_row[row_index].size(),
Expand Down Expand Up @@ -213,7 +216,7 @@ void HammerAllReachableRows(HammerFunction* hammer, uint64_t number_of_reads) {
void* mapping;
SetupMapping(&mapping_size, &mapping);

HammerAllReachablePages(1024*256, mapping, mapping_size,
HammerAllReachablePages(number_of_channels * 1024 * 128, mapping, mapping_size,
hammer, number_of_reads);
}

Expand All @@ -232,16 +235,20 @@ int main(int argc, char** argv) {
setvbuf(stdout, NULL, _IONBF, 0);

int opt;
while ((opt = getopt(argc, argv, "t:p:")) != -1) {
while ((opt = getopt(argc, argv, "t:p:d:")) != -1) {
switch (opt) {
case 't':
number_of_seconds_to_hammer = atoi(optarg);
break;
case 'p':
fraction_of_physical_memory = atof(optarg);
break;
case 'd':
if (atoi(optarg) == 1)
number_of_channels = 1;
break;
default:
fprintf(stderr, "Usage: %s [-t nsecs] [-p percent]\n",
fprintf(stderr, "Usage: %s [-t nsecs] [-p percent] [-d dimms]\n",
argv[0]);
exit(EXIT_FAILURE);
}
Expand Down