Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Sandipan Das and committed by
Michael Ellerman
c405b738 828ca432

+30 -29
+1
tools/testing/selftests/powerpc/include/utils.h
··· 60 60 #endif 61 61 62 62 bool is_ppc64le(void); 63 + int using_hash_mmu(bool *using_hash); 63 64 64 65 /* Yes, this is evil */ 65 66 #define FAIL_IF(x) \
+1 -1
tools/testing/selftests/powerpc/mm/Makefile
··· 10 10 top_srcdir = ../../../../.. 11 11 include ../../lib.mk 12 12 13 - $(TEST_GEN_PROGS): ../harness.c 13 + $(TEST_GEN_PROGS): ../harness.c ../utils.c 14 14 15 15 $(OUTPUT)/prot_sao: ../utils.c 16 16
-28
tools/testing/selftests/powerpc/mm/bad_accesses.c
··· 64 64 return 0; 65 65 } 66 66 67 - static int using_hash_mmu(bool *using_hash) 68 - { 69 - char line[128]; 70 - FILE *f; 71 - int rc; 72 - 73 - f = fopen("/proc/cpuinfo", "r"); 74 - FAIL_IF(!f); 75 - 76 - rc = 0; 77 - while (fgets(line, sizeof(line), f) != NULL) { 78 - if (strcmp(line, "MMU : Hash\n") == 0) { 79 - *using_hash = true; 80 - goto out; 81 - } 82 - 83 - if (strcmp(line, "MMU : Radix\n") == 0) { 84 - *using_hash = false; 85 - goto out; 86 - } 87 - } 88 - 89 - rc = -1; 90 - out: 91 - fclose(f); 92 - return rc; 93 - } 94 - 95 67 static int test(void) 96 68 { 97 69 unsigned long i, j, addr, region_shift, page_shift, page_size;
+28
tools/testing/selftests/powerpc/utils.c
··· 293 293 294 294 asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR)); 295 295 } 296 + 297 + int using_hash_mmu(bool *using_hash) 298 + { 299 + char line[128]; 300 + FILE *f; 301 + int rc; 302 + 303 + f = fopen("/proc/cpuinfo", "r"); 304 + FAIL_IF(!f); 305 + 306 + rc = 0; 307 + while (fgets(line, sizeof(line), f) != NULL) { 308 + if (strcmp(line, "MMU : Hash\n") == 0) { 309 + *using_hash = true; 310 + goto out; 311 + } 312 + 313 + if (strcmp(line, "MMU : Radix\n") == 0) { 314 + *using_hash = false; 315 + goto out; 316 + } 317 + } 318 + 319 + rc = -1; 320 + out: 321 + fclose(f); 322 + return rc; 323 + }