aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/os.cc29
-rw-r--r--src/os.h16
-rw-r--r--src/pattern.cc16
-rw-r--r--src/sat.cc6
-rw-r--r--src/sat.h2
-rw-r--r--src/sattypes.h2
-rw-r--r--src/stressapptest_config.h.in3
-rw-r--r--src/stressapptest_config_android.h15
-rw-r--r--src/worker.cc6
9 files changed, 63 insertions, 32 deletions
diff --git a/src/os.cc b/src/os.cc
index 7c4e3d1..089b92d 100644
--- a/src/os.cc
+++ b/src/os.cc
@@ -63,6 +63,7 @@ OsLayer::OsLayer() {
dynamic_mapped_shmem_ = false;
mmapped_allocation_ = false;
shmid_ = 0;
+ channels_ = NULL;
time_initialized_ = 0;
@@ -140,10 +141,17 @@ int OsLayer::AddressMode() {
// Translates user virtual to physical address.
uint64 OsLayer::VirtualToPhysical(void *vaddr) {
- uint64 frame, shift;
- off64_t off = ((uintptr_t)vaddr) / sysconf(_SC_PAGESIZE) * 8;
+ uint64 frame, paddr, pfnmask, pagemask;
+ int pagesize = sysconf(_SC_PAGESIZE);
+ off64_t off = ((uintptr_t)vaddr) / pagesize * 8;
int fd = open(kPagemapPath, O_RDONLY);
- // /proc/self/pagemap is available in kernel >= 2.6.25
+
+ /*
+ * https://www.kernel.org/doc/Documentation/vm/pagemap.txt
+ * API change (July 2015)
+ * https://patchwork.kernel.org/patch/6787991/
+ */
+
if (fd < 0)
return 0;
@@ -157,11 +165,18 @@ uint64 OsLayer::VirtualToPhysical(void *vaddr) {
return 0;
}
close(fd);
- if (!(frame & (1LL << 63)) || (frame & (1LL << 62)))
+
+ /* Check if page is present and not swapped. */
+ if (!(frame & (1ULL << 63)) || (frame & (1ULL << 62)))
return 0;
- shift = (frame >> 55) & 0x3f;
- frame = (frame & 0x007fffffffffffffLL) << shift;
- return frame | ((uintptr_t)vaddr & ((1LL << shift) - 1));
+
+ /* pfn is bits 0-54. */
+ pfnmask = ((1ULL << 55) - 1);
+ /* Pagesize had better be a power of 2. */
+ pagemask = pagesize - 1;
+
+ paddr = ((frame & pfnmask) * pagesize) | ((uintptr_t)vaddr & pagemask);
+ return paddr;
}
// Returns the HD device that contains this file.
diff --git a/src/os.h b/src/os.h
index 0812f1a..7dd69b8 100644
--- a/src/os.h
+++ b/src/os.h
@@ -153,9 +153,15 @@ class OsLayer {
asm volatile("mfence");
asm volatile("clflush (%0)" : : "r" (vaddr));
asm volatile("mfence");
-#elif defined(STRESSAPPTEST_CPU_ARMV7A) && !defined(__aarch64__)
+#elif defined(STRESSAPPTEST_CPU_ARMV7A)
// ARMv7a cachelines are 8 words (32 bytes).
syscall(__ARM_NR_cacheflush, vaddr, reinterpret_cast<char*>(vaddr) + 32, 0);
+#elif defined(STRESSAPPTEST_CPU_AARCH64)
+ asm volatile("dc cvau, %0" : : "r" (vaddr));
+ asm volatile("dsb ish");
+ asm volatile("ic ivau, %0" : : "r" (vaddr));
+ asm volatile("dsb ish");
+ asm volatile("isb");
#else
#warning "Unsupported CPU type: Unable to force cache flushes."
#endif
@@ -186,7 +192,7 @@ class OsLayer {
asm volatile("clflush (%0)" : : "r" (*vaddrs++));
}
asm volatile("mfence");
-#elif defined(STRESSAPPTEST_CPU_ARMV7A)
+#elif defined(STRESSAPPTEST_CPU_ARMV7A) || defined(STRESSAPPTEST_CPU_AARCH64)
while (*vaddrs) {
FastFlush(*vaddrs++);
}
@@ -211,7 +217,7 @@ class OsLayer {
// instruction. For example, software can use an MFENCE instruction to
// insure that previous stores are included in the write-back.
asm volatile("clflush (%0)" : : "r" (vaddr));
-#elif defined(STRESSAPPTEST_CPU_ARMV7A)
+#elif defined(STRESSAPPTEST_CPU_ARMV7A) || defined(STRESSAPPTEST_CPU_AARCH64)
FastFlush(vaddr);
#else
#warning "Unsupported CPU type: Unable to force cache flushes."
@@ -236,7 +242,7 @@ class OsLayer {
// instruction. For example, software can use an MFENCE instruction to
// insure that previous stores are included in the write-back.
asm volatile("mfence");
-#elif defined(STRESSAPPTEST_CPU_ARMV7A)
+#elif defined(STRESSAPPTEST_CPU_ARMV7A) || defined(STRESSAPPTEST_CPU_AARCH64)
// This is a NOP, FastFlushHint() always does a full flush, so there's
// nothing to do for FastFlushSync().
#else
@@ -269,6 +275,8 @@ class OsLayer {
#elif defined(STRESSAPPTEST_CPU_ARMV7A)
#warning "Unsupported CPU type ARMV7A: your timer may not function correctly"
tsc = 0;
+#elif defined(STRESSAPPTEST_CPU_AARCH64)
+ __asm __volatile("mrs %0, CNTVCT_EL0" : "=r" (tsc) : : );
#else
#warning "Unsupported CPU type: your timer may not function correctly"
tsc = 0;
diff --git a/src/pattern.cc b/src/pattern.cc
index 9f22674..ba8f4d4 100644
--- a/src/pattern.cc
+++ b/src/pattern.cc
@@ -403,15 +403,17 @@ Pattern *PatternList::GetPattern(int i) {
// Return a randomly selected pattern.
Pattern *PatternList::GetRandomPattern() {
- unsigned int target = random();
- target = target % weightcount_;
-
+ int target = random();
unsigned int i = 0;
- unsigned int sum = 0;
- while (target > sum) {
- sum += patterns_[i].weight();
+ target = (target % weightcount_) + 1;
+
+ do {
+ target -= patterns_[i].weight();
+ if (target <= 0)
+ break;
i++;
- }
+ } while (i < size_);
+
if (i < size_) {
return &patterns_[i];
}
diff --git a/src/sat.cc b/src/sat.cc
index 927ba54..0528bf2 100644
--- a/src/sat.cc
+++ b/src/sat.cc
@@ -680,7 +680,7 @@ Sat::Sat() {
strict_ = 1;
warm_ = 0;
run_on_anything_ = 0;
- use_logfile_ = 0;
+ use_logfile_ = false;
logfile_ = 0;
log_timestamps_ = true;
// Detect 32/64 bit binary.
@@ -1015,7 +1015,7 @@ bool Sat::ParseArgs(int argc, char **argv) {
// Set logfile flag.
if (strcmp(logfilename_, ""))
- use_logfile_ = 1;
+ use_logfile_ = true;
// Checks valid page length.
if (page_length_ &&
!(page_length_ & (page_length_ - 1)) &&
@@ -1430,7 +1430,7 @@ void Sat::InitializeThreads() {
reinterpret_cast<void**>(&num),
line_size, line_size * needed_lines * cc_cacheline_count_);
#else
- num = reinterpret_cast<char*>(memalign(
+ num = reinterpret_cast<int*>(memalign(
line_size, line_size * needed_lines * cc_cacheline_count_));
int err_result = (num == 0);
#endif
diff --git a/src/sat.h b/src/sat.h
index 5cc3bec..33824b4 100644
--- a/src/sat.h
+++ b/src/sat.h
@@ -174,7 +174,7 @@ class Sat {
bool crazy_error_injection_; // Simulate lots of errors.
uint64 max_errorcount_; // Number of errors before forced exit.
int run_on_anything_; // Ignore unknown machine ereor.
- int use_logfile_; // Log to a file.
+ bool use_logfile_; // Log to a file.
char logfilename_[255]; // Name of file to log to.
int logfile_; // File handle to log to.
bool log_timestamps_; // Whether to add timestamps to log lines.
diff --git a/src/sattypes.h b/src/sattypes.h
index 79bb47d..251e8bc 100644
--- a/src/sattypes.h
+++ b/src/sattypes.h
@@ -227,6 +227,8 @@ inline void cpuid(
return;
#elif defined(STRESSAPPTEST_CPU_ARMV7A)
return;
+#elif defined(STRESSAPPTEST_CPU_AARCH64)
+ return;
#else
#warning "Unsupported CPU type."
#endif
diff --git a/src/stressapptest_config.h.in b/src/stressapptest_config.h.in
index 5412df4..4ab0ec8 100644
--- a/src/stressapptest_config.h.in
+++ b/src/stressapptest_config.h.in
@@ -172,6 +172,9 @@
/* Define to 1 if strerror_r returns char *. */
#undef STRERROR_R_CHAR_P
+/* Defined if the target CPU is aarch64 */
+#undef STRESSAPPTEST_CPU_AARCH64
+
/* Defined if the target CPU is armv7a */
#undef STRESSAPPTEST_CPU_ARMV7A
diff --git a/src/stressapptest_config_android.h b/src/stressapptest_config_android.h
index 6beff2c..03f6201 100644
--- a/src/stressapptest_config_android.h
+++ b/src/stressapptest_config_android.h
@@ -55,7 +55,7 @@
#define HAVE_POSIX_MEMALIGN 1
/* Define to 1 if the system has `pthread_barrier'. */
-#undef HAVE_PTHREAD_BARRIERS
+#define HAVE_PTHREAD_BARRIERS 1
/* Define to 1 if you have the <pthread.h> header file. */
#define HAVE_PTHREAD_H 1
@@ -73,7 +73,7 @@
#define HAVE_SOCKET 1
/* Define to 1 if stdbool.h conforms to C99. */
-/* #undef HAVE_STDBOOL_H */
+#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@@ -144,7 +144,7 @@
#define PACKAGE_NAME "stressapptest"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "stressapptest 1.0.7_autoconf"
+#define PACKAGE_STRING "stressapptest 1.0.9_autoconf"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "stressapptest"
@@ -153,7 +153,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.0.7_autoconf"
+#define PACKAGE_VERSION "1.0.9_autoconf"
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
@@ -174,14 +174,11 @@
/* #undef STRERROR_R_CHAR_P */
/* Defined if the target CPU is armv7a */
-#define STRESSAPPTEST_CPU_ARMV7A /**/
+/* #define STRESSAPPTEST_CPU_ARMV7A */
/* Defined if the target CPU is i686 */
/* #undef STRESSAPPTEST_CPU_I686 */
-/* Defined if the target CPU is mips */
-/* #undef STRESSAPPTEST_CPU_MIPS */
-
/* Defined if the target CPU is PowerPC */
/* #undef STRESSAPPTEST_CPU_PPC */
@@ -206,7 +203,7 @@
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
-#define VERSION "1.0.7_autoconf"
+#define VERSION "1.0.9_autoconf"
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
diff --git a/src/worker.cc b/src/worker.cc
index 5b0fe59..922d2c1 100644
--- a/src/worker.cc
+++ b/src/worker.cc
@@ -1238,9 +1238,11 @@ int WorkerThread::CrcCopyPage(struct page_entry *dstpe,
expectedcrc->ToHexString().c_str());
struct ErrorRecord er;
er.actual = sourcemem[0];
- er.expected = 0x0;
+ er.expected = 0xbad00000ull << 32;
er.vaddr = sourcemem;
ProcessError(&er, 0, "Hardware Error");
+ errors += 1;
+ errorcount_ ++;
}
}
}
@@ -1385,6 +1387,8 @@ int WorkerThread::CrcWarmCopyPage(struct page_entry *dstpe,
er.expected = 0xbad;
er.vaddr = sourcemem;
ProcessError(&er, 0, "Hardware Error");
+ errors ++;
+ errorcount_ ++;
}
}
}