1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _RUNTIME_INSTR_H
3 #define _RUNTIME_INSTR_H
4 
5 #define S390_RUNTIME_INSTR_START	0x1
6 #define S390_RUNTIME_INSTR_STOP		0x2
7 
8 struct runtime_instr_cb {
9 	__u64 rca;
10 	__u64 roa;
11 	__u64 rla;
12 
13 	__u32 v			: 1;
14 	__u32 s			: 1;
15 	__u32 k			: 1;
16 	__u32 h			: 1;
17 	__u32 a			: 1;
18 	__u32 reserved1		: 3;
19 	__u32 ps		: 1;
20 	__u32 qs		: 1;
21 	__u32 pc		: 1;
22 	__u32 qc		: 1;
23 	__u32 reserved2		: 1;
24 	__u32 g			: 1;
25 	__u32 u			: 1;
26 	__u32 l			: 1;
27 	__u32 key		: 4;
28 	__u32 reserved3		: 8;
29 	__u32 t			: 1;
30 	__u32 rgs		: 3;
31 
32 	__u32 m			: 4;
33 	__u32 n			: 1;
34 	__u32 mae		: 1;
35 	__u32 reserved4		: 2;
36 	__u32 c			: 1;
37 	__u32 r			: 1;
38 	__u32 b			: 1;
39 	__u32 j			: 1;
40 	__u32 e			: 1;
41 	__u32 x			: 1;
42 	__u32 reserved5		: 2;
43 	__u32 bpxn		: 1;
44 	__u32 bpxt		: 1;
45 	__u32 bpti		: 1;
46 	__u32 bpni		: 1;
47 	__u32 reserved6		: 2;
48 
49 	__u32 d			: 1;
50 	__u32 f			: 1;
51 	__u32 ic		: 4;
52 	__u32 dc		: 4;
53 
54 	__u64 reserved7;
55 	__u64 sf;
56 	__u64 rsic;
57 	__u64 reserved8;
58 } __packed __aligned(8);
59 
60 extern struct runtime_instr_cb runtime_instr_empty_cb;
61 
62 static inline void load_runtime_instr_cb(struct runtime_instr_cb *cb)
63 {
64 	asm volatile(".insn	rsy,0xeb0000000060,0,0,%0"	/* LRIC */
65 		: : "Q" (*cb));
66 }
67 
68 static inline void store_runtime_instr_cb(struct runtime_instr_cb *cb)
69 {
70 	asm volatile(".insn	rsy,0xeb0000000061,0,0,%0"	/* STRIC */
71 		: "=Q" (*cb) : : "cc");
72 }
73 
74 static inline void save_ri_cb(struct runtime_instr_cb *cb_prev)
75 {
76 	if (cb_prev)
77 		store_runtime_instr_cb(cb_prev);
78 }
79 
80 static inline void restore_ri_cb(struct runtime_instr_cb *cb_next,
81 				 struct runtime_instr_cb *cb_prev)
82 {
83 	if (cb_next)
84 		load_runtime_instr_cb(cb_next);
85 	else if (cb_prev)
86 		load_runtime_instr_cb(&runtime_instr_empty_cb);
87 }
88 
89 struct task_struct;
90 
91 void runtime_instr_release(struct task_struct *tsk);
92 
93 #endif /* _RUNTIME_INSTR_H */
94