10b73214fSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2c6557e7fSMartin Schwidefsky /*
3a53c8fabSHeiko Carstens * definition for kernel virtual machines on s390
4c6557e7fSMartin Schwidefsky *
5a37cb07aSChristian Borntraeger * Copyright IBM Corp. 2008, 2018
6c6557e7fSMartin Schwidefsky *
7c6557e7fSMartin Schwidefsky * Author(s): Carsten Otte <cotte@de.ibm.com>
8c6557e7fSMartin Schwidefsky */
9c6557e7fSMartin Schwidefsky
10c6557e7fSMartin Schwidefsky
11c6557e7fSMartin Schwidefsky #ifndef ASM_KVM_HOST_H
12c6557e7fSMartin Schwidefsky #define ASM_KVM_HOST_H
1365647300SPaolo Bonzini
1465647300SPaolo Bonzini #include <linux/types.h>
15ca872302SChristian Borntraeger #include <linux/hrtimer.h>
16ca872302SChristian Borntraeger #include <linux/interrupt.h>
1765647300SPaolo Bonzini #include <linux/kvm_types.h>
18c6557e7fSMartin Schwidefsky #include <linux/kvm_host.h>
1981aa8efeSJens Freimann #include <linux/kvm.h>
209c23a131SDavid Hildenbrand #include <linux/seqlock.h>
21e5282de9SPierre Morel #include <linux/module.h>
2209340b2fSMatthew Rosato #include <linux/pci.h>
23ca2fd060SClaudio Imbrenda #include <linux/mmu_notifier.h>
24c6557e7fSMartin Schwidefsky #include <asm/debug.h>
25e86a6ed6SHeiko Carstens #include <asm/cpu.h>
26b0753902SHendrik Brueckner #include <asm/fpu/api.h>
27841b91c5SCornelia Huck #include <asm/isc.h>
284e0b1ab7SFan Zhang #include <asm/guarded_storage.h>
29c6557e7fSMartin Schwidefsky
30bc784cceSEugene (jno) Dvurechenski #define KVM_S390_BSCA_CPU_SLOTS 64
31bc784cceSEugene (jno) Dvurechenski #define KVM_S390_ESCA_CPU_SLOTS 248
32a6940674SDavid Hildenbrand #define KVM_MAX_VCPUS 255
33c6557e7fSMartin Schwidefsky
3484223598SCornelia Huck /*
3577491129SChristian Borntraeger * These seem to be used for allocating ->chip in the routing table, which we
3677491129SChristian Borntraeger * don't use. 1 is as small as we can get to reduce the needed memory. If we
3777491129SChristian Borntraeger * need to look at ->chip later on, we'll need to revisit this.
3884223598SCornelia Huck */
3984223598SCornelia Huck #define KVM_NR_IRQCHIPS 1
4077491129SChristian Borntraeger #define KVM_IRQCHIP_NUM_PINS 1
416e9b622dSChristian Borntraeger #define KVM_HALT_POLL_NS_DEFAULT 50000
4284223598SCornelia Huck
432860c4b1SPaolo Bonzini /* s390-specific vcpu->requests bit members */
442387149eSAndrew Jones #define KVM_REQ_ENABLE_IBS KVM_ARCH_REQ(0)
452387149eSAndrew Jones #define KVM_REQ_DISABLE_IBS KVM_ARCH_REQ(1)
462387149eSAndrew Jones #define KVM_REQ_ICPT_OPEREXC KVM_ARCH_REQ(2)
4704a7ea04SPaolo Bonzini #define KVM_REQ_START_MIGRATION KVM_ARCH_REQ(3)
4804a7ea04SPaolo Bonzini #define KVM_REQ_STOP_MIGRATION KVM_ARCH_REQ(4)
493194cdb7SDavid Hildenbrand #define KVM_REQ_VSIE_RESTART KVM_ARCH_REQ(5)
50cc65c3a1SSean Christopherson #define KVM_REQ_REFRESH_GUEST_PREFIX \
51cc65c3a1SSean Christopherson KVM_ARCH_REQ_FLAGS(6, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
522860c4b1SPaolo Bonzini
53ea5f4969SDavid Hildenbrand #define SIGP_CTRL_C 0x80
54ea5f4969SDavid Hildenbrand #define SIGP_CTRL_SCN_MASK 0x3f
554953919fSDavid Hildenbrand
56bc784cceSEugene (jno) Dvurechenski union bsca_sigp_ctrl {
57bc784cceSEugene (jno) Dvurechenski __u8 value;
58bc784cceSEugene (jno) Dvurechenski struct {
59bc784cceSEugene (jno) Dvurechenski __u8 c : 1;
60bc784cceSEugene (jno) Dvurechenski __u8 r : 1;
61bc784cceSEugene (jno) Dvurechenski __u8 scn : 6;
62bc784cceSEugene (jno) Dvurechenski };
631cae0255SMartin Schwidefsky };
64bc784cceSEugene (jno) Dvurechenski
65bc784cceSEugene (jno) Dvurechenski union esca_sigp_ctrl {
66bc784cceSEugene (jno) Dvurechenski __u16 value;
67bc784cceSEugene (jno) Dvurechenski struct {
68bc784cceSEugene (jno) Dvurechenski __u8 c : 1;
69bc784cceSEugene (jno) Dvurechenski __u8 reserved: 7;
70bc784cceSEugene (jno) Dvurechenski __u8 scn;
71bc784cceSEugene (jno) Dvurechenski };
721cae0255SMartin Schwidefsky };
73bc784cceSEugene (jno) Dvurechenski
74bc784cceSEugene (jno) Dvurechenski struct esca_entry {
75bc784cceSEugene (jno) Dvurechenski union esca_sigp_ctrl sigp_ctrl;
76bc784cceSEugene (jno) Dvurechenski __u16 reserved1[3];
77bc784cceSEugene (jno) Dvurechenski __u64 sda;
78bc784cceSEugene (jno) Dvurechenski __u64 reserved2[6];
791cae0255SMartin Schwidefsky };
80bc784cceSEugene (jno) Dvurechenski
81bc784cceSEugene (jno) Dvurechenski struct bsca_entry {
82ea5f4969SDavid Hildenbrand __u8 reserved0;
83bc784cceSEugene (jno) Dvurechenski union bsca_sigp_ctrl sigp_ctrl;
84ea5f4969SDavid Hildenbrand __u16 reserved[3];
85c6557e7fSMartin Schwidefsky __u64 sda;
86c6557e7fSMartin Schwidefsky __u64 reserved2[2];
871cae0255SMartin Schwidefsky };
88c6557e7fSMartin Schwidefsky
898a242234SHeiko Carstens union ipte_control {
908a242234SHeiko Carstens unsigned long val;
918a242234SHeiko Carstens struct {
928a242234SHeiko Carstens unsigned long k : 1;
938a242234SHeiko Carstens unsigned long kh : 31;
948a242234SHeiko Carstens unsigned long kg : 32;
958a242234SHeiko Carstens };
968a242234SHeiko Carstens };
97c6557e7fSMartin Schwidefsky
9824fe0195SPierre Morel union sca_utility {
9924fe0195SPierre Morel __u16 val;
10024fe0195SPierre Morel struct {
10124fe0195SPierre Morel __u16 mtcr : 1;
10224fe0195SPierre Morel __u16 reserved : 15;
10324fe0195SPierre Morel };
10424fe0195SPierre Morel };
10524fe0195SPierre Morel
106bc784cceSEugene (jno) Dvurechenski struct bsca_block {
1078a242234SHeiko Carstens union ipte_control ipte_control;
108c6557e7fSMartin Schwidefsky __u64 reserved[5];
109c6557e7fSMartin Schwidefsky __u64 mcn;
11024fe0195SPierre Morel union sca_utility utility;
11124fe0195SPierre Morel __u8 reserved2[6];
112bc784cceSEugene (jno) Dvurechenski struct bsca_entry cpu[KVM_S390_BSCA_CPU_SLOTS];
1131cae0255SMartin Schwidefsky };
114c6557e7fSMartin Schwidefsky
115bc784cceSEugene (jno) Dvurechenski struct esca_block {
116bc784cceSEugene (jno) Dvurechenski union ipte_control ipte_control;
11724fe0195SPierre Morel __u64 reserved1[6];
11824fe0195SPierre Morel union sca_utility utility;
11924fe0195SPierre Morel __u8 reserved2[6];
120bc784cceSEugene (jno) Dvurechenski __u64 mcn[4];
12124fe0195SPierre Morel __u64 reserved3[20];
122bc784cceSEugene (jno) Dvurechenski struct esca_entry cpu[KVM_S390_ESCA_CPU_SLOTS];
1231cae0255SMartin Schwidefsky };
124bc784cceSEugene (jno) Dvurechenski
125da72ca4dSQingFeng Hao /*
126da72ca4dSQingFeng Hao * This struct is used to store some machine check info from lowcore
127da72ca4dSQingFeng Hao * for machine checks that happen while the guest is running.
128da72ca4dSQingFeng Hao * This info in host's lowcore might be overwritten by a second machine
129da72ca4dSQingFeng Hao * check from host when host is in the machine check's high-level handling.
130da72ca4dSQingFeng Hao * The size is 24 bytes.
131da72ca4dSQingFeng Hao */
132da72ca4dSQingFeng Hao struct mcck_volatile_info {
133da72ca4dSQingFeng Hao __u64 mcic;
134da72ca4dSQingFeng Hao __u64 failing_storage_address;
135da72ca4dSQingFeng Hao __u32 ext_damage_code;
136da72ca4dSQingFeng Hao __u32 reserved;
137da72ca4dSQingFeng Hao };
138da72ca4dSQingFeng Hao
139cca00ebbSJanosch Frank #define CR0_INITIAL_MASK (CR0_UNUSED_56 | CR0_INTERRUPT_KEY_SUBMASK | \
140cca00ebbSJanosch Frank CR0_MEASUREMENT_ALERT_SUBMASK)
141cca00ebbSJanosch Frank #define CR14_INITIAL_MASK (CR14_UNUSED_32 | CR14_UNUSED_33 | \
142cca00ebbSJanosch Frank CR14_EXTERNAL_DAMAGE_SUBMASK)
143cca00ebbSJanosch Frank
14419e12277SJanosch Frank #define SIDAD_SIZE_MASK 0xff
145b99f4512SNico Boehr #define sida_addr(sie_block) phys_to_virt((sie_block)->sidad & PAGE_MASK)
14619e12277SJanosch Frank #define sida_size(sie_block) \
14719e12277SJanosch Frank ((((sie_block)->sidad & SIDAD_SIZE_MASK) + 1) * PAGE_SIZE)
14819e12277SJanosch Frank
1499e6dabefSCornelia Huck #define CPUSTAT_STOPPED 0x80000000
150c6557e7fSMartin Schwidefsky #define CPUSTAT_WAIT 0x10000000
151c6557e7fSMartin Schwidefsky #define CPUSTAT_ECALL_PEND 0x08000000
152c6557e7fSMartin Schwidefsky #define CPUSTAT_STOP_INT 0x04000000
153c6557e7fSMartin Schwidefsky #define CPUSTAT_IO_INT 0x02000000
154c6557e7fSMartin Schwidefsky #define CPUSTAT_EXT_INT 0x01000000
155c6557e7fSMartin Schwidefsky #define CPUSTAT_RUNNING 0x00800000
156c6557e7fSMartin Schwidefsky #define CPUSTAT_RETAINED 0x00400000
157c6557e7fSMartin Schwidefsky #define CPUSTAT_TIMING_SUB 0x00020000
158c6557e7fSMartin Schwidefsky #define CPUSTAT_SIE_SUB 0x00010000
159c6557e7fSMartin Schwidefsky #define CPUSTAT_RRF 0x00008000
160c6557e7fSMartin Schwidefsky #define CPUSTAT_SLSV 0x00004000
161c6557e7fSMartin Schwidefsky #define CPUSTAT_SLSR 0x00002000
162c6557e7fSMartin Schwidefsky #define CPUSTAT_ZARCH 0x00000800
163c6557e7fSMartin Schwidefsky #define CPUSTAT_MCDS 0x00000100
164730cd632SFarhan Ali #define CPUSTAT_KSS 0x00000200
165c6557e7fSMartin Schwidefsky #define CPUSTAT_SM 0x00000080
1668ad35755SDavid Hildenbrand #define CPUSTAT_IBS 0x00000040
16753df84f8SGuenther Hutzl #define CPUSTAT_GED2 0x00000010
168c6557e7fSMartin Schwidefsky #define CPUSTAT_G 0x00000008
16969d0d3a3SChristian Borntraeger #define CPUSTAT_GED 0x00000004
170c6557e7fSMartin Schwidefsky #define CPUSTAT_J 0x00000002
171c6557e7fSMartin Schwidefsky #define CPUSTAT_P 0x00000001
172c6557e7fSMartin Schwidefsky
173c6557e7fSMartin Schwidefsky struct kvm_s390_sie_block {
174c6557e7fSMartin Schwidefsky atomic_t cpuflags; /* 0x0000 */
175fda902cbSMichael Mueller __u32 : 1; /* 0x0004 */
176fda902cbSMichael Mueller __u32 prefix : 18;
177658b6edaSMichael Mueller __u32 : 1;
178658b6edaSMichael Mueller __u32 ibc : 12;
17995d38fd0SChristian Borntraeger __u8 reserved08[4]; /* 0x0008 */
18095d38fd0SChristian Borntraeger #define PROG_IN_SIE (1<<0)
18195d38fd0SChristian Borntraeger __u32 prog0c; /* 0x000c */
18229b40f10SJanosch Frank union {
18349b99e1eSChristian Borntraeger __u8 reserved10[16]; /* 0x0010 */
18429b40f10SJanosch Frank struct {
18529b40f10SJanosch Frank __u64 pv_handle_cpu;
18629b40f10SJanosch Frank __u64 pv_handle_config;
18729b40f10SJanosch Frank };
18829b40f10SJanosch Frank };
1898e236546SChristian Borntraeger #define PROG_BLOCK_SIE (1<<0)
1908e236546SChristian Borntraeger #define PROG_REQUEST (1<<1)
19149b99e1eSChristian Borntraeger atomic_t prog20; /* 0x0020 */
19249b99e1eSChristian Borntraeger __u8 reserved24[4]; /* 0x0024 */
193c6557e7fSMartin Schwidefsky __u64 cputm; /* 0x0028 */
194c6557e7fSMartin Schwidefsky __u64 ckc; /* 0x0030 */
195c6557e7fSMartin Schwidefsky __u64 epoch; /* 0x0038 */
196a3508fbeSDavid Hildenbrand __u32 svcc; /* 0x0040 */
197c6557e7fSMartin Schwidefsky #define LCTL_CR0 0x8000
198d8346b7dSCornelia Huck #define LCTL_CR6 0x0200
19927291e21SDavid Hildenbrand #define LCTL_CR9 0x0040
20027291e21SDavid Hildenbrand #define LCTL_CR10 0x0020
20127291e21SDavid Hildenbrand #define LCTL_CR11 0x0010
20248a3e950SCornelia Huck #define LCTL_CR14 0x0002
203c6557e7fSMartin Schwidefsky __u16 lctl; /* 0x0044 */
204c6557e7fSMartin Schwidefsky __s16 icpua; /* 0x0046 */
20595ca2cb5SJanosch Frank #define ICTL_OPEREXC 0x80000000
20627291e21SDavid Hildenbrand #define ICTL_PINT 0x20000000
20748a3e950SCornelia Huck #define ICTL_LPSW 0x00400000
20827291e21SDavid Hildenbrand #define ICTL_STCTL 0x00040000
209693ffc08SDominik Dingel #define ICTL_ISKE 0x00004000
210693ffc08SDominik Dingel #define ICTL_SSKE 0x00002000
211693ffc08SDominik Dingel #define ICTL_RRBE 0x00001000
2125a5e6536SMatthew Rosato #define ICTL_TPROT 0x00000200
213c6557e7fSMartin Schwidefsky __u32 ictl; /* 0x0048 */
2140c9d8683SDavid Hildenbrand #define ECA_CEI 0x80000000
2150c9d8683SDavid Hildenbrand #define ECA_IB 0x40000000
2160c9d8683SDavid Hildenbrand #define ECA_SIGPI 0x10000000
2170c9d8683SDavid Hildenbrand #define ECA_MVPGI 0x01000000
21819114bebSMichael Mueller #define ECA_AIV 0x00200000
2190c9d8683SDavid Hildenbrand #define ECA_VX 0x00020000
2200c9d8683SDavid Hildenbrand #define ECA_PROTEXCI 0x00002000
221e585b24aSTony Krowiak #define ECA_APIE 0x00000008
2220c9d8683SDavid Hildenbrand #define ECA_SII 0x00000001
223c6557e7fSMartin Schwidefsky __u32 eca; /* 0x004c */
2248712836bSDavid Hildenbrand #define ICPT_INST 0x04
2258712836bSDavid Hildenbrand #define ICPT_PROGI 0x08
2268712836bSDavid Hildenbrand #define ICPT_INSTPROGI 0x0C
227947b8972SFarhan Ali #define ICPT_EXTREQ 0x10
228a3508fbeSDavid Hildenbrand #define ICPT_EXTINT 0x14
229947b8972SFarhan Ali #define ICPT_IOREQ 0x18
230947b8972SFarhan Ali #define ICPT_WAIT 0x1c
231a3508fbeSDavid Hildenbrand #define ICPT_VALIDITY 0x20
232a3508fbeSDavid Hildenbrand #define ICPT_STOP 0x28
2338712836bSDavid Hildenbrand #define ICPT_OPEREXC 0x2C
2348712836bSDavid Hildenbrand #define ICPT_PARTEXEC 0x38
2358712836bSDavid Hildenbrand #define ICPT_IOINST 0x40
236730cd632SFarhan Ali #define ICPT_KSS 0x5c
23749710db0SJanosch Frank #define ICPT_MCHKREQ 0x60
23849710db0SJanosch Frank #define ICPT_INT_ENABLE 0x64
239da24a0ccSJanosch Frank #define ICPT_PV_INSTR 0x68
240da24a0ccSJanosch Frank #define ICPT_PV_NOTIFY 0x6c
241d274995eSJanosch Frank #define ICPT_PV_PREF 0x70
242c6557e7fSMartin Schwidefsky __u8 icptcode; /* 0x0050 */
24304b41acdSThomas Huth __u8 icptstatus; /* 0x0051 */
244c6557e7fSMartin Schwidefsky __u16 ihcpu; /* 0x0052 */
245201ae986SMichael Mueller __u8 reserved54; /* 0x0054 */
246201ae986SMichael Mueller #define IICTL_CODE_NONE 0x00
247201ae986SMichael Mueller #define IICTL_CODE_MCHK 0x01
248201ae986SMichael Mueller #define IICTL_CODE_EXT 0x02
249201ae986SMichael Mueller #define IICTL_CODE_IO 0x03
250201ae986SMichael Mueller #define IICTL_CODE_RESTART 0x04
251201ae986SMichael Mueller #define IICTL_CODE_SPECIFICATION 0x10
252201ae986SMichael Mueller #define IICTL_CODE_OPERAND 0x11
253201ae986SMichael Mueller __u8 iictl; /* 0x0055 */
254c6557e7fSMartin Schwidefsky __u16 ipa; /* 0x0056 */
255c6557e7fSMartin Schwidefsky __u32 ipb; /* 0x0058 */
256c6557e7fSMartin Schwidefsky __u32 scaoh; /* 0x005c */
25735b3fde6SChristian Borntraeger #define FPF_BPBC 0x20
25835b3fde6SChristian Borntraeger __u8 fpf; /* 0x0060 */
2594e0b1ab7SFan Zhang #define ECB_GS 0x40
2600c9d8683SDavid Hildenbrand #define ECB_TE 0x10
2617119decfSJanis Schoetterl-Glausch #define ECB_SPECI 0x08
2620c9d8683SDavid Hildenbrand #define ECB_SRSI 0x04
2630c9d8683SDavid Hildenbrand #define ECB_HOSTPROTINT 0x02
26424fe0195SPierre Morel #define ECB_PTF 0x01
265c6557e7fSMartin Schwidefsky __u8 ecb; /* 0x0061 */
2660c9d8683SDavid Hildenbrand #define ECB2_CMMA 0x80
2670c9d8683SDavid Hildenbrand #define ECB2_IEP 0x20
2680c9d8683SDavid Hildenbrand #define ECB2_PFMFI 0x08
2690c9d8683SDavid Hildenbrand #define ECB2_ESCA 0x04
2703f4bbb43SMatthew Rosato #define ECB2_ZPCI_LSI 0x02
27169d0d3a3SChristian Borntraeger __u8 ecb2; /* 0x0062 */
2723f4bbb43SMatthew Rosato #define ECB3_AISI 0x20
2733f4bbb43SMatthew Rosato #define ECB3_AISII 0x10
274a374e892STony Krowiak #define ECB3_DEA 0x08
2750c9d8683SDavid Hildenbrand #define ECB3_AES 0x04
2760c9d8683SDavid Hildenbrand #define ECB3_RI 0x01
277a374e892STony Krowiak __u8 ecb3; /* 0x0063 */
278fe0ef003SNico Boehr #define ESCA_SCAOL_MASK ~0x3fU
279c6557e7fSMartin Schwidefsky __u32 scaol; /* 0x0064 */
28029b40f10SJanosch Frank __u8 sdf; /* 0x0068 */
2818fa1696eSCollin L. Walling __u8 epdx; /* 0x0069 */
28223a60f83SCollin Walling __u8 cpnc; /* 0x006a */
28323a60f83SCollin Walling __u8 reserved6b; /* 0x006b */
284c6557e7fSMartin Schwidefsky __u32 todpr; /* 0x006c */
2854b9f9525SMichael Mueller #define GISA_FORMAT1 0x00000001
28619114bebSMichael Mueller __u32 gd; /* 0x0070 */
28719114bebSMichael Mueller __u8 reserved74[12]; /* 0x0074 */
288efed1104SDavid Hildenbrand __u64 mso; /* 0x0080 */
289efed1104SDavid Hildenbrand __u64 msl; /* 0x0088 */
290c6557e7fSMartin Schwidefsky psw_t gpsw; /* 0x0090 */
291c6557e7fSMartin Schwidefsky __u64 gg14; /* 0x00a0 */
292c6557e7fSMartin Schwidefsky __u64 gg15; /* 0x00a8 */
29367d49d52SCollin Walling __u8 reservedb0[8]; /* 0x00b0 */
29467d49d52SCollin Walling #define HPID_KVM 0x4
29567d49d52SCollin Walling #define HPID_VSIE 0x5
29667d49d52SCollin Walling __u8 hpid; /* 0x00b8 */
297201ae986SMichael Mueller __u8 reservedb9[7]; /* 0x00b9 */
298201ae986SMichael Mueller union {
299201ae986SMichael Mueller struct {
300201ae986SMichael Mueller __u32 eiparams; /* 0x00c0 */
301f14d82e0SThomas Huth __u16 extcpuaddr; /* 0x00c4 */
302f14d82e0SThomas Huth __u16 eic; /* 0x00c6 */
303201ae986SMichael Mueller };
304201ae986SMichael Mueller __u64 mcic; /* 0x00c0 */
305201ae986SMichael Mueller } __packed;
306f14d82e0SThomas Huth __u32 reservedc8; /* 0x00c8 */
307201ae986SMichael Mueller union {
308201ae986SMichael Mueller struct {
309439716a5SDavid Hildenbrand __u16 pgmilc; /* 0x00cc */
310c6557e7fSMartin Schwidefsky __u16 iprcc; /* 0x00ce */
311201ae986SMichael Mueller };
312201ae986SMichael Mueller __u32 edc; /* 0x00cc */
313201ae986SMichael Mueller } __packed;
314201ae986SMichael Mueller union {
315201ae986SMichael Mueller struct {
316439716a5SDavid Hildenbrand __u32 dxc; /* 0x00d0 */
317439716a5SDavid Hildenbrand __u16 mcn; /* 0x00d4 */
318439716a5SDavid Hildenbrand __u8 perc; /* 0x00d6 */
319439716a5SDavid Hildenbrand __u8 peratmid; /* 0x00d7 */
320201ae986SMichael Mueller };
321201ae986SMichael Mueller __u64 faddr; /* 0x00d0 */
322201ae986SMichael Mueller } __packed;
323439716a5SDavid Hildenbrand __u64 peraddr; /* 0x00d8 */
324439716a5SDavid Hildenbrand __u8 eai; /* 0x00e0 */
325439716a5SDavid Hildenbrand __u8 peraid; /* 0x00e1 */
326439716a5SDavid Hildenbrand __u8 oai; /* 0x00e2 */
327439716a5SDavid Hildenbrand __u8 armid; /* 0x00e3 */
328439716a5SDavid Hildenbrand __u8 reservede4[4]; /* 0x00e4 */
329201ae986SMichael Mueller union {
330439716a5SDavid Hildenbrand __u64 tecmc; /* 0x00e8 */
331201ae986SMichael Mueller struct {
332201ae986SMichael Mueller __u16 subchannel_id; /* 0x00e8 */
333201ae986SMichael Mueller __u16 subchannel_nr; /* 0x00ea */
334201ae986SMichael Mueller __u32 io_int_parm; /* 0x00ec */
335201ae986SMichael Mueller __u32 io_int_word; /* 0x00f0 */
336201ae986SMichael Mueller };
337201ae986SMichael Mueller } __packed;
338201ae986SMichael Mueller __u8 reservedf4[8]; /* 0x00f4 */
339e585b24aSTony Krowiak #define CRYCB_FORMAT_MASK 0x00000003
340258287c9STony Krowiak #define CRYCB_FORMAT0 0x00000000
3415102ee87STony Krowiak #define CRYCB_FORMAT1 0x00000001
34245c9b47cSTony Krowiak #define CRYCB_FORMAT2 0x00000003
3435102ee87STony Krowiak __u32 crycbd; /* 0x00fc */
344c6557e7fSMartin Schwidefsky __u64 gcr[16]; /* 0x0100 */
34519e12277SJanosch Frank union {
346c6557e7fSMartin Schwidefsky __u64 gbea; /* 0x0180 */
34719e12277SJanosch Frank __u64 sidad;
34819e12277SJanosch Frank };
3494e0b1ab7SFan Zhang __u8 reserved188[8]; /* 0x0188 */
3504e0b1ab7SFan Zhang __u64 sdnxo; /* 0x0190 */
3514e0b1ab7SFan Zhang __u8 reserved198[8]; /* 0x0198 */
352ef50f7acSChristian Borntraeger __u32 fac; /* 0x01a0 */
353b31288faSKonstantin Weitz __u8 reserved1a4[20]; /* 0x01a4 */
354b31288faSKonstantin Weitz __u64 cbrlo; /* 0x01b8 */
35513211ea7SEric Farman __u8 reserved1c0[8]; /* 0x01c0 */
3560c9d8683SDavid Hildenbrand #define ECD_HOSTREGMGMT 0x20000000
3578fa1696eSCollin L. Walling #define ECD_MEF 0x08000000
358a3da7b4aSChristian Borntraeger #define ECD_ETOKENF 0x02000000
3598ec2fa52SChristian Borntraeger #define ECD_ECC 0x00200000
36013211ea7SEric Farman __u32 ecd; /* 0x01c8 */
36113211ea7SEric Farman __u8 reserved1cc[18]; /* 0x01cc */
362672550fbSChristian Borntraeger __u64 pp; /* 0x01de */
363672550fbSChristian Borntraeger __u8 reserved1e6[2]; /* 0x01e6 */
3647feb6bb8SMichael Mueller __u64 itdba; /* 0x01e8 */
365c6e5f166SFan Zhang __u64 riccbd; /* 0x01f0 */
366c9bc1eabSDavid Hildenbrand __u64 gvrd; /* 0x01f8 */
367f3dd18d4SChristian Borntraeger } __packed __aligned(512);
368c6557e7fSMartin Schwidefsky
3697feb6bb8SMichael Mueller struct kvm_s390_itdb {
3707feb6bb8SMichael Mueller __u8 data[256];
3711cae0255SMartin Schwidefsky };
3727feb6bb8SMichael Mueller
3737feb6bb8SMichael Mueller struct sie_page {
3747feb6bb8SMichael Mueller struct kvm_s390_sie_block sie_block;
375da72ca4dSQingFeng Hao struct mcck_volatile_info mcck_info; /* 0x0200 */
376c8aac234SJanosch Frank __u8 reserved218[360]; /* 0x0218 */
377c8aac234SJanosch Frank __u64 pv_grregs[16]; /* 0x0380 */
378c8aac234SJanosch Frank __u8 reserved400[512]; /* 0x0400 */
3797feb6bb8SMichael Mueller struct kvm_s390_itdb itdb; /* 0x0600 */
380efa48163SDavid Hildenbrand __u8 reserved700[2304]; /* 0x0700 */
3811cae0255SMartin Schwidefsky };
3827feb6bb8SMichael Mueller
383c6557e7fSMartin Schwidefsky struct kvm_vcpu_stat {
3840193cc90SJing Zhang struct kvm_vcpu_stat_generic generic;
3858a7e75d4SSuraj Jitindar Singh u64 exit_userspace;
3868a7e75d4SSuraj Jitindar Singh u64 exit_null;
3878a7e75d4SSuraj Jitindar Singh u64 exit_external_request;
388a5e0aceaSChristian Borntraeger u64 exit_io_request;
3898a7e75d4SSuraj Jitindar Singh u64 exit_external_interrupt;
3908a7e75d4SSuraj Jitindar Singh u64 exit_stop_request;
3918a7e75d4SSuraj Jitindar Singh u64 exit_validity;
3928a7e75d4SSuraj Jitindar Singh u64 exit_instruction;
3938a7e75d4SSuraj Jitindar Singh u64 exit_pei;
3948b905d28SChristian Borntraeger u64 halt_no_poll_steal;
3958a7e75d4SSuraj Jitindar Singh u64 instruction_lctl;
3968a7e75d4SSuraj Jitindar Singh u64 instruction_lctlg;
3978a7e75d4SSuraj Jitindar Singh u64 instruction_stctl;
3988a7e75d4SSuraj Jitindar Singh u64 instruction_stctg;
3998a7e75d4SSuraj Jitindar Singh u64 exit_program_interruption;
4008a7e75d4SSuraj Jitindar Singh u64 exit_instr_and_program;
4018a7e75d4SSuraj Jitindar Singh u64 exit_operation_exception;
402ccc40c53SChristian Borntraeger u64 deliver_ckc;
403ccc40c53SChristian Borntraeger u64 deliver_cputm;
4048a7e75d4SSuraj Jitindar Singh u64 deliver_external_call;
4058a7e75d4SSuraj Jitindar Singh u64 deliver_emergency_signal;
4068a7e75d4SSuraj Jitindar Singh u64 deliver_service_signal;
407ccc40c53SChristian Borntraeger u64 deliver_virtio;
4088a7e75d4SSuraj Jitindar Singh u64 deliver_stop_signal;
4098a7e75d4SSuraj Jitindar Singh u64 deliver_prefix_signal;
4108a7e75d4SSuraj Jitindar Singh u64 deliver_restart_signal;
411ccc40c53SChristian Borntraeger u64 deliver_program;
412ccc40c53SChristian Borntraeger u64 deliver_io;
41332de0749SQingFeng Hao u64 deliver_machine_check;
4148a7e75d4SSuraj Jitindar Singh u64 exit_wait_state;
415ccc40c53SChristian Borntraeger u64 inject_ckc;
416ccc40c53SChristian Borntraeger u64 inject_cputm;
417ccc40c53SChristian Borntraeger u64 inject_external_call;
418ccc40c53SChristian Borntraeger u64 inject_emergency_signal;
419ccc40c53SChristian Borntraeger u64 inject_mchk;
420ccc40c53SChristian Borntraeger u64 inject_pfault_init;
421ccc40c53SChristian Borntraeger u64 inject_program;
422ccc40c53SChristian Borntraeger u64 inject_restart;
423ccc40c53SChristian Borntraeger u64 inject_set_prefix;
424ccc40c53SChristian Borntraeger u64 inject_stop_signal;
425a37cb07aSChristian Borntraeger u64 instruction_epsw;
426a37cb07aSChristian Borntraeger u64 instruction_gs;
427a37cb07aSChristian Borntraeger u64 instruction_io_other;
428a37cb07aSChristian Borntraeger u64 instruction_lpsw;
429a37cb07aSChristian Borntraeger u64 instruction_lpswe;
430*f4513867SChristian Borntraeger u64 instruction_lpswey;
4318a7e75d4SSuraj Jitindar Singh u64 instruction_pfmf;
432a37cb07aSChristian Borntraeger u64 instruction_ptff;
433a37cb07aSChristian Borntraeger u64 instruction_sck;
434a37cb07aSChristian Borntraeger u64 instruction_sckpf;
4358a7e75d4SSuraj Jitindar Singh u64 instruction_stidp;
4368a7e75d4SSuraj Jitindar Singh u64 instruction_spx;
4378a7e75d4SSuraj Jitindar Singh u64 instruction_stpx;
4388a7e75d4SSuraj Jitindar Singh u64 instruction_stap;
439a37cb07aSChristian Borntraeger u64 instruction_iske;
440a37cb07aSChristian Borntraeger u64 instruction_ri;
441a37cb07aSChristian Borntraeger u64 instruction_rrbe;
442a37cb07aSChristian Borntraeger u64 instruction_sske;
4438a7e75d4SSuraj Jitindar Singh u64 instruction_ipte_interlock;
4448a7e75d4SSuraj Jitindar Singh u64 instruction_stsi;
4458a7e75d4SSuraj Jitindar Singh u64 instruction_stfl;
446a37cb07aSChristian Borntraeger u64 instruction_tb;
447a37cb07aSChristian Borntraeger u64 instruction_tpi;
4488a7e75d4SSuraj Jitindar Singh u64 instruction_tprot;
449a37cb07aSChristian Borntraeger u64 instruction_tsch;
4508a7e75d4SSuraj Jitindar Singh u64 instruction_sie;
4518a7e75d4SSuraj Jitindar Singh u64 instruction_essa;
4528a7e75d4SSuraj Jitindar Singh u64 instruction_sthyi;
4538a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_sense;
4548a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_sense_running;
4558a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_external_call;
4568a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_emergency;
4578a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_cond_emergency;
4588a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_start;
4598a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_stop;
4608a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_stop_store_status;
4618a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_store_status;
4628a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_store_adtl_status;
4638a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_arch;
4648a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_prefix;
4658a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_restart;
4668a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_init_cpu_reset;
4678a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_cpu_reset;
4688a7e75d4SSuraj Jitindar Singh u64 instruction_sigp_unknown;
469bb000f64SChristian Borntraeger u64 instruction_diagnose_10;
470bb000f64SChristian Borntraeger u64 instruction_diagnose_44;
471bb000f64SChristian Borntraeger u64 instruction_diagnose_9c;
472bb000f64SChristian Borntraeger u64 diag_9c_ignored;
473bb000f64SChristian Borntraeger u64 diag_9c_forward;
474bb000f64SChristian Borntraeger u64 instruction_diagnose_258;
475bb000f64SChristian Borntraeger u64 instruction_diagnose_308;
476bb000f64SChristian Borntraeger u64 instruction_diagnose_500;
477bb000f64SChristian Borntraeger u64 instruction_diagnose_other;
47850a05be4SChristian Borntraeger u64 pfault_sync;
479c6557e7fSMartin Schwidefsky };
480c6557e7fSMartin Schwidefsky
481c6557e7fSMartin Schwidefsky #define PGM_OPERATION 0x01
482208dd756SThomas Huth #define PGM_PRIVILEGED_OP 0x02
483c6557e7fSMartin Schwidefsky #define PGM_EXECUTE 0x03
484c6557e7fSMartin Schwidefsky #define PGM_PROTECTION 0x04
485c6557e7fSMartin Schwidefsky #define PGM_ADDRESSING 0x05
486c6557e7fSMartin Schwidefsky #define PGM_SPECIFICATION 0x06
487c6557e7fSMartin Schwidefsky #define PGM_DATA 0x07
488bcd84683SJens Freimann #define PGM_FIXED_POINT_OVERFLOW 0x08
489bcd84683SJens Freimann #define PGM_FIXED_POINT_DIVIDE 0x09
490bcd84683SJens Freimann #define PGM_DECIMAL_OVERFLOW 0x0a
491bcd84683SJens Freimann #define PGM_DECIMAL_DIVIDE 0x0b
492bcd84683SJens Freimann #define PGM_HFP_EXPONENT_OVERFLOW 0x0c
493bcd84683SJens Freimann #define PGM_HFP_EXPONENT_UNDERFLOW 0x0d
494bcd84683SJens Freimann #define PGM_HFP_SIGNIFICANCE 0x0e
495bcd84683SJens Freimann #define PGM_HFP_DIVIDE 0x0f
496bcd84683SJens Freimann #define PGM_SEGMENT_TRANSLATION 0x10
497bcd84683SJens Freimann #define PGM_PAGE_TRANSLATION 0x11
498bcd84683SJens Freimann #define PGM_TRANSLATION_SPEC 0x12
499bcd84683SJens Freimann #define PGM_SPECIAL_OPERATION 0x13
500bcd84683SJens Freimann #define PGM_OPERAND 0x15
501bcd84683SJens Freimann #define PGM_TRACE_TABEL 0x16
502403c8648SEric Farman #define PGM_VECTOR_PROCESSING 0x1b
503bcd84683SJens Freimann #define PGM_SPACE_SWITCH 0x1c
504bcd84683SJens Freimann #define PGM_HFP_SQUARE_ROOT 0x1d
505bcd84683SJens Freimann #define PGM_PC_TRANSLATION_SPEC 0x1f
506bcd84683SJens Freimann #define PGM_AFX_TRANSLATION 0x20
507bcd84683SJens Freimann #define PGM_ASX_TRANSLATION 0x21
508bcd84683SJens Freimann #define PGM_LX_TRANSLATION 0x22
509bcd84683SJens Freimann #define PGM_EX_TRANSLATION 0x23
510bcd84683SJens Freimann #define PGM_PRIMARY_AUTHORITY 0x24
511bcd84683SJens Freimann #define PGM_SECONDARY_AUTHORITY 0x25
512bcd84683SJens Freimann #define PGM_LFX_TRANSLATION 0x26
513bcd84683SJens Freimann #define PGM_LSX_TRANSLATION 0x27
514bcd84683SJens Freimann #define PGM_ALET_SPECIFICATION 0x28
515bcd84683SJens Freimann #define PGM_ALEN_TRANSLATION 0x29
516bcd84683SJens Freimann #define PGM_ALE_SEQUENCE 0x2a
517bcd84683SJens Freimann #define PGM_ASTE_VALIDITY 0x2b
518bcd84683SJens Freimann #define PGM_ASTE_SEQUENCE 0x2c
519bcd84683SJens Freimann #define PGM_EXTENDED_AUTHORITY 0x2d
520bcd84683SJens Freimann #define PGM_LSTE_SEQUENCE 0x2e
521bcd84683SJens Freimann #define PGM_ASTE_INSTANCE 0x2f
522bcd84683SJens Freimann #define PGM_STACK_FULL 0x30
523bcd84683SJens Freimann #define PGM_STACK_EMPTY 0x31
524bcd84683SJens Freimann #define PGM_STACK_SPECIFICATION 0x32
525bcd84683SJens Freimann #define PGM_STACK_TYPE 0x33
526bcd84683SJens Freimann #define PGM_STACK_OPERATION 0x34
527bcd84683SJens Freimann #define PGM_ASCE_TYPE 0x38
528bcd84683SJens Freimann #define PGM_REGION_FIRST_TRANS 0x39
529bcd84683SJens Freimann #define PGM_REGION_SECOND_TRANS 0x3a
530bcd84683SJens Freimann #define PGM_REGION_THIRD_TRANS 0x3b
531bcd84683SJens Freimann #define PGM_MONITOR 0x40
532bcd84683SJens Freimann #define PGM_PER 0x80
533bcd84683SJens Freimann #define PGM_CRYPTO_OPERATION 0x119
534c6557e7fSMartin Schwidefsky
535c7901a6eSMichael Mueller /* irq types in ascend order of priorities */
536c0e6159dSJens Freimann enum irq_types {
537c7901a6eSMichael Mueller IRQ_PEND_SET_PREFIX = 0,
538c0e6159dSJens Freimann IRQ_PEND_RESTART,
539c7901a6eSMichael Mueller IRQ_PEND_SIGP_STOP,
540c7901a6eSMichael Mueller IRQ_PEND_IO_ISC_7,
541c7901a6eSMichael Mueller IRQ_PEND_IO_ISC_6,
542c7901a6eSMichael Mueller IRQ_PEND_IO_ISC_5,
543c7901a6eSMichael Mueller IRQ_PEND_IO_ISC_4,
544c7901a6eSMichael Mueller IRQ_PEND_IO_ISC_3,
545c7901a6eSMichael Mueller IRQ_PEND_IO_ISC_2,
546c7901a6eSMichael Mueller IRQ_PEND_IO_ISC_1,
547c7901a6eSMichael Mueller IRQ_PEND_IO_ISC_0,
548c7901a6eSMichael Mueller IRQ_PEND_VIRTIO,
549c7901a6eSMichael Mueller IRQ_PEND_PFAULT_DONE,
550c7901a6eSMichael Mueller IRQ_PEND_PFAULT_INIT,
551c7901a6eSMichael Mueller IRQ_PEND_EXT_HOST,
552c7901a6eSMichael Mueller IRQ_PEND_EXT_SERVICE,
5530890ddeaSChristian Borntraeger IRQ_PEND_EXT_SERVICE_EV,
554c7901a6eSMichael Mueller IRQ_PEND_EXT_TIMING,
555c7901a6eSMichael Mueller IRQ_PEND_EXT_CPU_TIMER,
556c7901a6eSMichael Mueller IRQ_PEND_EXT_CLOCK_COMP,
557c7901a6eSMichael Mueller IRQ_PEND_EXT_EXTERNAL,
558c7901a6eSMichael Mueller IRQ_PEND_EXT_EMERGENCY,
559c7901a6eSMichael Mueller IRQ_PEND_EXT_MALFUNC,
560c7901a6eSMichael Mueller IRQ_PEND_EXT_IRQ_KEY,
561c7901a6eSMichael Mueller IRQ_PEND_MCHK_REP,
562c7901a6eSMichael Mueller IRQ_PEND_PROG,
563c7901a6eSMichael Mueller IRQ_PEND_SVC,
564c7901a6eSMichael Mueller IRQ_PEND_MCHK_EX,
565c0e6159dSJens Freimann IRQ_PEND_COUNT
566c0e6159dSJens Freimann };
567c0e6159dSJens Freimann
5686d3da241SJens Freimann /* We have 2M for virtio device descriptor pages. Smallest amount of
5696d3da241SJens Freimann * memory per page is 24 bytes (1 queue), so (2048*1024) / 24 = 87381
5706d3da241SJens Freimann */
5716d3da241SJens Freimann #define KVM_S390_MAX_VIRTIO_IRQS 87381
5726d3da241SJens Freimann
573c0e6159dSJens Freimann /*
574c0e6159dSJens Freimann * Repressible (non-floating) machine check interrupts
575c0e6159dSJens Freimann * subclass bits in MCIC
576c0e6159dSJens Freimann */
577c0e6159dSJens Freimann #define MCHK_EXTD_BIT 58
578c0e6159dSJens Freimann #define MCHK_DEGR_BIT 56
579c0e6159dSJens Freimann #define MCHK_WARN_BIT 55
580c0e6159dSJens Freimann #define MCHK_REP_MASK ((1UL << MCHK_DEGR_BIT) | \
581c0e6159dSJens Freimann (1UL << MCHK_EXTD_BIT) | \
582c0e6159dSJens Freimann (1UL << MCHK_WARN_BIT))
583c0e6159dSJens Freimann
584c0e6159dSJens Freimann /* Exigent machine check interrupts subclass bits in MCIC */
585c0e6159dSJens Freimann #define MCHK_SD_BIT 63
586c0e6159dSJens Freimann #define MCHK_PD_BIT 62
587c0e6159dSJens Freimann #define MCHK_EX_MASK ((1UL << MCHK_SD_BIT) | (1UL << MCHK_PD_BIT))
588c0e6159dSJens Freimann
589c0e6159dSJens Freimann #define IRQ_PEND_EXT_MASK ((1UL << IRQ_PEND_EXT_IRQ_KEY) | \
590c0e6159dSJens Freimann (1UL << IRQ_PEND_EXT_CLOCK_COMP) | \
591c0e6159dSJens Freimann (1UL << IRQ_PEND_EXT_CPU_TIMER) | \
592c0e6159dSJens Freimann (1UL << IRQ_PEND_EXT_MALFUNC) | \
593c0e6159dSJens Freimann (1UL << IRQ_PEND_EXT_EMERGENCY) | \
594c0e6159dSJens Freimann (1UL << IRQ_PEND_EXT_EXTERNAL) | \
595c0e6159dSJens Freimann (1UL << IRQ_PEND_EXT_TIMING) | \
596c0e6159dSJens Freimann (1UL << IRQ_PEND_EXT_HOST) | \
597c0e6159dSJens Freimann (1UL << IRQ_PEND_EXT_SERVICE) | \
5980890ddeaSChristian Borntraeger (1UL << IRQ_PEND_EXT_SERVICE_EV) | \
599c0e6159dSJens Freimann (1UL << IRQ_PEND_VIRTIO) | \
600c0e6159dSJens Freimann (1UL << IRQ_PEND_PFAULT_INIT) | \
601c0e6159dSJens Freimann (1UL << IRQ_PEND_PFAULT_DONE))
602c0e6159dSJens Freimann
603c0e6159dSJens Freimann #define IRQ_PEND_IO_MASK ((1UL << IRQ_PEND_IO_ISC_0) | \
604c0e6159dSJens Freimann (1UL << IRQ_PEND_IO_ISC_1) | \
605c0e6159dSJens Freimann (1UL << IRQ_PEND_IO_ISC_2) | \
606c0e6159dSJens Freimann (1UL << IRQ_PEND_IO_ISC_3) | \
607c0e6159dSJens Freimann (1UL << IRQ_PEND_IO_ISC_4) | \
608c0e6159dSJens Freimann (1UL << IRQ_PEND_IO_ISC_5) | \
609c0e6159dSJens Freimann (1UL << IRQ_PEND_IO_ISC_6) | \
610c0e6159dSJens Freimann (1UL << IRQ_PEND_IO_ISC_7))
611c0e6159dSJens Freimann
612c0e6159dSJens Freimann #define IRQ_PEND_MCHK_MASK ((1UL << IRQ_PEND_MCHK_REP) | \
613c0e6159dSJens Freimann (1UL << IRQ_PEND_MCHK_EX))
614c0e6159dSJens Freimann
615201ae986SMichael Mueller #define IRQ_PEND_EXT_II_MASK ((1UL << IRQ_PEND_EXT_CPU_TIMER) | \
616201ae986SMichael Mueller (1UL << IRQ_PEND_EXT_CLOCK_COMP) | \
617201ae986SMichael Mueller (1UL << IRQ_PEND_EXT_EMERGENCY) | \
618201ae986SMichael Mueller (1UL << IRQ_PEND_EXT_EXTERNAL) | \
6190890ddeaSChristian Borntraeger (1UL << IRQ_PEND_EXT_SERVICE) | \
6200890ddeaSChristian Borntraeger (1UL << IRQ_PEND_EXT_SERVICE_EV))
621201ae986SMichael Mueller
622c6557e7fSMartin Schwidefsky struct kvm_s390_interrupt_info {
623c6557e7fSMartin Schwidefsky struct list_head list;
624c6557e7fSMartin Schwidefsky u64 type;
625c6557e7fSMartin Schwidefsky union {
626c6557e7fSMartin Schwidefsky struct kvm_s390_io_info io;
627c6557e7fSMartin Schwidefsky struct kvm_s390_ext_info ext;
628c6557e7fSMartin Schwidefsky struct kvm_s390_pgm_info pgm;
6298bb3a2ebSChristian Ehrhardt struct kvm_s390_emerg_info emerg;
6307697e71fSChristian Ehrhardt struct kvm_s390_extcall_info extcall;
631c6557e7fSMartin Schwidefsky struct kvm_s390_prefix_info prefix;
6322822545fSDavid Hildenbrand struct kvm_s390_stop_info stop;
63348a3e950SCornelia Huck struct kvm_s390_mchk_info mchk;
634c6557e7fSMartin Schwidefsky };
635c6557e7fSMartin Schwidefsky };
636c6557e7fSMartin Schwidefsky
637c0e6159dSJens Freimann struct kvm_s390_irq_payload {
638c0e6159dSJens Freimann struct kvm_s390_io_info io;
639c0e6159dSJens Freimann struct kvm_s390_ext_info ext;
640c0e6159dSJens Freimann struct kvm_s390_pgm_info pgm;
641c0e6159dSJens Freimann struct kvm_s390_emerg_info emerg;
642c0e6159dSJens Freimann struct kvm_s390_extcall_info extcall;
643c0e6159dSJens Freimann struct kvm_s390_prefix_info prefix;
6442822545fSDavid Hildenbrand struct kvm_s390_stop_info stop;
645c0e6159dSJens Freimann struct kvm_s390_mchk_info mchk;
646c0e6159dSJens Freimann };
647c0e6159dSJens Freimann
648c6557e7fSMartin Schwidefsky struct kvm_s390_local_interrupt {
649c6557e7fSMartin Schwidefsky spinlock_t lock;
650c0e6159dSJens Freimann DECLARE_BITMAP(sigp_emerg_pending, KVM_MAX_VCPUS);
651c0e6159dSJens Freimann struct kvm_s390_irq_payload irq;
652c0e6159dSJens Freimann unsigned long pending_irqs;
653c6557e7fSMartin Schwidefsky };
654c6557e7fSMartin Schwidefsky
6556d3da241SJens Freimann #define FIRQ_LIST_IO_ISC_0 0
6566d3da241SJens Freimann #define FIRQ_LIST_IO_ISC_1 1
6576d3da241SJens Freimann #define FIRQ_LIST_IO_ISC_2 2
6586d3da241SJens Freimann #define FIRQ_LIST_IO_ISC_3 3
6596d3da241SJens Freimann #define FIRQ_LIST_IO_ISC_4 4
6606d3da241SJens Freimann #define FIRQ_LIST_IO_ISC_5 5
6616d3da241SJens Freimann #define FIRQ_LIST_IO_ISC_6 6
6626d3da241SJens Freimann #define FIRQ_LIST_IO_ISC_7 7
6636d3da241SJens Freimann #define FIRQ_LIST_PFAULT 8
6646d3da241SJens Freimann #define FIRQ_LIST_VIRTIO 9
6656d3da241SJens Freimann #define FIRQ_LIST_COUNT 10
6666d3da241SJens Freimann #define FIRQ_CNTR_IO 0
6676d3da241SJens Freimann #define FIRQ_CNTR_SERVICE 1
6686d3da241SJens Freimann #define FIRQ_CNTR_VIRTIO 2
6696d3da241SJens Freimann #define FIRQ_CNTR_PFAULT 3
6706d3da241SJens Freimann #define FIRQ_MAX_COUNT 4
6716d3da241SJens Freimann
67251978393SFei Li /* mask the AIS mode for a given ISC */
67351978393SFei Li #define AIS_MODE_MASK(isc) (0x80 >> isc)
67451978393SFei Li
67551978393SFei Li #define KVM_S390_AIS_MODE_ALL 0
67651978393SFei Li #define KVM_S390_AIS_MODE_SINGLE 1
67751978393SFei Li
678c6557e7fSMartin Schwidefsky struct kvm_s390_float_interrupt {
6796d3da241SJens Freimann unsigned long pending_irqs;
6800890ddeaSChristian Borntraeger unsigned long masked_irqs;
681c6557e7fSMartin Schwidefsky spinlock_t lock;
6826d3da241SJens Freimann struct list_head lists[FIRQ_LIST_COUNT];
6836d3da241SJens Freimann int counters[FIRQ_MAX_COUNT];
6846d3da241SJens Freimann struct kvm_s390_mchk_info mchk;
6856d3da241SJens Freimann struct kvm_s390_ext_info srv_signal;
686c6557e7fSMartin Schwidefsky int next_rr_cpu;
68751978393SFei Li struct mutex ais_lock;
68851978393SFei Li u8 simm;
68951978393SFei Li u8 nimm;
690c6557e7fSMartin Schwidefsky };
691c6557e7fSMartin Schwidefsky
69227291e21SDavid Hildenbrand struct kvm_hw_wp_info_arch {
69327291e21SDavid Hildenbrand unsigned long addr;
69427291e21SDavid Hildenbrand unsigned long phys_addr;
69527291e21SDavid Hildenbrand int len;
69627291e21SDavid Hildenbrand char *old_data;
69727291e21SDavid Hildenbrand };
69827291e21SDavid Hildenbrand
69927291e21SDavid Hildenbrand struct kvm_hw_bp_info_arch {
70027291e21SDavid Hildenbrand unsigned long addr;
70127291e21SDavid Hildenbrand int len;
70227291e21SDavid Hildenbrand };
70327291e21SDavid Hildenbrand
70427291e21SDavid Hildenbrand /*
70527291e21SDavid Hildenbrand * Only the upper 16 bits of kvm_guest_debug->control are arch specific.
70627291e21SDavid Hildenbrand * Further KVM_GUESTDBG flags which an be used from userspace can be found in
70727291e21SDavid Hildenbrand * arch/s390/include/uapi/asm/kvm.h
70827291e21SDavid Hildenbrand */
70927291e21SDavid Hildenbrand #define KVM_GUESTDBG_EXIT_PENDING 0x10000000
71027291e21SDavid Hildenbrand
71127291e21SDavid Hildenbrand #define guestdbg_enabled(vcpu) \
71227291e21SDavid Hildenbrand (vcpu->guest_debug & KVM_GUESTDBG_ENABLE)
71327291e21SDavid Hildenbrand #define guestdbg_sstep_enabled(vcpu) \
71427291e21SDavid Hildenbrand (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
71527291e21SDavid Hildenbrand #define guestdbg_hw_bp_enabled(vcpu) \
71627291e21SDavid Hildenbrand (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)
71727291e21SDavid Hildenbrand #define guestdbg_exit_pending(vcpu) (guestdbg_enabled(vcpu) && \
71827291e21SDavid Hildenbrand (vcpu->guest_debug & KVM_GUESTDBG_EXIT_PENDING))
71927291e21SDavid Hildenbrand
720a43b80b7SMaxim Levitsky #define KVM_GUESTDBG_VALID_MASK \
721a43b80b7SMaxim Levitsky (KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP |\
722a43b80b7SMaxim Levitsky KVM_GUESTDBG_USE_HW_BP | KVM_GUESTDBG_EXIT_PENDING)
723a43b80b7SMaxim Levitsky
72427291e21SDavid Hildenbrand struct kvm_guestdbg_info_arch {
72527291e21SDavid Hildenbrand unsigned long cr0;
72627291e21SDavid Hildenbrand unsigned long cr9;
72727291e21SDavid Hildenbrand unsigned long cr10;
72827291e21SDavid Hildenbrand unsigned long cr11;
72927291e21SDavid Hildenbrand struct kvm_hw_bp_info_arch *hw_bp_info;
73027291e21SDavid Hildenbrand struct kvm_hw_wp_info_arch *hw_wp_info;
73127291e21SDavid Hildenbrand int nr_hw_bp;
73227291e21SDavid Hildenbrand int nr_hw_wp;
73327291e21SDavid Hildenbrand unsigned long last_bp;
73427291e21SDavid Hildenbrand };
735c6557e7fSMartin Schwidefsky
73629b40f10SJanosch Frank struct kvm_s390_pv_vcpu {
73729b40f10SJanosch Frank u64 handle;
73829b40f10SJanosch Frank unsigned long stor_base;
73929b40f10SJanosch Frank };
74029b40f10SJanosch Frank
741c6557e7fSMartin Schwidefsky struct kvm_vcpu_arch {
742c6557e7fSMartin Schwidefsky struct kvm_s390_sie_block *sie_block;
743adbf1698SDavid Hildenbrand /* if vsie is active, currently executed shadow sie control block */
744adbf1698SDavid Hildenbrand struct kvm_s390_sie_block *vsie_block;
745c6557e7fSMartin Schwidefsky unsigned int host_acrs[NUM_ACRS];
7464e0b1ab7SFan Zhang struct gs_cb *host_gscb;
7479977e886SHendrik Brueckner struct fpu host_fpregs;
748c6557e7fSMartin Schwidefsky struct kvm_s390_local_interrupt local_int;
749ca872302SChristian Borntraeger struct hrtimer ckc_timer;
7501b0462e5SHeiko Carstens struct kvm_s390_pgm_info pgm;
751598841caSCarsten Otte struct gmap *gmap;
75237d9df98SDavid Hildenbrand /* backup location for the currently enabled gmap when scheduled out */
75337d9df98SDavid Hildenbrand struct gmap *enabled_gmap;
75427291e21SDavid Hildenbrand struct kvm_guestdbg_info_arch guestdbg;
7553c038e6bSDominik Dingel unsigned long pfault_token;
7563c038e6bSDominik Dingel unsigned long pfault_select;
7573c038e6bSDominik Dingel unsigned long pfault_compare;
758db0758b2SDavid Hildenbrand bool cputm_enabled;
7599c23a131SDavid Hildenbrand /*
7609c23a131SDavid Hildenbrand * The seqcount protects updates to cputm_start and sie_block.cputm,
7619c23a131SDavid Hildenbrand * this way we can have non-blocking reads with consistent values.
7629c23a131SDavid Hildenbrand * Only the owning VCPU thread (vcpu->cpu) is allowed to change these
7639c23a131SDavid Hildenbrand * values and to start/stop/enable/disable cpu timer accounting.
7649c23a131SDavid Hildenbrand */
7659c23a131SDavid Hildenbrand seqcount_t cputm_seqcount;
766db0758b2SDavid Hildenbrand __u64 cputm_start;
7674e0b1ab7SFan Zhang bool gs_enabled;
76857cb198cSJanosch Frank bool skey_enabled;
76929b40f10SJanosch Frank struct kvm_s390_pv_vcpu pv;
77023a60f83SCollin Walling union diag318_info diag318_info;
771c6557e7fSMartin Schwidefsky };
772c6557e7fSMartin Schwidefsky
773c6557e7fSMartin Schwidefsky struct kvm_vm_stat {
7740193cc90SJing Zhang struct kvm_vm_stat_generic generic;
775ccc40c53SChristian Borntraeger u64 inject_io;
776ccc40c53SChristian Borntraeger u64 inject_float_mchk;
777ccc40c53SChristian Borntraeger u64 inject_pfault_done;
778ccc40c53SChristian Borntraeger u64 inject_service_signal;
779ccc40c53SChristian Borntraeger u64 inject_virtio;
78073f91b00SMatthew Rosato u64 aen_forward;
78199b86c9bSNico Boehr u64 gmap_shadow_create;
78299b86c9bSNico Boehr u64 gmap_shadow_reuse;
78399b86c9bSNico Boehr u64 gmap_shadow_r1_entry;
78499b86c9bSNico Boehr u64 gmap_shadow_r2_entry;
78599b86c9bSNico Boehr u64 gmap_shadow_r3_entry;
78699b86c9bSNico Boehr u64 gmap_shadow_sg_entry;
78799b86c9bSNico Boehr u64 gmap_shadow_pg_entry;
788c6557e7fSMartin Schwidefsky };
789c6557e7fSMartin Schwidefsky
790db3fe4ebSTakuya Yoshikawa struct kvm_arch_memory_slot {
791db3fe4ebSTakuya Yoshikawa };
792db3fe4ebSTakuya Yoshikawa
793841b91c5SCornelia Huck struct s390_map_info {
794841b91c5SCornelia Huck struct list_head list;
795841b91c5SCornelia Huck __u64 guest_addr;
796841b91c5SCornelia Huck __u64 addr;
797841b91c5SCornelia Huck struct page *page;
798841b91c5SCornelia Huck };
799841b91c5SCornelia Huck
800841b91c5SCornelia Huck struct s390_io_adapter {
801841b91c5SCornelia Huck unsigned int id;
802841b91c5SCornelia Huck int isc;
803841b91c5SCornelia Huck bool maskable;
804841b91c5SCornelia Huck bool masked;
805841b91c5SCornelia Huck bool swap;
80608fab50dSFei Li bool suppressible;
807841b91c5SCornelia Huck };
808841b91c5SCornelia Huck
809841b91c5SCornelia Huck #define MAX_S390_IO_ADAPTERS ((MAX_ISC + 1) * 8)
810841b91c5SCornelia Huck #define MAX_S390_ADAPTER_MAPS 256
811841b91c5SCornelia Huck
8129d8d5786SMichael Mueller /* maximum size of facilities and facility mask is 2k bytes */
8139d8d5786SMichael Mueller #define S390_ARCH_FAC_LIST_SIZE_BYTE (1<<11)
8149d8d5786SMichael Mueller #define S390_ARCH_FAC_LIST_SIZE_U64 \
8159d8d5786SMichael Mueller (S390_ARCH_FAC_LIST_SIZE_BYTE / sizeof(u64))
8169d8d5786SMichael Mueller #define S390_ARCH_FAC_MASK_SIZE_BYTE S390_ARCH_FAC_LIST_SIZE_BYTE
8179d8d5786SMichael Mueller #define S390_ARCH_FAC_MASK_SIZE_U64 \
8189d8d5786SMichael Mueller (S390_ARCH_FAC_MASK_SIZE_BYTE / sizeof(u64))
8199d8d5786SMichael Mueller
8209d8d5786SMichael Mueller struct kvm_s390_cpu_model {
821c54f0d6aSDavid Hildenbrand /* facility mask supported by kvm & hosting machine */
822c54f0d6aSDavid Hildenbrand __u64 fac_mask[S390_ARCH_FAC_LIST_SIZE_U64];
823346fa2f8SChristian Borntraeger struct kvm_s390_vm_cpu_subfunc subfuncs;
824c54f0d6aSDavid Hildenbrand /* facility list requested by guest (in dma page) */
825c54f0d6aSDavid Hildenbrand __u64 *fac_list;
8269bb0ec09SDavid Hildenbrand u64 cpuid;
827658b6edaSMichael Mueller unsigned short ibc;
82819c654bfSSteffen Eiden /* subset of available UV-features for pv-guests enabled by user space */
82919c654bfSSteffen Eiden struct kvm_s390_vm_cpu_uv_feat uv_feat_guest;
8309d8d5786SMichael Mueller };
8319d8d5786SMichael Mueller
8321e753732STony Krowiak typedef int (*crypto_hook)(struct kvm_vcpu *vcpu);
833e5282de9SPierre Morel
8345102ee87STony Krowiak struct kvm_s390_crypto {
8355102ee87STony Krowiak struct kvm_s390_crypto_cb *crycb;
8361e753732STony Krowiak struct rw_semaphore pqap_hook_rwsem;
8371e753732STony Krowiak crypto_hook *pqap_hook;
8385102ee87STony Krowiak __u32 crycbd;
839a374e892STony Krowiak __u8 aes_kw;
840a374e892STony Krowiak __u8 dea_kw;
841e585b24aSTony Krowiak __u8 apie;
8425102ee87STony Krowiak };
8435102ee87STony Krowiak
844ba850a8eSTony Krowiak #define APCB0_MASK_SIZE 1
845ba850a8eSTony Krowiak struct kvm_s390_apcb0 {
846ba850a8eSTony Krowiak __u64 apm[APCB0_MASK_SIZE]; /* 0x0000 */
847ba850a8eSTony Krowiak __u64 aqm[APCB0_MASK_SIZE]; /* 0x0008 */
848ba850a8eSTony Krowiak __u64 adm[APCB0_MASK_SIZE]; /* 0x0010 */
849ba850a8eSTony Krowiak __u64 reserved18; /* 0x0018 */
850ba850a8eSTony Krowiak };
851ba850a8eSTony Krowiak
852ba850a8eSTony Krowiak #define APCB1_MASK_SIZE 4
853ba850a8eSTony Krowiak struct kvm_s390_apcb1 {
854ba850a8eSTony Krowiak __u64 apm[APCB1_MASK_SIZE]; /* 0x0000 */
855ba850a8eSTony Krowiak __u64 aqm[APCB1_MASK_SIZE]; /* 0x0020 */
856ba850a8eSTony Krowiak __u64 adm[APCB1_MASK_SIZE]; /* 0x0040 */
857ba850a8eSTony Krowiak __u64 reserved60[4]; /* 0x0060 */
858ba850a8eSTony Krowiak };
859ba850a8eSTony Krowiak
8605102ee87STony Krowiak struct kvm_s390_crypto_cb {
861ba850a8eSTony Krowiak struct kvm_s390_apcb0 apcb0; /* 0x0000 */
862ba850a8eSTony Krowiak __u8 reserved20[0x0048 - 0x0020]; /* 0x0020 */
863a374e892STony Krowiak __u8 dea_wrapping_key_mask[24]; /* 0x0048 */
864a374e892STony Krowiak __u8 aes_wrapping_key_mask[32]; /* 0x0060 */
865ba850a8eSTony Krowiak struct kvm_s390_apcb1 apcb1; /* 0x0080 */
8665102ee87STony Krowiak };
8675102ee87STony Krowiak
86819114bebSMichael Mueller struct kvm_s390_gisa {
8694b9f9525SMichael Mueller union {
8704b9f9525SMichael Mueller struct { /* common to all formats */
8714b9f9525SMichael Mueller u32 next_alert;
8724b9f9525SMichael Mueller u8 ipm;
8734b9f9525SMichael Mueller u8 reserved01[2];
8744b9f9525SMichael Mueller u8 iam;
8754b9f9525SMichael Mueller };
8764b9f9525SMichael Mueller struct { /* format 0 */
87719114bebSMichael Mueller u32 next_alert;
87819114bebSMichael Mueller u8 ipm;
87919114bebSMichael Mueller u8 reserved01;
88019114bebSMichael Mueller u8 : 6;
88119114bebSMichael Mueller u8 g : 1;
88219114bebSMichael Mueller u8 c : 1;
88319114bebSMichael Mueller u8 iam;
88419114bebSMichael Mueller u8 reserved02[4];
88519114bebSMichael Mueller u32 airq_count;
8864b9f9525SMichael Mueller } g0;
8874b9f9525SMichael Mueller struct { /* format 1 */
8884b9f9525SMichael Mueller u32 next_alert;
8894b9f9525SMichael Mueller u8 ipm;
8904b9f9525SMichael Mueller u8 simm;
8914b9f9525SMichael Mueller u8 nimm;
8924b9f9525SMichael Mueller u8 iam;
8934b9f9525SMichael Mueller u8 aism[8];
8944b9f9525SMichael Mueller u8 : 6;
8954b9f9525SMichael Mueller u8 g : 1;
8964b9f9525SMichael Mueller u8 c : 1;
8974b9f9525SMichael Mueller u8 reserved03[11];
8984b9f9525SMichael Mueller u32 airq_count;
8994b9f9525SMichael Mueller } g1;
9006cff2e10SMichael Mueller struct {
9016cff2e10SMichael Mueller u64 word[4];
9026cff2e10SMichael Mueller } u64;
9034b9f9525SMichael Mueller };
90419114bebSMichael Mueller };
90519114bebSMichael Mueller
9061282c21eSMichael Mueller struct kvm_s390_gib {
9071282c21eSMichael Mueller u32 alert_list_origin;
9081282c21eSMichael Mueller u32 reserved01;
9091282c21eSMichael Mueller u8:5;
9101282c21eSMichael Mueller u8 nisc:3;
9111282c21eSMichael Mueller u8 reserved03[3];
9121282c21eSMichael Mueller u32 reserved04[5];
9131282c21eSMichael Mueller };
9141282c21eSMichael Mueller
915c54f0d6aSDavid Hildenbrand /*
91619114bebSMichael Mueller * sie_page2 has to be allocated as DMA because fac_list, crycb and
91719114bebSMichael Mueller * gisa need 31bit addresses in the sie control block.
918c54f0d6aSDavid Hildenbrand */
919c54f0d6aSDavid Hildenbrand struct sie_page2 {
920c54f0d6aSDavid Hildenbrand __u64 fac_list[S390_ARCH_FAC_LIST_SIZE_U64]; /* 0x0000 */
921c54f0d6aSDavid Hildenbrand struct kvm_s390_crypto_cb crycb; /* 0x0800 */
92219114bebSMichael Mueller struct kvm_s390_gisa gisa; /* 0x0900 */
92325c84dbaSMichael Mueller struct kvm *kvm; /* 0x0920 */
92425c84dbaSMichael Mueller u8 reserved928[0x1000 - 0x928]; /* 0x0928 */
9251cae0255SMartin Schwidefsky };
926c54f0d6aSDavid Hildenbrand
927a3508fbeSDavid Hildenbrand struct kvm_s390_vsie {
928a3508fbeSDavid Hildenbrand struct mutex mutex;
929a3508fbeSDavid Hildenbrand struct radix_tree_root addr_to_page;
930a3508fbeSDavid Hildenbrand int page_count;
931a3508fbeSDavid Hildenbrand int next;
932a3508fbeSDavid Hildenbrand struct page *pages[KVM_MAX_VCPUS];
933a3508fbeSDavid Hildenbrand };
934a3508fbeSDavid Hildenbrand
9356cff2e10SMichael Mueller struct kvm_s390_gisa_iam {
9366cff2e10SMichael Mueller u8 mask;
9376cff2e10SMichael Mueller spinlock_t ref_lock;
9386cff2e10SMichael Mueller u32 ref_count[MAX_ISC + 1];
9396cff2e10SMichael Mueller };
9406cff2e10SMichael Mueller
941982cff42SMichael Mueller struct kvm_s390_gisa_interrupt {
942982cff42SMichael Mueller struct kvm_s390_gisa *origin;
9436cff2e10SMichael Mueller struct kvm_s390_gisa_iam alert;
9449f30f621SMichael Mueller struct hrtimer timer;
9459f30f621SMichael Mueller u64 expires;
9469f30f621SMichael Mueller DECLARE_BITMAP(kicked_mask, KVM_MAX_VCPUS);
947982cff42SMichael Mueller };
948982cff42SMichael Mueller
94929b40f10SJanosch Frank struct kvm_s390_pv {
95029b40f10SJanosch Frank u64 handle;
95129b40f10SJanosch Frank u64 guest_len;
95229b40f10SJanosch Frank unsigned long stor_base;
95329b40f10SJanosch Frank void *stor_var;
9540460eb35SJanosch Frank bool dumping;
955fb491d55SClaudio Imbrenda void *set_aside;
956fb491d55SClaudio Imbrenda struct list_head need_cleanup;
957ca2fd060SClaudio Imbrenda struct mmu_notifier mmu_notifier;
95829b40f10SJanosch Frank };
95929b40f10SJanosch Frank
960c6557e7fSMartin Schwidefsky struct kvm_arch{
9617d43bafcSEugene (jno) Dvurechenski void *sca;
9627d43bafcSEugene (jno) Dvurechenski int use_esca;
9635e044315SEugene (jno) Dvurechenski rwlock_t sca_lock;
964c6557e7fSMartin Schwidefsky debug_info_t *dbf;
965c6557e7fSMartin Schwidefsky struct kvm_s390_float_interrupt float_int;
966c05c4186SJens Freimann struct kvm_device *flic;
967598841caSCarsten Otte struct gmap *gmap;
968a3a92c31SDominik Dingel unsigned long mem_limit;
969fa6b7fe9SCornelia Huck int css_support;
97084223598SCornelia Huck int use_irqchip;
971b31605c1SDominik Dingel int use_cmma;
972c9f0a2b8SJanosch Frank int use_pfmfi;
97355531b74SJanosch Frank int use_skf;
9743f4bbb43SMatthew Rosato int use_zpci_interp;
9756352e4d2SDavid Hildenbrand int user_cpu_state_ctrl;
9762444b352SDavid Hildenbrand int user_sigp;
977e44fc8c9SEkaterina Tumanova int user_stsi;
9786502a34cSDavid Hildenbrand int user_instr0;
979841b91c5SCornelia Huck struct s390_io_adapter *adapters[MAX_S390_IO_ADAPTERS];
9808a242234SHeiko Carstens wait_queue_head_t ipte_wq;
981a6b7e459SThomas Huth int ipte_lock_count;
982a6b7e459SThomas Huth struct mutex ipte_mutex;
9838ad35755SDavid Hildenbrand spinlock_t start_stop_lock;
984c54f0d6aSDavid Hildenbrand struct sie_page2 *sie_page2;
9859d8d5786SMichael Mueller struct kvm_s390_cpu_model model;
9865102ee87STony Krowiak struct kvm_s390_crypto crypto;
987a3508fbeSDavid Hildenbrand struct kvm_s390_vsie vsie;
9888fa1696eSCollin L. Walling u8 epdx;
98972f25020SJason J. Herne u64 epoch;
990afdad616SClaudio Imbrenda int migration_mode;
991afdad616SClaudio Imbrenda atomic64_t cmma_dirty_pages;
99215c9705fSDavid Hildenbrand /* subset of available cpu features enabled by user space */
99315c9705fSDavid Hildenbrand DECLARE_BITMAP(cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
994a3e03bc1SHalil Pasic /* indexed by vcpu_idx */
995246b7218SMichael Mueller DECLARE_BITMAP(idle_mask, KVM_MAX_VCPUS);
996982cff42SMichael Mueller struct kvm_s390_gisa_interrupt gisa_int;
99729b40f10SJanosch Frank struct kvm_s390_pv pv;
99809340b2fSMatthew Rosato struct list_head kzdev_list;
99909340b2fSMatthew Rosato spinlock_t kzdev_list_lock;
1000c6557e7fSMartin Schwidefsky };
1001c6557e7fSMartin Schwidefsky
1002bf640876SDominik Dingel #define KVM_HVA_ERR_BAD (-1UL)
1003bf640876SDominik Dingel #define KVM_HVA_ERR_RO_BAD (-2UL)
1004bf640876SDominik Dingel
kvm_is_error_hva(unsigned long addr)1005bf640876SDominik Dingel static inline bool kvm_is_error_hva(unsigned long addr)
1006bf640876SDominik Dingel {
1007bf640876SDominik Dingel return IS_ERR_VALUE(addr);
1008bf640876SDominik Dingel }
1009bf640876SDominik Dingel
10103c038e6bSDominik Dingel #define ASYNC_PF_PER_VCPU 64
10113c038e6bSDominik Dingel struct kvm_arch_async_pf {
10123c038e6bSDominik Dingel unsigned long pfault_token;
10133c038e6bSDominik Dingel };
10143c038e6bSDominik Dingel
10157c0ade6cSVitaly Kuznetsov bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu);
10163c038e6bSDominik Dingel
10173c038e6bSDominik Dingel void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu,
10183c038e6bSDominik Dingel struct kvm_async_pf *work);
10193c038e6bSDominik Dingel
10202a18b7e7SVitaly Kuznetsov bool kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu,
10213c038e6bSDominik Dingel struct kvm_async_pf *work);
10223c038e6bSDominik Dingel
10233c038e6bSDominik Dingel void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
10243c038e6bSDominik Dingel struct kvm_async_pf *work);
10253c038e6bSDominik Dingel
kvm_arch_async_page_present_queued(struct kvm_vcpu * vcpu)1026557a961aSVitaly Kuznetsov static inline void kvm_arch_async_page_present_queued(struct kvm_vcpu *vcpu) {}
1027557a961aSVitaly Kuznetsov
102842104598STony Krowiak void kvm_arch_crypto_clear_masks(struct kvm *kvm);
10290e237e44SPierre Morel void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,
10300e237e44SPierre Morel unsigned long *aqm, unsigned long *adm);
103142104598STony Krowiak
10326b33e68aSNico Boehr int __sie64a(phys_addr_t sie_block_phys, struct kvm_s390_sie_block *sie_block, u64 *rsa);
10336b33e68aSNico Boehr
sie64a(struct kvm_s390_sie_block * sie_block,u64 * rsa)10346b33e68aSNico Boehr static inline int sie64a(struct kvm_s390_sie_block *sie_block, u64 *rsa)
10356b33e68aSNico Boehr {
10366b33e68aSNico Boehr return __sie64a(virt_to_phys(sie_block), sie_block, rsa);
10376b33e68aSNico Boehr }
10386b33e68aSNico Boehr
1039b764bb1cSHeinz Graalfs extern char sie_exit;
10400865e636SRadim Krčmář
1041fb5040efSTony Krowiak bool kvm_s390_pv_is_protected(struct kvm *kvm);
1042fb5040efSTony Krowiak bool kvm_s390_pv_cpu_is_protected(struct kvm_vcpu *vcpu);
1043fb5040efSTony Krowiak
10446cff2e10SMichael Mueller extern int kvm_s390_gisc_register(struct kvm *kvm, u32 gisc);
10456cff2e10SMichael Mueller extern int kvm_s390_gisc_unregister(struct kvm *kvm, u32 gisc);
10466cff2e10SMichael Mueller
kvm_arch_sync_events(struct kvm * kvm)10470865e636SRadim Krčmář static inline void kvm_arch_sync_events(struct kvm *kvm) {}
kvm_arch_sched_in(struct kvm_vcpu * vcpu,int cpu)10480865e636SRadim Krčmář static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
kvm_arch_free_memslot(struct kvm * kvm,struct kvm_memory_slot * slot)10490865e636SRadim Krčmář static inline void kvm_arch_free_memslot(struct kvm *kvm,
1050e96c81eeSSean Christopherson struct kvm_memory_slot *slot) {}
kvm_arch_memslots_updated(struct kvm * kvm,u64 gen)105115248258SSean Christopherson static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
kvm_arch_flush_shadow_all(struct kvm * kvm)10520865e636SRadim Krčmář static inline void kvm_arch_flush_shadow_all(struct kvm *kvm) {}
kvm_arch_flush_shadow_memslot(struct kvm * kvm,struct kvm_memory_slot * slot)10530865e636SRadim Krčmář static inline void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
10540865e636SRadim Krčmář struct kvm_memory_slot *slot) {}
kvm_arch_vcpu_blocking(struct kvm_vcpu * vcpu)10553217f7c2SChristoffer Dall static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {}
kvm_arch_vcpu_unblocking(struct kvm_vcpu * vcpu)10563217f7c2SChristoffer Dall static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
10570865e636SRadim Krčmář
105809340b2fSMatthew Rosato #define __KVM_HAVE_ARCH_VM_FREE
105909340b2fSMatthew Rosato void kvm_arch_free_vm(struct kvm *kvm);
106009340b2fSMatthew Rosato
1061ca922fecSPierre Morel struct zpci_kvm_hook {
1062ca922fecSPierre Morel int (*kvm_register)(void *opaque, struct kvm *kvm);
1063ca922fecSPierre Morel void (*kvm_unregister)(void *opaque);
1064ca922fecSPierre Morel };
1065ca922fecSPierre Morel
1066ca922fecSPierre Morel extern struct zpci_kvm_hook zpci_kvm_hook;
106709340b2fSMatthew Rosato
1068c6557e7fSMartin Schwidefsky #endif
1069