1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 1999, 2009
8 #ifndef __ASM_S390_CTLREG_H
9 #define __ASM_S390_CTLREG_H
11 #include <linux/bits.h>
13 #define CR0_TRANSACTIONAL_EXECUTION_BIT (63 - 8)
14 #define CR0_CLOCK_COMPARATOR_SIGN_BIT (63 - 10)
15 #define CR0_CRYPTOGRAPHY_COUNTER_BIT (63 - 13)
16 #define CR0_PAI_EXTENSION_BIT (63 - 14)
17 #define CR0_CPUMF_EXTRACTION_AUTH_BIT (63 - 15)
18 #define CR0_WARNING_TRACK_BIT (63 - 30)
19 #define CR0_LOW_ADDRESS_PROTECTION_BIT (63 - 35)
20 #define CR0_FETCH_PROTECTION_OVERRIDE_BIT (63 - 38)
21 #define CR0_STORAGE_PROTECTION_OVERRIDE_BIT (63 - 39)
22 #define CR0_EDAT_BIT (63 - 40)
23 #define CR0_INSTRUCTION_EXEC_PROTECTION_BIT (63 - 43)
24 #define CR0_VECTOR_BIT (63 - 46)
25 #define CR0_MALFUNCTION_ALERT_SUBMASK_BIT (63 - 48)
26 #define CR0_EMERGENCY_SIGNAL_SUBMASK_BIT (63 - 49)
27 #define CR0_EXTERNAL_CALL_SUBMASK_BIT (63 - 50)
28 #define CR0_CLOCK_COMPARATOR_SUBMASK_BIT (63 - 52)
29 #define CR0_CPU_TIMER_SUBMASK_BIT (63 - 53)
30 #define CR0_SERVICE_SIGNAL_SUBMASK_BIT (63 - 54)
31 #define CR0_UNUSED_56_BIT (63 - 56)
32 #define CR0_INTERRUPT_KEY_SUBMASK_BIT (63 - 57)
33 #define CR0_MEASUREMENT_ALERT_SUBMASK_BIT (63 - 58)
34 #define CR0_ETR_SUBMASK_BIT (63 - 59)
35 #define CR0_IUCV_BIT (63 - 62)
37 #define CR0_TRANSACTIONAL_EXECUTION BIT(CR0_TRANSACTIONAL_EXECUTION_BIT)
38 #define CR0_CLOCK_COMPARATOR_SIGN BIT(CR0_CLOCK_COMPARATOR_SIGN_BIT)
39 #define CR0_CRYPTOGRAPHY_COUNTER BIT(CR0_CRYPTOGRAPHY_COUNTER_BIT)
40 #define CR0_PAI_EXTENSION BIT(CR0_PAI_EXTENSION_BIT)
41 #define CR0_CPUMF_EXTRACTION_AUTH BIT(CR0_CPUMF_EXTRACTION_AUTH_BIT)
42 #define CR0_WARNING_TRACK BIT(CR0_WARNING_TRACK_BIT)
43 #define CR0_LOW_ADDRESS_PROTECTION BIT(CR0_LOW_ADDRESS_PROTECTION_BIT)
44 #define CR0_FETCH_PROTECTION_OVERRIDE BIT(CR0_FETCH_PROTECTION_OVERRIDE_BIT)
45 #define CR0_STORAGE_PROTECTION_OVERRIDE BIT(CR0_STORAGE_PROTECTION_OVERRIDE_BIT)
46 #define CR0_EDAT BIT(CR0_EDAT_BIT)
47 #define CR0_INSTRUCTION_EXEC_PROTECTION BIT(CR0_INSTRUCTION_EXEC_PROTECTION_BIT)
48 #define CR0_VECTOR BIT(CR0_VECTOR_BIT)
49 #define CR0_MALFUNCTION_ALERT_SUBMASK BIT(CR0_MALFUNCTION_ALERT_SUBMASK_BIT)
50 #define CR0_EMERGENCY_SIGNAL_SUBMASK BIT(CR0_EMERGENCY_SIGNAL_SUBMASK_BIT)
51 #define CR0_EXTERNAL_CALL_SUBMASK BIT(CR0_EXTERNAL_CALL_SUBMASK_BIT)
52 #define CR0_CLOCK_COMPARATOR_SUBMASK BIT(CR0_CLOCK_COMPARATOR_SUBMASK_BIT)
53 #define CR0_CPU_TIMER_SUBMASK BIT(CR0_CPU_TIMER_SUBMASK_BIT)
54 #define CR0_SERVICE_SIGNAL_SUBMASK BIT(CR0_SERVICE_SIGNAL_SUBMASK_BIT)
55 #define CR0_UNUSED_56 BIT(CR0_UNUSED_56_BIT)
56 #define CR0_INTERRUPT_KEY_SUBMASK BIT(CR0_INTERRUPT_KEY_SUBMASK_BIT)
57 #define CR0_MEASUREMENT_ALERT_SUBMASK BIT(CR0_MEASUREMENT_ALERT_SUBMASK_BIT)
58 #define CR0_ETR_SUBMASK BIT(CR0_ETR_SUBMASK_BIT)
59 #define CR0_IUCV BIT(CR0_IUCV_BIT)
61 #define CR2_MIO_ADDRESSING_BIT (63 - 58)
62 #define CR2_GUARDED_STORAGE_BIT (63 - 59)
64 #define CR2_MIO_ADDRESSING BIT(CR2_MIO_ADDRESSING_BIT)
65 #define CR2_GUARDED_STORAGE BIT(CR2_GUARDED_STORAGE_BIT)
67 #define CR14_UNUSED_32_BIT (63 - 32)
68 #define CR14_UNUSED_33_BIT (63 - 33)
69 #define CR14_CHANNEL_REPORT_SUBMASK_BIT (63 - 35)
70 #define CR14_RECOVERY_SUBMASK_BIT (63 - 36)
71 #define CR14_DEGRADATION_SUBMASK_BIT (63 - 37)
72 #define CR14_EXTERNAL_DAMAGE_SUBMASK_BIT (63 - 38)
73 #define CR14_WARNING_SUBMASK_BIT (63 - 39)
75 #define CR14_UNUSED_32 BIT(CR14_UNUSED_32_BIT)
76 #define CR14_UNUSED_33 BIT(CR14_UNUSED_33_BIT)
77 #define CR14_CHANNEL_REPORT_SUBMASK BIT(CR14_CHANNEL_REPORT_SUBMASK_BIT)
78 #define CR14_RECOVERY_SUBMASK BIT(CR14_RECOVERY_SUBMASK_BIT)
79 #define CR14_DEGRADATION_SUBMASK BIT(CR14_DEGRADATION_SUBMASK_BIT)
80 #define CR14_EXTERNAL_DAMAGE_SUBMASK BIT(CR14_EXTERNAL_DAMAGE_SUBMASK_BIT)
81 #define CR14_WARNING_SUBMASK BIT(CR14_WARNING_SUBMASK_BIT)
85 #include <linux/bug.h>
91 #define __local_ctl_load(low, high, array) do { \
93 char _[sizeof(array)]; \
99 _esize = (_high - _low + 1) * sizeof(struct ctlreg); \
100 BUILD_BUG_ON(sizeof(struct addrtype) != _esize); \
101 typecheck(struct ctlreg, array[0]); \
103 " lctlg %[_low],%[_high],%[_arr]\n" \
105 : [_arr] "Q" (*(struct addrtype *)(&array)), \
106 [_low] "i" (low), [_high] "i" (high) \
110 #define __local_ctl_store(low, high, array) do { \
112 char _[sizeof(array)]; \
118 _esize = (_high - _low + 1) * sizeof(struct ctlreg); \
119 BUILD_BUG_ON(sizeof(struct addrtype) != _esize); \
120 typecheck(struct ctlreg, array[0]); \
122 " stctg %[_low],%[_high],%[_arr]\n" \
123 : [_arr] "=Q" (*(struct addrtype *)(&array)) \
124 : [_low] "i" (low), [_high] "i" (high)); \
127 static __always_inline void local_ctl_load(unsigned int cr, struct ctlreg *reg)
130 " lctlg %[cr],%[cr],%[reg]\n"
132 : [reg] "Q" (*reg), [cr] "i" (cr)
136 static __always_inline void local_ctl_store(unsigned int cr, struct ctlreg *reg)
139 " stctg %[cr],%[cr],%[reg]\n"
144 static __always_inline struct ctlreg local_ctl_set_bit(unsigned int cr, unsigned int bit)
146 struct ctlreg new, old;
148 local_ctl_store(cr, &old);
150 new.val |= 1UL << bit;
151 local_ctl_load(cr, &new);
155 static __always_inline struct ctlreg local_ctl_clear_bit(unsigned int cr, unsigned int bit)
157 struct ctlreg new, old;
159 local_ctl_store(cr, &old);
161 new.val &= ~(1UL << bit);
162 local_ctl_load(cr, &new);
168 void system_ctlreg_lock(void);
169 void system_ctlreg_unlock(void);
170 void system_ctlreg_init_save_area(struct lowcore *lc);
171 void system_ctlreg_modify(unsigned int cr, unsigned long data, int request);
179 static inline void system_ctl_set_bit(unsigned int cr, unsigned int bit)
181 system_ctlreg_modify(cr, bit, CTLREG_SET_BIT);
184 static inline void system_ctl_clear_bit(unsigned int cr, unsigned int bit)
186 system_ctlreg_modify(cr, bit, CTLREG_CLEAR_BIT);
189 static inline void system_ctl_load(unsigned int cr, struct ctlreg *reg)
191 system_ctlreg_modify(cr, reg->val, CTLREG_LOAD);
199 unsigned long tcx : 1; /* Transactional-Execution control */
200 unsigned long pifo : 1; /* Transactional-Execution Program-
201 Interruption-Filtering Override */
203 unsigned long ccc : 1; /* Cryptography counter control */
204 unsigned long pec : 1; /* PAI extension control */
206 unsigned long wti : 1; /* Warning-track */
208 unsigned long lap : 1; /* Low-address-protection control */
210 unsigned long edat : 1; /* Enhanced-DAT-enablement control */
212 unsigned long iep : 1; /* Instruction-Execution-Protection */
214 unsigned long afp : 1; /* AFP-register control */
215 unsigned long vx : 1; /* Vector enablement control */
217 unsigned long sssm : 1; /* Service signal subclass mask */
227 unsigned long ducto : 25;
229 unsigned long gse : 1;
231 unsigned long tds : 1;
232 unsigned long tdc : 2;
241 unsigned long pasteo: 25;
250 unsigned long lsea : 61;
255 #endif /* __ASSEMBLY__ */
256 #endif /* __ASM_S390_CTLREG_H */