aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/powerpc/utils.c
diff options
context:
space:
mode:
authorSandipan Das <sandipan@linux.ibm.com>2020-06-04 18:26:09 +0530
committerMichael Ellerman <mpe@ellerman.id.au>2020-06-30 14:37:51 +1000
commitc405b738daf9d8e8a5aedfeb6be851681e65e54b (patch)
tree7b11e0c1a8b834a93bc1ca900d881f3852f79a78 /tools/testing/selftests/powerpc/utils.c
parentselftests/powerpc: Fix pkey access right updates (diff)
downloadlinux-dev-c405b738daf9d8e8a5aedfeb6be851681e65e54b.tar.xz
linux-dev-c405b738daf9d8e8a5aedfeb6be851681e65e54b.zip
selftests/powerpc: Move Hash MMU check to utilities
This moves a function to test if the MMU is in Hash mode under the generic test utilities. Signed-off-by: Sandipan Das <sandipan@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200604125610.649668-3-sandipan@linux.ibm.com
Diffstat (limited to 'tools/testing/selftests/powerpc/utils.c')
-rw-r--r--tools/testing/selftests/powerpc/utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/testing/selftests/powerpc/utils.c b/tools/testing/selftests/powerpc/utils.c
index 5ee0e98c4896..933678f1ed0a 100644
--- a/tools/testing/selftests/powerpc/utils.c
+++ b/tools/testing/selftests/powerpc/utils.c
@@ -293,3 +293,31 @@ void set_dscr(unsigned long val)
asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR));
}
+
+int using_hash_mmu(bool *using_hash)
+{
+ char line[128];
+ FILE *f;
+ int rc;
+
+ f = fopen("/proc/cpuinfo", "r");
+ FAIL_IF(!f);
+
+ rc = 0;
+ while (fgets(line, sizeof(line), f) != NULL) {
+ if (strcmp(line, "MMU : Hash\n") == 0) {
+ *using_hash = true;
+ goto out;
+ }
+
+ if (strcmp(line, "MMU : Radix\n") == 0) {
+ *using_hash = false;
+ goto out;
+ }
+ }
+
+ rc = -1;
+out:
+ fclose(f);
+ return rc;
+}