selftests/powerpc: Use mfspr/mtspr macros

No need to write inline asm for mtspr/mfspr, we have macros for this
in reg.h

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221128041948.58339-2-bgray@linux.ibm.com
This commit is contained in:
Benjamin Gray 2022-11-28 15:19:42 +11:00 committed by Michael Ellerman
parent 5921eb36d2
commit aecfd68009
4 changed files with 10 additions and 21 deletions

View File

@ -23,6 +23,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "reg.h"
#include "utils.h" #include "utils.h"
#define THREADS 100 /* Max threads */ #define THREADS 100 /* Max threads */
@ -41,31 +42,23 @@
/* Prilvilege state DSCR access */ /* Prilvilege state DSCR access */
inline unsigned long get_dscr(void) inline unsigned long get_dscr(void)
{ {
unsigned long ret; return mfspr(SPRN_DSCR_PRIV);
asm volatile("mfspr %0,%1" : "=r" (ret) : "i" (SPRN_DSCR_PRIV));
return ret;
} }
inline void set_dscr(unsigned long val) inline void set_dscr(unsigned long val)
{ {
asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR_PRIV)); mtspr(SPRN_DSCR_PRIV, val);
} }
/* Problem state DSCR access */ /* Problem state DSCR access */
inline unsigned long get_dscr_usr(void) inline unsigned long get_dscr_usr(void)
{ {
unsigned long ret; return mfspr(SPRN_DSCR);
asm volatile("mfspr %0,%1" : "=r" (ret) : "i" (SPRN_DSCR));
return ret;
} }
inline void set_dscr_usr(unsigned long val) inline void set_dscr_usr(unsigned long val)
{ {
asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR)); mtspr(SPRN_DSCR, val);
} }
/* Default DSCR access */ /* Default DSCR access */

View File

@ -23,6 +23,7 @@
#include <sys/syscall.h> #include <sys/syscall.h>
#include <linux/limits.h> #include <linux/limits.h>
#include "ptrace.h" #include "ptrace.h"
#include "reg.h"
#define SPRN_PVR 0x11F #define SPRN_PVR 0x11F
#define PVR_8xx 0x00500000 #define PVR_8xx 0x00500000
@ -620,10 +621,7 @@ static int ptrace_hwbreak(void)
int main(int argc, char **argv, char **envp) int main(int argc, char **argv, char **envp)
{ {
int pvr = 0; is_8xx = mfspr(SPRN_PVR) == PVR_8xx;
asm __volatile__ ("mfspr %0,%1" : "=r"(pvr) : "i"(SPRN_PVR));
if (pvr == PVR_8xx)
is_8xx = true;
return test_harness(ptrace_hwbreak, "ptrace-hwbreak"); return test_harness(ptrace_hwbreak, "ptrace-hwbreak");
} }

View File

@ -745,10 +745,7 @@ int show_tm_spr(pid_t child, struct tm_spr_regs *out)
/* Analyse TEXASR after TM failure */ /* Analyse TEXASR after TM failure */
inline unsigned long get_tfiar(void) inline unsigned long get_tfiar(void)
{ {
unsigned long ret; return mfspr(SPRN_TFIAR);
asm volatile("mfspr %0,%1" : "=r" (ret) : "i" (SPRN_TFIAR));
return ret;
} }
void analyse_texasr(unsigned long texasr) void analyse_texasr(unsigned long texasr)

View File

@ -14,6 +14,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include "reg.h"
#include "utils.h" #include "utils.h"
#include "flush_utils.h" #include "flush_utils.h"
@ -79,5 +80,5 @@ void set_dscr(unsigned long val)
init = 1; init = 1;
} }
asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR)); mtspr(SPRN_DSCR, val);
} }