1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 3 * Copyright IBM Corp. 1999, 2009 4 * 5 * Author(s): Martin Schwidefsky <schwidefsky@ 6 */ 7 8 #ifndef __ASM_S390_CTLREG_H 9 #define __ASM_S390_CTLREG_H 10 11 #include <linux/bits.h> 12 13 #define CR0_TRANSACTIONAL_EXECUTION_BIT 14 #define CR0_CLOCK_COMPARATOR_SIGN_BIT 15 #define CR0_CRYPTOGRAPHY_COUNTER_BIT 16 #define CR0_PAI_EXTENSION_BIT 17 #define CR0_CPUMF_EXTRACTION_AUTH_BIT 18 #define CR0_WARNING_TRACK_BIT 19 #define CR0_LOW_ADDRESS_PROTECTION_BIT 20 #define CR0_FETCH_PROTECTION_OVERRIDE_BIT 21 #define CR0_STORAGE_PROTECTION_OVERRIDE_BIT 22 #define CR0_EDAT_BIT 23 #define CR0_INSTRUCTION_EXEC_PROTECTION_BIT 24 #define CR0_VECTOR_BIT 25 #define CR0_MALFUNCTION_ALERT_SUBMASK_BIT 26 #define CR0_EMERGENCY_SIGNAL_SUBMASK_BIT 27 #define CR0_EXTERNAL_CALL_SUBMASK_BIT 28 #define CR0_CLOCK_COMPARATOR_SUBMASK_BIT 29 #define CR0_CPU_TIMER_SUBMASK_BIT 30 #define CR0_SERVICE_SIGNAL_SUBMASK_BIT 31 #define CR0_UNUSED_56_BIT 32 #define CR0_INTERRUPT_KEY_SUBMASK_BIT 33 #define CR0_MEASUREMENT_ALERT_SUBMASK_BIT 34 #define CR0_ETR_SUBMASK_BIT 35 #define CR0_IUCV_BIT 36 37 #define CR0_TRANSACTIONAL_EXECUTION 38 #define CR0_CLOCK_COMPARATOR_SIGN 39 #define CR0_CRYPTOGRAPHY_COUNTER 40 #define CR0_PAI_EXTENSION 41 #define CR0_CPUMF_EXTRACTION_AUTH 42 #define CR0_WARNING_TRACK 43 #define CR0_LOW_ADDRESS_PROTECTION 44 #define CR0_FETCH_PROTECTION_OVERRIDE 45 #define CR0_STORAGE_PROTECTION_OVERRIDE 46 #define CR0_EDAT 47 #define CR0_INSTRUCTION_EXEC_PROTECTION 48 #define CR0_VECTOR 49 #define CR0_MALFUNCTION_ALERT_SUBMASK 50 #define CR0_EMERGENCY_SIGNAL_SUBMASK 51 #define CR0_EXTERNAL_CALL_SUBMASK 52 #define CR0_CLOCK_COMPARATOR_SUBMASK 53 #define CR0_CPU_TIMER_SUBMASK 54 #define CR0_SERVICE_SIGNAL_SUBMASK 55 #define CR0_UNUSED_56 56 #define CR0_INTERRUPT_KEY_SUBMASK 57 #define CR0_MEASUREMENT_ALERT_SUBMASK 58 #define CR0_ETR_SUBMASK 59 #define CR0_IUCV 60 61 #define CR2_MIO_ADDRESSING_BIT 62 #define CR2_GUARDED_STORAGE_BIT 63 64 #define CR2_MIO_ADDRESSING 65 #define CR2_GUARDED_STORAGE 66 67 #define CR14_UNUSED_32_BIT 68 #define CR14_UNUSED_33_BIT 69 #define CR14_CHANNEL_REPORT_SUBMASK_BIT 70 #define CR14_RECOVERY_SUBMASK_BIT 71 #define CR14_DEGRADATION_SUBMASK_BIT 72 #define CR14_EXTERNAL_DAMAGE_SUBMASK_BIT 73 #define CR14_WARNING_SUBMASK_BIT 74 75 #define CR14_UNUSED_32 76 #define CR14_UNUSED_33 77 #define CR14_CHANNEL_REPORT_SUBMASK 78 #define CR14_RECOVERY_SUBMASK 79 #define CR14_DEGRADATION_SUBMASK 80 #define CR14_EXTERNAL_DAMAGE_SUBMASK 81 #define CR14_WARNING_SUBMASK 82 83 #ifndef __ASSEMBLY__ 84 85 #include <linux/bug.h> 86 87 struct ctlreg { 88 unsigned long val; 89 }; 90 91 #define __local_ctl_load(low, high, array) do 92 struct addrtype { 93 char _[sizeof(array)]; 94 }; 95 int _high = high; 96 int _low = low; 97 int _esize; 98 99 _esize = (_high - _low + 1) * sizeof(s 100 BUILD_BUG_ON(sizeof(struct addrtype) ! 101 typecheck(struct ctlreg, array[0]); 102 asm volatile( 103 " lctlg %[_low],%[_hig 104 : 105 : [_arr] "Q" (*(struct addrtyp 106 [_low] "i" (low), [_high] "i 107 : "memory"); 108 } while (0) 109 110 #define __local_ctl_store(low, high, array) do 111 struct addrtype { 112 char _[sizeof(array)]; 113 }; 114 int _high = high; 115 int _low = low; 116 int _esize; 117 118 _esize = (_high - _low + 1) * sizeof(s 119 BUILD_BUG_ON(sizeof(struct addrtype) ! 120 typecheck(struct ctlreg, array[0]); 121 asm volatile( 122 " stctg %[_low],%[_hig 123 : [_arr] "=Q" (*(struct addrty 124 : [_low] "i" (low), [_high] "i 125 } while (0) 126 127 static __always_inline void local_ctl_load(uns 128 { 129 asm volatile( 130 " lctlg %[cr],%[cr],%[ 131 : 132 : [reg] "Q" (*reg), [cr] "i" ( 133 : "memory"); 134 } 135 136 static __always_inline void local_ctl_store(un 137 { 138 asm volatile( 139 " stctg %[cr],%[cr],%[ 140 : [reg] "=Q" (*reg) 141 : [cr] "i" (cr)); 142 } 143 144 static __always_inline struct ctlreg local_ctl 145 { 146 struct ctlreg new, old; 147 148 local_ctl_store(cr, &old); 149 new = old; 150 new.val |= 1UL << bit; 151 local_ctl_load(cr, &new); 152 return old; 153 } 154 155 static __always_inline struct ctlreg local_ctl 156 { 157 struct ctlreg new, old; 158 159 local_ctl_store(cr, &old); 160 new = old; 161 new.val &= ~(1UL << bit); 162 local_ctl_load(cr, &new); 163 return old; 164 } 165 166 struct lowcore; 167 168 void system_ctlreg_lock(void); 169 void system_ctlreg_unlock(void); 170 void system_ctlreg_init_save_area(struct lowco 171 void system_ctlreg_modify(unsigned int cr, uns 172 173 enum { 174 CTLREG_SET_BIT, 175 CTLREG_CLEAR_BIT, 176 CTLREG_LOAD, 177 }; 178 179 static inline void system_ctl_set_bit(unsigned 180 { 181 system_ctlreg_modify(cr, bit, CTLREG_S 182 } 183 184 static inline void system_ctl_clear_bit(unsign 185 { 186 system_ctlreg_modify(cr, bit, CTLREG_C 187 } 188 189 static inline void system_ctl_load(unsigned in 190 { 191 system_ctlreg_modify(cr, reg->val, CTL 192 } 193 194 union ctlreg0 { 195 unsigned long val; 196 struct ctlreg reg; 197 struct { 198 unsigned long : 8; 199 unsigned long tcx : 1; /* Tra 200 unsigned long pifo : 1; /* Tra 201 Int 202 unsigned long : 3; 203 unsigned long ccc : 1; /* Cry 204 unsigned long pec : 1; /* PAI 205 unsigned long : 15; 206 unsigned long wti : 1; /* War 207 unsigned long : 4; 208 unsigned long lap : 1; /* Low 209 unsigned long : 4; 210 unsigned long edat : 1; /* Enh 211 unsigned long : 2; 212 unsigned long iep : 1; /* Ins 213 unsigned long : 1; 214 unsigned long afp : 1; /* AFP 215 unsigned long vx : 1; /* Vec 216 unsigned long : 7; 217 unsigned long sssm : 1; /* Ser 218 unsigned long : 9; 219 }; 220 }; 221 222 union ctlreg2 { 223 unsigned long val; 224 struct ctlreg reg; 225 struct { 226 unsigned long : 33; 227 unsigned long ducto : 25; 228 unsigned long : 1; 229 unsigned long gse : 1; 230 unsigned long : 1; 231 unsigned long tds : 1; 232 unsigned long tdc : 2; 233 }; 234 }; 235 236 union ctlreg5 { 237 unsigned long val; 238 struct ctlreg reg; 239 struct { 240 unsigned long : 33; 241 unsigned long pasteo: 25; 242 unsigned long : 6; 243 }; 244 }; 245 246 union ctlreg15 { 247 unsigned long val; 248 struct ctlreg reg; 249 struct { 250 unsigned long lsea : 61; 251 unsigned long : 3; 252 }; 253 }; 254 255 #endif /* __ASSEMBLY__ */ 256 #endif /* __ASM_S390_CTLREG_H */ 257
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.