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

s390/cpu_mf: add store cpu counter multiple instruction support

Add support for the STORE CPU COUNTER MULTIPLE instruction to extract
a range of counters from a counter set.

An assembler macro is used to create the instruction opcode because
the counter set identifier is part of the instruction and, thus,
cannot be easily specified as parameter.

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Hendrik Brueckner and committed by
Martin Schwidefsky
778fb10c 17bebcc6

+39
+22
arch/s390/include/asm/cpu_mf-insn.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Support for CPU-MF instructions 4 + * 5 + * Copyright IBM Corp. 2019 6 + * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> 7 + */ 8 + #ifndef _ASM_S390_CPU_MF_INSN_H 9 + #define _ASM_S390_CPU_MF_INSN_H 10 + 11 + #ifdef __ASSEMBLY__ 12 + 13 + /* Macro to generate the STCCTM instruction with a customized 14 + * M3 field designating the counter set. 15 + */ 16 + .macro STCCTM r1 m3 db2 17 + .insn rsy,0xeb0000000017,\r1,\m3 & 0xf,\db2 18 + .endm 19 + 20 + #endif /* __ASSEMBLY__ */ 21 + 22 + #endif
+17
arch/s390/include/asm/cpu_mf.h
··· 12 12 #include <linux/errno.h> 13 13 #include <asm/facility.h> 14 14 15 + asm(".include \"asm/cpu_mf-insn.h\"\n"); 16 + 15 17 #define CPU_MF_INT_SF_IAE (1 << 31) /* invalid entry address */ 16 18 #define CPU_MF_INT_SF_ISE (1 << 30) /* incorrect SDBT entry */ 17 19 #define CPU_MF_INT_SF_PRA (1 << 29) /* program request alert */ ··· 208 206 cc = __ecctr(ctr, &content); 209 207 if (!cc) 210 208 *val = content; 209 + return cc; 210 + } 211 + 212 + /* Store CPU counter multiple for a particular counter set */ 213 + static inline int stcctm(u8 set, u64 range, u64 *dest) 214 + { 215 + int cc; 216 + 217 + asm volatile ( 218 + " STCCTM %2,%3,%1\n" 219 + " ipm %0\n" 220 + " srl %0,28\n" 221 + : "=d" (cc) 222 + : "Q" (*dest), "d" (range), "i" (set) 223 + : "cc", "memory"); 211 224 return cc; 212 225 } 213 226