powerpc: add compile-time support for lbarx, lharx
Nicholas Piggin
reviewerPATCH v3 1/1 powerpc: add compile-time support for lbarx, lharx
ISA v2.06 (POWER7 and up) as well as e6500 support lbarx and lharx. Add a compile option that allows code to use it, and add support in cmpxchg and xchg 8 and 16 bit values without shifting and masking.
---
v2: Fixed lwarx->lharx typo, switched to PPC_HAS_
v3: Rebase, tidy asm slightly.
My powernv_defconfig build has a grand total of one call site, xchg on 16-bit value in kernel/locking/qspinlock.o
arch/powerpc/Kconfig | 3 + arch/powerpc/include/asm/cmpxchg.h | 231 ++++++++++++++++++++++++- arch/powerpc/lib/sstep.c | 21 +-- arch/powerpc/platforms/Kconfig.cputype | 5 + 4 files changed, 249 insertions(+), 11 deletions(-)
arch/powerpc/Kconfig +3 -0
@@ -292,6 +292,9 @@ config PPC_BARRIER_NOSPEC default y depends on PPC_BOOK3S_64 || PPC_FSL_BOOK3E +config PPC_HAS_LBARX_LHARX + bool + config EARLY_PRINTK bool default y
arch/powerpc/include/asm/cmpxchg.h +230 -1
257 lines not on this page · raw message
arch/powerpc/lib/sstep.c +11 -10
@@ -2284,15 +2284,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs, op->type =MKOP (STCX ,0 ,4 );break ; -#ifdef __powerpc64__ -case 84 :/* ldarx */ - op->type =MKOP (LARX ,0 ,8 ); -break ; - -case 214 :/* stdcx. */ - op->type =MKOP (STCX ,0 ,8 ); -break ; - +#ifdef CONFIG_PPC_HAS_LBARX_LHARX case 52 :/* lbarx */ op->type =MKOP (LARX ,0 ,1 );break ;
@@ -2308,6 +2300,15 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,case 726 :/* sthcx. */ op->type =MKOP (STCX ,0 ,2 );break ; +#endif +#ifdef __powerpc64__ +case 84 :/* ldarx */ + op->type =MKOP (LARX ,0 ,8 ); +break ; + +case 214 :/* stdcx. */ + op->type =MKOP (STCX ,0 ,8 ); +break ;case 276 :/* lqarx */ if (!((rd &1 ) || rd == ra || rd == rb))
@@ -3334,7 +3335,7 @@ int emulate_loadstore(struct pt_regs *regs, struct instruction_op *op) err =0 ; val =0 ;switch (size) { -#ifdef __powerpc64__ +#ifdef CONFIG_PPC_HAS_LBARX_LHARX case 1 :__get_user_asmx (val, ea, err,"lbarx" );break ;
arch/powerpc/platforms/Kconfig.cputype +5 -0
@@ -134,6 +134,7 @@ config GENERIC_CPU depends on PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN select ARCH_HAS_FAST_MULTIPLIER select PPC_64S_HASH_MMU + select PPC_HAS_LBARX_LHARX config POWERPC_CPU bool "Generic 32 bits powerpc"
@@ -159,17 +160,20 @@ config POWER7_CPU depends on PPC_BOOK3S_64 select ARCH_HAS_FAST_MULTIPLIER select PPC_64S_HASH_MMU + select PPC_HAS_LBARX_LHARX config POWER8_CPU bool "POWER8" depends on PPC_BOOK3S_64 select ARCH_HAS_FAST_MULTIPLIER select PPC_64S_HASH_MMU + select PPC_HAS_LBARX_LHARX config POWER9_CPU bool "POWER9" depends on PPC_BOOK3S_64 select ARCH_HAS_FAST_MULTIPLIER + select PPC_HAS_LBARX_LHARX config E5500_CPU bool "Freescale e5500"
@@ -178,6 +182,7 @@ config E5500_CPU config E6500_CPU bool "Freescale e6500" depends on PPC64 && E500 + select PPC_HAS_LBARX_LHARX config 405_CPU bool "40x family"
Signature · 1 line
2.37.2
Michael Ellerman
AppliedQuoted 5 lines · Nicholas Piggin
ISA v2.06 (POWER7 and up) as well as e6500 support lbarx and lharx. Add a compile option that allows code to use it, and add support in cmpxchg and xchg 8 and 16 bit values without shifting and masking.
Applied to powerpc/next.
[1/1] powerpc: add compile-time support for lbarx, lharx
https://git.kernel.org/powerpc/c/b86cf14f240e002e001fd4f2bf49114c7836fd5c
cheers