xref: /kvm-unit-tests/lib/s390x/asm/sie-arch.h (revision 1f08a91a41402b0e032ecce8ed1b5952cbfca0ea)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _S390X_SIE_ARCH_H_
3 #define _S390X_SIE_ARCH_H_
4 
5 #include <stdint.h>
6 #include <asm/arch_def.h>
7 
8 #define CPUSTAT_STOPPED    0x80000000
9 #define CPUSTAT_WAIT       0x10000000
10 #define CPUSTAT_ECALL_PEND 0x08000000
11 #define CPUSTAT_STOP_INT   0x04000000
12 #define CPUSTAT_IO_INT     0x02000000
13 #define CPUSTAT_EXT_INT    0x01000000
14 #define CPUSTAT_RUNNING    0x00800000
15 #define CPUSTAT_RETAINED   0x00400000
16 #define CPUSTAT_TIMING_SUB 0x00020000
17 #define CPUSTAT_SIE_SUB    0x00010000
18 #define CPUSTAT_RRF        0x00008000
19 #define CPUSTAT_SLSV       0x00004000
20 #define CPUSTAT_SLSR       0x00002000
21 #define CPUSTAT_ZARCH      0x00000800
22 #define CPUSTAT_MCDS       0x00000100
23 #define CPUSTAT_KSS        0x00000200
24 #define CPUSTAT_SM         0x00000080
25 #define CPUSTAT_IBS        0x00000040
26 #define CPUSTAT_GED2       0x00000010
27 #define CPUSTAT_G          0x00000008
28 #define CPUSTAT_GED        0x00000004
29 #define CPUSTAT_J          0x00000002
30 #define CPUSTAT_P          0x00000001
31 
32 struct kvm_s390_sie_block {
33 	uint32_t 	cpuflags;		/* 0x0000 */
34 	uint32_t : 1;			/* 0x0004 */
35 	uint32_t 	prefix : 18;
36 	uint32_t : 1;
37 	uint32_t 	ibc : 12;
38 	uint8_t		reserved08[4];		/* 0x0008 */
39 #define PROG_IN_SIE (1<<0)
40 	uint32_t	prog0c;			/* 0x000c */
41 union {
42 		uint8_t	reserved10[16];		/* 0x0010 */
43 		struct {
44 			uint64_t	pv_handle_cpu;
45 			uint64_t	pv_handle_config;
46 		};
47 	};
48 #define PROG_BLOCK_SIE	(1<<0)
49 #define PROG_REQUEST	(1<<1)
50 	uint32_t 	prog20;		/* 0x0020 */
51 	uint8_t		reserved24[4];		/* 0x0024 */
52 	uint64_t	cputm;			/* 0x0028 */
53 	uint64_t	ckc;			/* 0x0030 */
54 	uint64_t	epoch;			/* 0x0038 */
55 	uint32_t	svcc;			/* 0x0040 */
56 #define LCTL_CR0	0x8000
57 #define LCTL_CR6	0x0200
58 #define LCTL_CR9	0x0040
59 #define LCTL_CR10	0x0020
60 #define LCTL_CR11	0x0010
61 #define LCTL_CR14	0x0002
62 	uint16_t   	lctl;			/* 0x0044 */
63 	int16_t		icpua;			/* 0x0046 */
64 #define ICTL_OPEREXC	0x80000000
65 #define ICTL_PINT	0x20000000
66 #define ICTL_LPSW	0x00400000
67 #define ICTL_STCTL	0x00040000
68 #define ICTL_ISKE	0x00004000
69 #define ICTL_SSKE	0x00002000
70 #define ICTL_RRBE	0x00001000
71 #define ICTL_TPROT	0x00000200
72 	uint32_t	ictl;			/* 0x0048 */
73 #define ECA_CEI		0x80000000
74 #define ECA_IB		0x40000000
75 #define ECA_SIGPI	0x10000000
76 #define ECA_MVPGI	0x01000000
77 #define ECA_AIV		0x00200000
78 #define ECA_VX		0x00020000
79 #define ECA_PROTEXCI	0x00002000
80 #define ECA_APIE	0x00000008
81 #define ECA_SII		0x00000001
82 	uint32_t	eca;			/* 0x004c */
83 #define ICPT_INST	0x04
84 #define ICPT_PROGI	0x08
85 #define ICPT_INSTPROGI	0x0C
86 #define ICPT_EXTREQ	0x10
87 #define ICPT_EXTINT	0x14
88 #define ICPT_IOREQ	0x18
89 #define ICPT_WAIT	0x1c
90 #define ICPT_VALIDITY	0x20
91 #define ICPT_STOP	0x28
92 #define ICPT_OPEREXC	0x2C
93 #define ICPT_PARTEXEC	0x38
94 #define ICPT_IOINST	0x40
95 #define ICPT_KSS	0x5c
96 #define ICPT_INT_ENABLE	0x64
97 #define ICPT_PV_INSTR	0x68
98 #define ICPT_PV_NOTIFY	0x6c
99 #define ICPT_PV_PREF	0x70
100 	uint8_t		icptcode;		/* 0x0050 */
101 	uint8_t		icptstatus;		/* 0x0051 */
102 	uint16_t	ihcpu;			/* 0x0052 */
103 	uint8_t		reserved54;		/* 0x0054 */
104 #define IICTL_CODE_NONE		 0x00
105 #define IICTL_CODE_MCHK		 0x01
106 #define IICTL_CODE_EXT		 0x02
107 #define IICTL_CODE_IO		 0x03
108 #define IICTL_CODE_RESTART	 0x04
109 #define IICTL_CODE_SPECIFICATION 0x10
110 #define IICTL_CODE_OPERAND	 0x11
111 	uint8_t		iictl;			/* 0x0055 */
112 	uint16_t	ipa;			/* 0x0056 */
113 	uint32_t	ipb;			/* 0x0058 */
114 	uint32_t	scaoh;			/* 0x005c */
115 #define FPF_BPBC 	0x20
116 	uint8_t		fpf;			/* 0x0060 */
117 #define ECB_GS		0x40
118 #define ECB_TE		0x10
119 #define ECB_SPECI	0x08
120 #define ECB_SRSI	0x04
121 #define ECB_HOSTPROTINT	0x02
122 	uint8_t		ecb;			/* 0x0061 */
123 #define ECB2_CMMA	0x80
124 #define ECB2_IEP	0x20
125 #define ECB2_PFMFI	0x08
126 #define ECB2_ESCA	0x04
127 	uint8_t    	ecb2;                   /* 0x0062 */
128 #define ECB3_DEA 0x08
129 #define ECB3_AES 0x04
130 #define ECB3_RI  0x01
131 	uint8_t    	ecb3;			/* 0x0063 */
132 	uint32_t	scaol;			/* 0x0064 */
133 	uint8_t		sdf;			/* 0x0068 */
134 	uint8_t    	epdx;			/* 0x0069 */
135 	uint8_t    	reserved6a[2];		/* 0x006a */
136 	uint32_t	todpr;			/* 0x006c */
137 #define GISA_FORMAT1 0x00000001
138 	uint32_t	gd;			/* 0x0070 */
139 	uint8_t		reserved74[12];		/* 0x0074 */
140 	uint64_t	mso;			/* 0x0080 */
141 	uint64_t	msl;			/* 0x0088 */
142 	struct psw	gpsw;			/* 0x0090 */
143 	uint64_t	gg14;			/* 0x00a0 */
144 	uint64_t	gg15;			/* 0x00a8 */
145 	uint8_t		reservedb0[8];		/* 0x00b0 */
146 #define HPID_KVM	0x4
147 #define HPID_VSIE	0x5
148 	uint8_t		hpid;			/* 0x00b8 */
149 	uint8_t		reservedb9[7];		/* 0x00b9 */
150 	union {
151 		struct {
152 			uint32_t	eiparams;	/* 0x00c0 */
153 			uint16_t	extcpuaddr;	/* 0x00c4 */
154 			uint16_t	eic;		/* 0x00c6 */
155 		};
156 		uint64_t	mcic;			/* 0x00c0 */
157 	} __attribute__ ((__packed__));
158 	uint32_t	reservedc8;		/* 0x00c8 */
159 	uint16_t	pgmilc;			/* 0x00cc */
160 	uint16_t	iprcc;			/* 0x00ce */
161 	uint32_t	dxc;			/* 0x00d0 */
162 	uint16_t	mcn;			/* 0x00d4 */
163 	uint8_t		perc;			/* 0x00d6 */
164 	uint8_t		peratmid;		/* 0x00d7 */
165 	uint64_t	peraddr;		/* 0x00d8 */
166 	uint8_t		eai;			/* 0x00e0 */
167 	uint8_t		peraid;			/* 0x00e1 */
168 	uint8_t		oai;			/* 0x00e2 */
169 	uint8_t		armid;			/* 0x00e3 */
170 	uint8_t		reservede4[4];		/* 0x00e4 */
171 	uint64_t	tecmc;			/* 0x00e8 */
172 	uint8_t		reservedf0[12];		/* 0x00f0 */
173 #define CRYCB_FORMAT_MASK 0x00000003
174 #define CRYCB_FORMAT0 0x00000000
175 #define CRYCB_FORMAT1 0x00000001
176 #define CRYCB_FORMAT2 0x00000003
177 	uint32_t	crycbd;			/* 0x00fc */
178 	uint64_t	gcr[16];		/* 0x0100 */
179 	union {
180 		uint64_t	gbea;			/* 0x0180 */
181 		uint64_t	sidad;
182 	};
183 	uint8_t		reserved188[8];		/* 0x0188 */
184 	uint64_t   	sdnxo;			/* 0x0190 */
185 	uint8_t    	reserved198[8];		/* 0x0198 */
186 	uint32_t	fac;			/* 0x01a0 */
187 	uint8_t		reserved1a4[20];	/* 0x01a4 */
188 	uint64_t	cbrlo;			/* 0x01b8 */
189 	uint8_t		reserved1c0[8];		/* 0x01c0 */
190 #define ECD_HOSTREGMGMT	0x20000000
191 #define ECD_MEF		0x08000000
192 #define ECD_ETOKENF	0x02000000
193 #define ECD_ECC		0x00200000
194 	uint32_t	ecd;			/* 0x01c8 */
195 	uint8_t		reserved1cc[18];	/* 0x01cc */
196 	uint64_t	pp;			/* 0x01de */
197 	uint8_t		reserved1e6[2];		/* 0x01e6 */
198 	uint64_t	itdba;			/* 0x01e8 */
199 	uint64_t   	riccbd;			/* 0x01f0 */
200 	uint64_t	gvrd;			/* 0x01f8 */
201 	uint64_t	reserved200[48];	/* 0x0200 */
202 	uint64_t	pv_grregs[16];		/* 0x0380 */
203 } __attribute__((packed));
204 
205 union esca_sigp_ctrl {
206 	uint16_t value;
207 	struct {
208 		uint8_t c : 1;
209 		uint8_t reserved: 7;
210 		uint8_t scn;
211 	};
212 };
213 
214 struct esca_entry {
215 	union esca_sigp_ctrl sigp_ctrl;
216 	uint16_t   reserved1[3];
217 	uint64_t   sda;
218 	uint64_t   reserved2[6];
219 };
220 
221 union ipte_control {
222 	unsigned long val;
223 	struct {
224 		unsigned long k  : 1;
225 		unsigned long kh : 31;
226 		unsigned long kg : 32;
227 	};
228 };
229 
230 struct esca_block {
231 	union ipte_control ipte_control;
232 	uint64_t   reserved1[7];
233 	uint64_t   mcn[4];
234 	uint64_t   reserved2[20];
235 	struct esca_entry cpu[256];
236 };
237 
238 #endif /* _S390X_SIE_ARCH_H_ */
239