1313#include <linux/kmsan-checks.h>
1414#include <asm/asm-extable.h>
1515#include <asm/facility.h>
16+ #include <asm/asm.h>
1617
1718asm(".include \"asm/cpu_mf-insn.h\"\n" );
1819
@@ -185,11 +186,12 @@ static inline int lcctl(u64 ctl)
185186 int cc ;
186187
187188 asm volatile (
188- " lcctl %1\n"
189- " ipm %0\n"
190- " srl %0,28\n"
191- : "=d" (cc ) : "Q" (ctl ) : "cc" );
192- return cc ;
189+ " lcctl %[ctl]\n"
190+ CC_IPM (cc )
191+ : CC_OUT (cc , cc )
192+ : [ctl ] "Q " (ctl)
193+ : CC_CLOBBER );
194+ return CC_TRANSFORM (cc );
193195}
194196
195197/* Extract CPU counter */
@@ -199,12 +201,13 @@ static inline int __ecctr(u64 ctr, u64 *content)
199201 int cc ;
200202
201203 asm volatile (
202- " ecctr %0,%2\n"
203- " ipm %1\n"
204- " srl %1,28\n"
205- : "=d" (_content ), "=d" (cc ) : "d" (ctr ) : "cc" );
204+ " ecctr %[_content],%[ctr]\n"
205+ CC_IPM (cc )
206+ : CC_OUT (cc , cc ), [_content ] "= d " (_content)
207+ : [ctr ] "d" (ctr )
208+ : CC_CLOBBER );
206209 * content = _content ;
207- return cc ;
210+ return CC_TRANSFORM ( cc ) ;
208211}
209212
210213/* Extract CPU counter */
@@ -234,18 +237,17 @@ static __always_inline int stcctm(enum stcctm_ctr_set set, u64 range, u64 *dest)
234237 int cc ;
235238
236239 asm volatile (
237- " STCCTM %2,%3,%1\n"
238- " ipm %0\n"
239- " srl %0,28\n"
240- : "=d" (cc )
241- : "Q" (* dest ), "d" (range ), "i" (set )
242- : "cc" , "memory" );
240+ " STCCTM %[range],%[set],%[dest]\n"
241+ CC_IPM (cc )
242+ : CC_OUT (cc , cc )
243+ : [dest ] "Q " (*dest), [range] " d " (range), [set] " i " (set)
244+ : CC_CLOBBER_LIST (" memory "));
243245 /*
244246 * If cc == 2, less than RANGE counters are stored, but it's not easy
245247 * to tell how many. Always unpoison the whole range for simplicity.
246248 */
247249 kmsan_unpoison_memory (dest , range * sizeof (u64 ));
248- return cc ;
250+ return CC_TRANSFORM ( cc ) ;
249251}
250252
251253/* Query sampling information */
@@ -265,19 +267,20 @@ static inline int qsi(struct hws_qsi_info_block *info)
265267/* Load sampling controls */
266268static inline int lsctl (struct hws_lsctl_request_block * req )
267269{
268- int cc ;
270+ int cc , exception ;
269271
270- cc = 1 ;
272+ exception = 1 ;
271273 asm volatile (
272- "0: lsctl 0(%1)\n"
273- "1: ipm %0\n"
274- " srl %0,28\n"
274+ "0: lsctl %[req]\n"
275+ "1: lhi %[exc],0\n"
275276 "2:\n"
277+ CC_IPM (cc )
276278 EX_TABLE (0b , 2b ) EX_TABLE (1b , 2b )
277- : "+ d " (cc), " + a " (req)
278- : " m " (*req)
279- : " cc ", " memory ");
280-
281- return cc ? - EINVAL : 0 ;
279+ : CC_OUT (cc , cc ), [exc ] "+ d " (exception)
280+ : [req ] "Q" (* req )
281+ : CC_CLOBBER );
282+ if (exception || CC_TRANSFORM (cc ))
283+ return - EINVAL ;
284+ return 0 ;
282285}
283286#endif /* _ASM_S390_CPU_MF_H */
0 commit comments