s390x: Split and rework cpacf query functions
PATCH 1/1 s390x: Split and rework cpacf query functions
Cherry-pick 830999bd7e72 ("s390/cpacf: Split and rework cpacf query functions") from the kernel:
Rework the cpacf query functions to use the correct RRE or RRF instruction formats and set register fields within instructions correctly.
Fixes a555dc6b16bf ("s390x: add cpacf.h from Linux")
Signed-off-by Nina Schoetterl-Glausch <[email protected]>
--- lib/s390x/asm/cpacf.h | 77 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 10 deletions(-)
lib/s390x/asm/cpacf.h +67 -10
@@ -137,19 +137,76 @@typedef struct {unsigned char bytes[16 ]; }cpacf_mask_t ; -static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mask) +static __always_inline void __cpacf_query_rre(u32 opc, u8 r1, u8 r2, +cpacf_mask_t *mask) { - register unsigned long r0 asm("0") = 0; /* query function */ - register unsigned long r1 asm("1") = (unsigned long) mask; + asmvolatile ( +" la %%r1,%[mask]\n" +" xgr %%r0,%%r0\n" +" .insn rre,%[opc] << 16,%[r1],%[r2]\n" + : [mask]"=R" (*mask) + : [opc]"i" (opc), + [r1]"i" (r1), [r2]"i" (r2) + :"cc" ,"r0" ,"r1" ); +} +static __always_inline void __cpacf_query_rrf(u32 opc, +u8 r1,u8 r2,u8 r3,u8 m4, +cpacf_mask_t *mask) +{ asmvolatile ( -" spm 0\n" /* pckmo doesn't change the cc */ -/* Parameter regs are ignored, but must be nonzero and unique */ -"0: .insn rrf,%[opc] << 16,2,4,6,0\n" -" brc 1,0b\n" /* handle partial completion */ - :"=m" (*mask) - : [fc]"d" (r0), [pba]"a" (r1), [opc]"i" (opcode) - :"cc" ); +" la %%r1,%[mask]\n" +" xgr %%r0,%%r0\n" +" .insn rrf,%[opc] << 16,%[r1],%[r2],%[r3],%[m4]\n" + : [mask]"=R" (*mask) + : [opc]"i" (opc), [r1]"i" (r1), [r2]"i" (r2), + [r3]"i" (r3), [m4]"i" (m4) + :"cc" ,"r0" ,"r1" ); +} + +static __always_inline void __cpacf_query(unsigned int opcode, +cpacf_mask_t *mask) +{ +switch (opcode) { +case CPACF_KIMD : +__cpacf_query_rre (CPACF_KIMD ,0 ,2 , mask); +break ; +case CPACF_KLMD : +__cpacf_query_rre (CPACF_KLMD ,0 ,2 , mask); +break ; +case CPACF_KM : +__cpacf_query_rre (CPACF_KM ,2 ,4 , mask); +break ; +case CPACF_KMA : +__cpacf_query_rrf (CPACF_KMA ,2 ,4 ,6 ,0 , mask); +break ; +case CPACF_KMAC : +__cpacf_query_rre (CPACF_KMAC ,0 ,2 , mask); +break ; +case CPACF_KMC : +__cpacf_query_rre (CPACF_KMC ,2 ,4 , mask); +break ; +case CPACF_KMCTR : +__cpacf_query_rrf (CPACF_KMCTR ,2 ,4 ,6 ,0 , mask); +break ; +case CPACF_KMF : +__cpacf_query_rre (CPACF_KMF ,2 ,4 , mask); +break ; +case CPACF_KMO : +__cpacf_query_rre (CPACF_KMO ,2 ,4 , mask); +break ; +case CPACF_PCC : +__cpacf_query_rre (CPACF_PCC ,0 ,0 , mask); +break ; +case CPACF_PCKMO : +__cpacf_query_rre (CPACF_PCKMO ,0 ,0 , mask); +break ; +case CPACF_PRNO : +__cpacf_query_rre (CPACF_PRNO ,2 ,4 , mask); +break ; +default : + asmvolatile (".error \"bad opcode\"" ); + } }static inline int __cpacf_check_opcode (unsigned int opcode)
base-commit: 66fdb0333237161fb9644b4a41a200af5b8d20e9
Signature · 1 line
2.44.0
Quoting Nina Schoetterl-Glausch (2024-06-21 12:22:12)
Quoted 9 lines
Cherry-pick
830999bd7e72("s390/cpacf: Split and rework cpacf query functions") from the kernel:Rework the cpacf query functions to use the correct RRE or RRF instruction formats and set register fields within instructions correctly.
Fixes a555dc6b16bf ("s390x: add cpacf.h from Linux")Signed-off-by Nina Schoetterl-Glausch <[email protected]>
Reviewed-by Nico Boehr <[email protected]>