1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 #ifndef _ASM_KVM_HOST_TYPES_H 4 #define _ASM_KVM_HOST_TYPES_H 5 6 #include <linux/atomic.h> 7 #include <linux/types.h> 8 9 #define KVM_S390_BSCA_CPU_SLOTS 64 10 #define KVM_S390_ESCA_CPU_SLOTS 248 11 12 #define SIGP_CTRL_C 0x80 13 #define SIGP_CTRL_SCN_MASK 0x3f 14 15 union bsca_sigp_ctrl { 16 __u8 value; 17 struct { 18 __u8 c : 1; 19 __u8 r : 1; 20 __u8 scn : 6; 21 }; 22 }; 23 24 union esca_sigp_ctrl { 25 __u16 value; 26 struct { 27 __u8 c : 1; 28 __u8 reserved: 7; 29 __u8 scn; 30 }; 31 }; 32 33 struct esca_entry { 34 union esca_sigp_ctrl sigp_ctrl; 35 __u16 reserved1[3]; 36 __u64 sda; 37 __u64 reserved2[6]; 38 }; 39 40 struct bsca_entry { 41 __u8 reserved0; 42 union bsca_sigp_ctrl sigp_ctrl; 43 __u16 reserved[3]; 44 __u64 sda; 45 __u64 reserved2[2]; 46 }; 47 48 union ipte_control { 49 unsigned long val; 50 struct { 51 unsigned long k : 1; 52 unsigned long kh : 31; 53 unsigned long kg : 32; 54 }; 55 }; 56 57 /* 58 * Utility is defined as two bytes but having it four bytes wide 59 * generates more efficient code. Since the following bytes are 60 * reserved this makes no functional difference. 61 */ 62 union sca_utility { 63 __u32 val; 64 struct { 65 __u32 mtcr : 1; 66 __u32 : 31; 67 }; 68 }; 69 70 struct bsca_block { 71 union ipte_control ipte_control; 72 __u64 reserved[5]; 73 __u64 mcn; 74 union sca_utility utility; 75 __u8 reserved2[4]; 76 struct bsca_entry cpu[KVM_S390_BSCA_CPU_SLOTS]; 77 }; 78 79 struct esca_block { 80 union ipte_control ipte_control; 81 __u64 reserved1[6]; 82 union sca_utility utility; 83 __u8 reserved2[4]; 84 __u64 mcn[4]; 85 __u64 reserved3[20]; 86 struct esca_entry cpu[KVM_S390_ESCA_CPU_SLOTS]; 87 }; 88 89 /* 90 * This struct is used to store some machine check info from lowcore 91 * for machine checks that happen while the guest is running. 92 * This info in host's lowcore might be overwritten by a second machine 93 * check from host when host is in the machine check's high-level handling. 94 * The size is 24 bytes. 95 */ 96 struct mcck_volatile_info { 97 __u64 mcic; 98 __u64 failing_storage_address; 99 __u32 ext_damage_code; 100 __u32 reserved; 101 }; 102 103 #define CR0_INITIAL_MASK (CR0_UNUSED_56 | CR0_INTERRUPT_KEY_SUBMASK | \ 104 CR0_MEASUREMENT_ALERT_SUBMASK) 105 #define CR14_INITIAL_MASK (CR14_UNUSED_32 | CR14_UNUSED_33 | \ 106 CR14_EXTERNAL_DAMAGE_SUBMASK) 107 108 #define SIDAD_SIZE_MASK 0xff 109 #define sida_addr(sie_block) phys_to_virt((sie_block)->sidad & PAGE_MASK) 110 #define sida_size(sie_block) \ 111 ((((sie_block)->sidad & SIDAD_SIZE_MASK) + 1) * PAGE_SIZE) 112 113 #define CPUSTAT_STOPPED 0x80000000 114 #define CPUSTAT_WAIT 0x10000000 115 #define CPUSTAT_ECALL_PEND 0x08000000 116 #define CPUSTAT_STOP_INT 0x04000000 117 #define CPUSTAT_IO_INT 0x02000000 118 #define CPUSTAT_EXT_INT 0x01000000 119 #define CPUSTAT_RUNNING 0x00800000 120 #define CPUSTAT_RETAINED 0x00400000 121 #define CPUSTAT_TIMING_SUB 0x00020000 122 #define CPUSTAT_SIE_SUB 0x00010000 123 #define CPUSTAT_RRF 0x00008000 124 #define CPUSTAT_SLSV 0x00004000 125 #define CPUSTAT_SLSR 0x00002000 126 #define CPUSTAT_ZARCH 0x00000800 127 #define CPUSTAT_MCDS 0x00000100 128 #define CPUSTAT_KSS 0x00000200 129 #define CPUSTAT_SM 0x00000080 130 #define CPUSTAT_IBS 0x00000040 131 #define CPUSTAT_GED2 0x00000010 132 #define CPUSTAT_G 0x00000008 133 #define CPUSTAT_GED 0x00000004 134 #define CPUSTAT_J 0x00000002 135 #define CPUSTAT_P 0x00000001 136 137 struct kvm_s390_sie_block { 138 atomic_t cpuflags; /* 0x0000 */ 139 __u32 : 1; /* 0x0004 */ 140 __u32 prefix : 18; 141 __u32 : 1; 142 __u32 ibc : 12; 143 __u8 reserved08[4]; /* 0x0008 */ 144 #define PROG_IN_SIE (1<<0) 145 __u32 prog0c; /* 0x000c */ 146 union { 147 __u8 reserved10[16]; /* 0x0010 */ 148 struct { 149 __u64 pv_handle_cpu; 150 __u64 pv_handle_config; 151 }; 152 }; 153 #define PROG_BLOCK_SIE (1<<0) 154 #define PROG_REQUEST (1<<1) 155 atomic_t prog20; /* 0x0020 */ 156 __u8 reserved24[4]; /* 0x0024 */ 157 __u64 cputm; /* 0x0028 */ 158 __u64 ckc; /* 0x0030 */ 159 __u64 epoch; /* 0x0038 */ 160 __u32 svcc; /* 0x0040 */ 161 #define LCTL_CR0 0x8000 162 #define LCTL_CR6 0x0200 163 #define LCTL_CR9 0x0040 164 #define LCTL_CR10 0x0020 165 #define LCTL_CR11 0x0010 166 #define LCTL_CR14 0x0002 167 __u16 lctl; /* 0x0044 */ 168 __s16 icpua; /* 0x0046 */ 169 #define ICTL_OPEREXC 0x80000000 170 #define ICTL_PINT 0x20000000 171 #define ICTL_LPSW 0x00400000 172 #define ICTL_STCTL 0x00040000 173 #define ICTL_ISKE 0x00004000 174 #define ICTL_SSKE 0x00002000 175 #define ICTL_RRBE 0x00001000 176 #define ICTL_TPROT 0x00000200 177 __u32 ictl; /* 0x0048 */ 178 #define ECA_CEI 0x80000000 179 #define ECA_IB 0x40000000 180 #define ECA_SIGPI 0x10000000 181 #define ECA_MVPGI 0x01000000 182 #define ECA_AIV 0x00200000 183 #define ECA_VX 0x00020000 184 #define ECA_PROTEXCI 0x00002000 185 #define ECA_APIE 0x00000008 186 #define ECA_SII 0x00000001 187 __u32 eca; /* 0x004c */ 188 #define ICPT_INST 0x04 189 #define ICPT_PROGI 0x08 190 #define ICPT_INSTPROGI 0x0C 191 #define ICPT_EXTREQ 0x10 192 #define ICPT_EXTINT 0x14 193 #define ICPT_IOREQ 0x18 194 #define ICPT_WAIT 0x1c 195 #define ICPT_VALIDITY 0x20 196 #define ICPT_STOP 0x28 197 #define ICPT_OPEREXC 0x2C 198 #define ICPT_PARTEXEC 0x38 199 #define ICPT_IOINST 0x40 200 #define ICPT_KSS 0x5c 201 #define ICPT_MCHKREQ 0x60 202 #define ICPT_INT_ENABLE 0x64 203 #define ICPT_PV_INSTR 0x68 204 #define ICPT_PV_NOTIFY 0x6c 205 #define ICPT_PV_PREF 0x70 206 __u8 icptcode; /* 0x0050 */ 207 __u8 icptstatus; /* 0x0051 */ 208 __u16 ihcpu; /* 0x0052 */ 209 __u8 reserved54; /* 0x0054 */ 210 #define IICTL_CODE_NONE 0x00 211 #define IICTL_CODE_MCHK 0x01 212 #define IICTL_CODE_EXT 0x02 213 #define IICTL_CODE_IO 0x03 214 #define IICTL_CODE_RESTART 0x04 215 #define IICTL_CODE_SPECIFICATION 0x10 216 #define IICTL_CODE_OPERAND 0x11 217 __u8 iictl; /* 0x0055 */ 218 __u16 ipa; /* 0x0056 */ 219 __u32 ipb; /* 0x0058 */ 220 __u32 scaoh; /* 0x005c */ 221 #define FPF_BPBC 0x20 222 __u8 fpf; /* 0x0060 */ 223 #define ECB_GS 0x40 224 #define ECB_TE 0x10 225 #define ECB_SPECI 0x08 226 #define ECB_SRSI 0x04 227 #define ECB_HOSTPROTINT 0x02 228 #define ECB_PTF 0x01 229 __u8 ecb; /* 0x0061 */ 230 #define ECB2_CMMA 0x80 231 #define ECB2_IEP 0x20 232 #define ECB2_PFMFI 0x08 233 #define ECB2_ESCA 0x04 234 #define ECB2_ZPCI_LSI 0x02 235 __u8 ecb2; /* 0x0062 */ 236 #define ECB3_AISI 0x20 237 #define ECB3_AISII 0x10 238 #define ECB3_DEA 0x08 239 #define ECB3_AES 0x04 240 #define ECB3_RI 0x01 241 __u8 ecb3; /* 0x0063 */ 242 #define ESCA_SCAOL_MASK ~0x3fU 243 __u32 scaol; /* 0x0064 */ 244 __u8 sdf; /* 0x0068 */ 245 __u8 epdx; /* 0x0069 */ 246 __u8 cpnc; /* 0x006a */ 247 __u8 reserved6b; /* 0x006b */ 248 __u32 todpr; /* 0x006c */ 249 #define GISA_FORMAT1 0x00000001 250 __u32 gd; /* 0x0070 */ 251 __u8 reserved74[12]; /* 0x0074 */ 252 __u64 mso; /* 0x0080 */ 253 __u64 msl; /* 0x0088 */ 254 psw_t gpsw; /* 0x0090 */ 255 __u64 gg14; /* 0x00a0 */ 256 __u64 gg15; /* 0x00a8 */ 257 __u8 reservedb0[8]; /* 0x00b0 */ 258 #define HPID_KVM 0x4 259 #define HPID_VSIE 0x5 260 __u8 hpid; /* 0x00b8 */ 261 __u8 reservedb9[7]; /* 0x00b9 */ 262 union { 263 struct { 264 __u32 eiparams; /* 0x00c0 */ 265 __u16 extcpuaddr; /* 0x00c4 */ 266 __u16 eic; /* 0x00c6 */ 267 }; 268 __u64 mcic; /* 0x00c0 */ 269 } __packed; 270 __u32 reservedc8; /* 0x00c8 */ 271 union { 272 struct { 273 __u16 pgmilc; /* 0x00cc */ 274 __u16 iprcc; /* 0x00ce */ 275 }; 276 __u32 edc; /* 0x00cc */ 277 } __packed; 278 union { 279 struct { 280 __u32 dxc; /* 0x00d0 */ 281 __u16 mcn; /* 0x00d4 */ 282 __u8 perc; /* 0x00d6 */ 283 __u8 peratmid; /* 0x00d7 */ 284 }; 285 __u64 faddr; /* 0x00d0 */ 286 } __packed; 287 __u64 peraddr; /* 0x00d8 */ 288 __u8 eai; /* 0x00e0 */ 289 __u8 peraid; /* 0x00e1 */ 290 __u8 oai; /* 0x00e2 */ 291 __u8 armid; /* 0x00e3 */ 292 __u8 reservede4[4]; /* 0x00e4 */ 293 union { 294 __u64 tecmc; /* 0x00e8 */ 295 struct { 296 __u16 subchannel_id; /* 0x00e8 */ 297 __u16 subchannel_nr; /* 0x00ea */ 298 __u32 io_int_parm; /* 0x00ec */ 299 __u32 io_int_word; /* 0x00f0 */ 300 }; 301 } __packed; 302 __u8 reservedf4[8]; /* 0x00f4 */ 303 #define CRYCB_FORMAT_MASK 0x00000003 304 #define CRYCB_FORMAT0 0x00000000 305 #define CRYCB_FORMAT1 0x00000001 306 #define CRYCB_FORMAT2 0x00000003 307 __u32 crycbd; /* 0x00fc */ 308 __u64 gcr[16]; /* 0x0100 */ 309 union { 310 __u64 gbea; /* 0x0180 */ 311 __u64 sidad; 312 }; 313 __u8 reserved188[8]; /* 0x0188 */ 314 __u64 sdnxo; /* 0x0190 */ 315 __u8 reserved198[8]; /* 0x0198 */ 316 __u32 fac; /* 0x01a0 */ 317 __u8 reserved1a4[20]; /* 0x01a4 */ 318 __u64 cbrlo; /* 0x01b8 */ 319 __u8 reserved1c0[8]; /* 0x01c0 */ 320 #define ECD_HOSTREGMGMT 0x20000000 321 #define ECD_MEF 0x08000000 322 #define ECD_ETOKENF 0x02000000 323 #define ECD_ECC 0x00200000 324 #define ECD_HMAC 0x00004000 325 __u32 ecd; /* 0x01c8 */ 326 __u8 reserved1cc[18]; /* 0x01cc */ 327 __u64 pp; /* 0x01de */ 328 __u8 reserved1e6[2]; /* 0x01e6 */ 329 __u64 itdba; /* 0x01e8 */ 330 __u64 riccbd; /* 0x01f0 */ 331 __u64 gvrd; /* 0x01f8 */ 332 } __packed __aligned(512); 333 334 struct kvm_s390_itdb { 335 __u8 data[256]; 336 }; 337 338 struct sie_page { 339 struct kvm_s390_sie_block sie_block; 340 struct mcck_volatile_info mcck_info; /* 0x0200 */ 341 __u8 reserved218[360]; /* 0x0218 */ 342 __u64 pv_grregs[16]; /* 0x0380 */ 343 __u8 reserved400[512]; /* 0x0400 */ 344 struct kvm_s390_itdb itdb; /* 0x0600 */ 345 __u8 reserved700[2304]; /* 0x0700 */ 346 }; 347 348 #endif /* _ASM_KVM_HOST_TYPES_H */ 349