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