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

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

authored by

Benjamin Gray and committed by
Michael Ellerman
aecfd680 5921eb36

+10 -21
+5 -12
tools/testing/selftests/powerpc/dscr/dscr.h
··· 23 23 #include <sys/stat.h> 24 24 #include <sys/wait.h> 25 25 26 + #include "reg.h" 26 27 #include "utils.h" 27 28 28 29 #define THREADS 100 /* Max threads */ ··· 42 41 /* Prilvilege state DSCR access */ 43 42 inline unsigned long get_dscr(void) 44 43 { 45 - unsigned long ret; 46 - 47 - asm volatile("mfspr %0,%1" : "=r" (ret) : "i" (SPRN_DSCR_PRIV)); 48 - 49 - return ret; 44 + return mfspr(SPRN_DSCR_PRIV); 50 45 } 51 46 52 47 inline void set_dscr(unsigned long val) 53 48 { 54 - asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR_PRIV)); 49 + mtspr(SPRN_DSCR_PRIV, val); 55 50 } 56 51 57 52 /* Problem state DSCR access */ 58 53 inline unsigned long get_dscr_usr(void) 59 54 { 60 - unsigned long ret; 61 - 62 - asm volatile("mfspr %0,%1" : "=r" (ret) : "i" (SPRN_DSCR)); 63 - 64 - return ret; 55 + return mfspr(SPRN_DSCR); 65 56 } 66 57 67 58 inline void set_dscr_usr(unsigned long val) 68 59 { 69 - asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR)); 60 + mtspr(SPRN_DSCR, val); 70 61 } 71 62 72 63 /* Default DSCR access */
+2 -4
tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
··· 23 23 #include <sys/syscall.h> 24 24 #include <linux/limits.h> 25 25 #include "ptrace.h" 26 + #include "reg.h" 26 27 27 28 #define SPRN_PVR 0x11F 28 29 #define PVR_8xx 0x00500000 ··· 621 620 622 621 int main(int argc, char **argv, char **envp) 623 622 { 624 - int pvr = 0; 625 - asm __volatile__ ("mfspr %0,%1" : "=r"(pvr) : "i"(SPRN_PVR)); 626 - if (pvr == PVR_8xx) 627 - is_8xx = true; 623 + is_8xx = mfspr(SPRN_PVR) == PVR_8xx; 628 624 629 625 return test_harness(ptrace_hwbreak, "ptrace-hwbreak"); 630 626 }
+1 -4
tools/testing/selftests/powerpc/ptrace/ptrace.h
··· 745 745 /* Analyse TEXASR after TM failure */ 746 746 inline unsigned long get_tfiar(void) 747 747 { 748 - unsigned long ret; 749 - 750 - asm volatile("mfspr %0,%1" : "=r" (ret) : "i" (SPRN_TFIAR)); 751 - return ret; 748 + return mfspr(SPRN_TFIAR); 752 749 } 753 750 754 751 void analyse_texasr(unsigned long texasr)
+2 -1
tools/testing/selftests/powerpc/security/flush_utils.c
··· 14 14 #include <string.h> 15 15 #include <stdio.h> 16 16 #include <sys/utsname.h> 17 + #include "reg.h" 17 18 #include "utils.h" 18 19 #include "flush_utils.h" 19 20 ··· 80 79 init = 1; 81 80 } 82 81 83 - asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR)); 82 + mtspr(SPRN_DSCR, val); 84 83 }