Commit c405b738 authored by Sandipan Das's avatar Sandipan Das Committed by Michael Ellerman

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: default avatarSandipan Das <sandipan@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200604125610.649668-3-sandipan@linux.ibm.com
parent 828ca432
...@@ -60,6 +60,7 @@ static inline bool have_hwcap2(unsigned long ftr2) ...@@ -60,6 +60,7 @@ static inline bool have_hwcap2(unsigned long ftr2)
#endif #endif
bool is_ppc64le(void); bool is_ppc64le(void);
int using_hash_mmu(bool *using_hash);
/* Yes, this is evil */ /* Yes, this is evil */
#define FAIL_IF(x) \ #define FAIL_IF(x) \
......
...@@ -10,7 +10,7 @@ TEST_GEN_FILES := tempfile ...@@ -10,7 +10,7 @@ TEST_GEN_FILES := tempfile
top_srcdir = ../../../../.. top_srcdir = ../../../../..
include ../../lib.mk include ../../lib.mk
$(TEST_GEN_PROGS): ../harness.c $(TEST_GEN_PROGS): ../harness.c ../utils.c
$(OUTPUT)/prot_sao: ../utils.c $(OUTPUT)/prot_sao: ../utils.c
......
...@@ -64,34 +64,6 @@ int bad_access(char *p, bool write) ...@@ -64,34 +64,6 @@ int bad_access(char *p, bool write)
return 0; return 0;
} }
static 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;
}
static int test(void) static int test(void)
{ {
unsigned long i, j, addr, region_shift, page_shift, page_size; unsigned long i, j, addr, region_shift, page_shift, page_size;
......
...@@ -293,3 +293,31 @@ void set_dscr(unsigned long val) ...@@ -293,3 +293,31 @@ void set_dscr(unsigned long val)
asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR)); 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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment