Merge remote-tracking branch 'remotes/dgilbert-gitlab/tags/pull-virtiofs-20210216...
[qemu/ar7.git] / target / s390x / gen-features.c
bloba6ec918e901e873e16ace060476c4efe8c386251
1 /*
2 * S390 feature list generator
4 * Copyright IBM Corp. 2016, 2018
6 * Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
7 * David Hildenbrand <dahi@linux.vnet.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or (at
10 * your option) any later version. See the COPYING file in the top-level
11 * directory.
14 #include <inttypes.h>
15 #include <stdio.h>
16 #include <string.h>
17 #include "cpu_features_def.h"
19 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
21 /***** BEGIN FEATURE DEFS *****/
23 #define S390_FEAT_GROUP_PLO \
24 S390_FEAT_PLO_CL, \
25 S390_FEAT_PLO_CLG, \
26 S390_FEAT_PLO_CLGR, \
27 S390_FEAT_PLO_CLX, \
28 S390_FEAT_PLO_CS, \
29 S390_FEAT_PLO_CSG, \
30 S390_FEAT_PLO_CSGR, \
31 S390_FEAT_PLO_CSX, \
32 S390_FEAT_PLO_DCS, \
33 S390_FEAT_PLO_DCSG, \
34 S390_FEAT_PLO_DCSGR, \
35 S390_FEAT_PLO_DCSX, \
36 S390_FEAT_PLO_CSST, \
37 S390_FEAT_PLO_CSSTG, \
38 S390_FEAT_PLO_CSSTGR, \
39 S390_FEAT_PLO_CSSTX, \
40 S390_FEAT_PLO_CSDST, \
41 S390_FEAT_PLO_CSDSTG, \
42 S390_FEAT_PLO_CSDSTGR, \
43 S390_FEAT_PLO_CSDSTX, \
44 S390_FEAT_PLO_CSTST, \
45 S390_FEAT_PLO_CSTSTG, \
46 S390_FEAT_PLO_CSTSTGR, \
47 S390_FEAT_PLO_CSTSTX
49 #define S390_FEAT_GROUP_TOD_CLOCK_STEERING \
50 S390_FEAT_TOD_CLOCK_STEERING, \
51 S390_FEAT_PTFF_QTO, \
52 S390_FEAT_PTFF_QSI, \
53 S390_FEAT_PTFF_QPT, \
54 S390_FEAT_PTFF_STO
56 #define S390_FEAT_GROUP_GEN13_PTFF \
57 S390_FEAT_PTFF_QUI, \
58 S390_FEAT_PTFF_QTOU, \
59 S390_FEAT_PTFF_STOU
61 #define S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF \
62 S390_FEAT_PTFF_QSIE, \
63 S390_FEAT_PTFF_QTOUE, \
64 S390_FEAT_PTFF_STOE, \
65 S390_FEAT_PTFF_STOUE
67 #define S390_FEAT_GROUP_MSA \
68 S390_FEAT_MSA, \
69 S390_FEAT_KMAC_DEA, \
70 S390_FEAT_KMAC_TDEA_128, \
71 S390_FEAT_KMAC_TDEA_192, \
72 S390_FEAT_KMC_DEA, \
73 S390_FEAT_KMC_TDEA_128, \
74 S390_FEAT_KMC_TDEA_192, \
75 S390_FEAT_KM_DEA, \
76 S390_FEAT_KM_TDEA_128, \
77 S390_FEAT_KM_TDEA_192, \
78 S390_FEAT_KIMD_SHA_1, \
79 S390_FEAT_KLMD_SHA_1
81 #define S390_FEAT_GROUP_MSA_EXT_1 \
82 S390_FEAT_KMC_AES_128, \
83 S390_FEAT_KM_AES_128, \
84 S390_FEAT_KIMD_SHA_256, \
85 S390_FEAT_KLMD_SHA_256
87 #define S390_FEAT_GROUP_MSA_EXT_2 \
88 S390_FEAT_KMC_AES_192, \
89 S390_FEAT_KMC_AES_256, \
90 S390_FEAT_KMC_PRNG, \
91 S390_FEAT_KM_AES_192, \
92 S390_FEAT_KM_AES_256, \
93 S390_FEAT_KIMD_SHA_512, \
94 S390_FEAT_KLMD_SHA_512
96 #define S390_FEAT_GROUP_MSA_EXT_3 \
97 S390_FEAT_MSA_EXT_3, \
98 S390_FEAT_KMAC_EDEA, \
99 S390_FEAT_KMAC_ETDEA_128, \
100 S390_FEAT_KMAC_ETDEA_192, \
101 S390_FEAT_KMC_EAES_128, \
102 S390_FEAT_KMC_EAES_192, \
103 S390_FEAT_KMC_EAES_256, \
104 S390_FEAT_KMC_EDEA, \
105 S390_FEAT_KMC_ETDEA_128, \
106 S390_FEAT_KMC_ETDEA_192, \
107 S390_FEAT_KM_EDEA, \
108 S390_FEAT_KM_ETDEA_128, \
109 S390_FEAT_KM_ETDEA_192, \
110 S390_FEAT_KM_EAES_128, \
111 S390_FEAT_KM_EAES_192, \
112 S390_FEAT_KM_EAES_256, \
113 S390_FEAT_PCKMO_EDEA, \
114 S390_FEAT_PCKMO_ETDEA_128, \
115 S390_FEAT_PCKMO_ETDEA_256, \
116 S390_FEAT_PCKMO_AES_128, \
117 S390_FEAT_PCKMO_AES_192, \
118 S390_FEAT_PCKMO_AES_256
120 #define S390_FEAT_GROUP_MSA_EXT_4 \
121 S390_FEAT_MSA_EXT_4, \
122 S390_FEAT_KMAC_AES_128, \
123 S390_FEAT_KMAC_AES_192, \
124 S390_FEAT_KMAC_AES_256, \
125 S390_FEAT_KMAC_EAES_128, \
126 S390_FEAT_KMAC_EAES_192, \
127 S390_FEAT_KMAC_EAES_256, \
128 S390_FEAT_KM_XTS_AES_128, \
129 S390_FEAT_KM_XTS_AES_256, \
130 S390_FEAT_KM_XTS_EAES_128, \
131 S390_FEAT_KM_XTS_EAES_256, \
132 S390_FEAT_KIMD_GHASH, \
133 S390_FEAT_KMCTR_DEA, \
134 S390_FEAT_KMCTR_TDEA_128, \
135 S390_FEAT_KMCTR_TDEA_192, \
136 S390_FEAT_KMCTR_EDEA, \
137 S390_FEAT_KMCTR_ETDEA_128, \
138 S390_FEAT_KMCTR_ETDEA_192, \
139 S390_FEAT_KMCTR_AES_128, \
140 S390_FEAT_KMCTR_AES_192, \
141 S390_FEAT_KMCTR_AES_256, \
142 S390_FEAT_KMCTR_EAES_128, \
143 S390_FEAT_KMCTR_EAES_192, \
144 S390_FEAT_KMCTR_EAES_256, \
145 S390_FEAT_KMF_DEA, \
146 S390_FEAT_KMF_TDEA_128, \
147 S390_FEAT_KMF_TDEA_192, \
148 S390_FEAT_KMF_EDEA, \
149 S390_FEAT_KMF_ETDEA_128, \
150 S390_FEAT_KMF_ETDEA_192, \
151 S390_FEAT_KMF_AES_128, \
152 S390_FEAT_KMF_AES_192, \
153 S390_FEAT_KMF_AES_256, \
154 S390_FEAT_KMF_EAES_128, \
155 S390_FEAT_KMF_EAES_192, \
156 S390_FEAT_KMF_EAES_256, \
157 S390_FEAT_KMO_DEA, \
158 S390_FEAT_KMO_TDEA_128, \
159 S390_FEAT_KMO_TDEA_192, \
160 S390_FEAT_KMO_EDEA, \
161 S390_FEAT_KMO_ETDEA_128, \
162 S390_FEAT_KMO_ETDEA_192, \
163 S390_FEAT_KMO_AES_128, \
164 S390_FEAT_KMO_AES_192, \
165 S390_FEAT_KMO_AES_256, \
166 S390_FEAT_KMO_EAES_128, \
167 S390_FEAT_KMO_EAES_192, \
168 S390_FEAT_KMO_EAES_256, \
169 S390_FEAT_PCC_CMAC_DEA, \
170 S390_FEAT_PCC_CMAC_TDEA_128, \
171 S390_FEAT_PCC_CMAC_TDEA_192, \
172 S390_FEAT_PCC_CMAC_ETDEA_128, \
173 S390_FEAT_PCC_CMAC_ETDEA_192, \
174 S390_FEAT_PCC_CMAC_TDEA, \
175 S390_FEAT_PCC_CMAC_AES_128, \
176 S390_FEAT_PCC_CMAC_AES_192, \
177 S390_FEAT_PCC_CMAC_AES_256, \
178 S390_FEAT_PCC_CMAC_EAES_128, \
179 S390_FEAT_PCC_CMAC_EAES_192, \
180 S390_FEAT_PCC_CMAC_EAES_256, \
181 S390_FEAT_PCC_XTS_AES_128, \
182 S390_FEAT_PCC_XTS_AES_256, \
183 S390_FEAT_PCC_XTS_EAES_128, \
184 S390_FEAT_PCC_XTS_EAES_256
186 #define S390_FEAT_GROUP_MSA_EXT_5 \
187 S390_FEAT_MSA_EXT_5, \
188 S390_FEAT_PPNO_SHA_512_DRNG
190 #define S390_FEAT_GROUP_MSA_EXT_6 \
191 S390_FEAT_KIMD_SHA3_224, \
192 S390_FEAT_KIMD_SHA3_256, \
193 S390_FEAT_KIMD_SHA3_384, \
194 S390_FEAT_KIMD_SHA3_512, \
195 S390_FEAT_KIMD_SHAKE_128, \
196 S390_FEAT_KIMD_SHAKE_256, \
197 S390_FEAT_KLMD_SHA3_224, \
198 S390_FEAT_KLMD_SHA3_256, \
199 S390_FEAT_KLMD_SHA3_384, \
200 S390_FEAT_KLMD_SHA3_512, \
201 S390_FEAT_KLMD_SHAKE_128, \
202 S390_FEAT_KLMD_SHAKE_256
204 #define S390_FEAT_GROUP_MSA_EXT_7 \
205 S390_FEAT_PRNO_TRNG_QRTCR, \
206 S390_FEAT_PRNO_TRNG
208 #define S390_FEAT_GROUP_MSA_EXT_8 \
209 S390_FEAT_MSA_EXT_8, \
210 S390_FEAT_KMA_GCM_AES_128, \
211 S390_FEAT_KMA_GCM_AES_192, \
212 S390_FEAT_KMA_GCM_AES_256 , \
213 S390_FEAT_KMA_GCM_EAES_128, \
214 S390_FEAT_KMA_GCM_EAES_192, \
215 S390_FEAT_KMA_GCM_EAES_256
217 #define S390_FEAT_GROUP_MSA_EXT_9 \
218 S390_FEAT_MSA_EXT_9, \
219 S390_FEAT_KDSA_ECDSA_VERIFY_P256, \
220 S390_FEAT_KDSA_ECDSA_VERIFY_P384, \
221 S390_FEAT_KDSA_ECDSA_VERIFY_P512, \
222 S390_FEAT_KDSA_ECDSA_SIGN_P256, \
223 S390_FEAT_KDSA_ECDSA_SIGN_P384, \
224 S390_FEAT_KDSA_ECDSA_SIGN_P512, \
225 S390_FEAT_KDSA_EECDSA_SIGN_P256, \
226 S390_FEAT_KDSA_EECDSA_SIGN_P384, \
227 S390_FEAT_KDSA_EECDSA_SIGN_P512, \
228 S390_FEAT_KDSA_EDDSA_VERIFY_ED25519, \
229 S390_FEAT_KDSA_EDDSA_VERIFY_ED448, \
230 S390_FEAT_KDSA_EDDSA_SIGN_ED25519, \
231 S390_FEAT_KDSA_EDDSA_SIGN_ED448, \
232 S390_FEAT_KDSA_EEDDSA_SIGN_ED25519, \
233 S390_FEAT_KDSA_EEDDSA_SIGN_ED448, \
234 S390_FEAT_PCC_SCALAR_MULT_P256, \
235 S390_FEAT_PCC_SCALAR_MULT_P384, \
236 S390_FEAT_PCC_SCALAR_MULT_P512, \
237 S390_FEAT_PCC_SCALAR_MULT_ED25519, \
238 S390_FEAT_PCC_SCALAR_MULT_ED448, \
239 S390_FEAT_PCC_SCALAR_MULT_X25519, \
240 S390_FEAT_PCC_SCALAR_MULT_X448
242 #define S390_FEAT_GROUP_MSA_EXT_9_PCKMO \
243 S390_FEAT_PCKMO_ECC_P256, \
244 S390_FEAT_PCKMO_ECC_P384, \
245 S390_FEAT_PCKMO_ECC_P521, \
246 S390_FEAT_PCKMO_ECC_ED25519, \
247 S390_FEAT_PCKMO_ECC_ED448
249 #define S390_FEAT_GROUP_ENH_SORT \
250 S390_FEAT_ESORT_BASE, \
251 S390_FEAT_SORTL_SFLR, \
252 S390_FEAT_SORTL_SVLR, \
253 S390_FEAT_SORTL_32, \
254 S390_FEAT_SORTL_128, \
255 S390_FEAT_SORTL_F0
258 #define S390_FEAT_GROUP_DEFLATE_CONVERSION \
259 S390_FEAT_DEFLATE_BASE, \
260 S390_FEAT_DEFLATE_GHDT, \
261 S390_FEAT_DEFLATE_CMPR, \
262 S390_FEAT_DEFLATE_XPND, \
263 S390_FEAT_DEFLATE_F0
265 /* cpu feature groups */
266 static uint16_t group_PLO[] = {
267 S390_FEAT_GROUP_PLO,
269 static uint16_t group_TOD_CLOCK_STEERING[] = {
270 S390_FEAT_GROUP_TOD_CLOCK_STEERING,
272 static uint16_t group_GEN13_PTFF[] = {
273 S390_FEAT_GROUP_GEN13_PTFF,
275 static uint16_t group_MULTIPLE_EPOCH_PTFF[] = {
276 S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,
278 static uint16_t group_MSA[] = {
279 S390_FEAT_GROUP_MSA,
281 static uint16_t group_MSA_EXT_1[] = {
282 S390_FEAT_GROUP_MSA_EXT_1,
284 static uint16_t group_MSA_EXT_2[] = {
285 S390_FEAT_GROUP_MSA_EXT_2,
287 static uint16_t group_MSA_EXT_3[] = {
288 S390_FEAT_GROUP_MSA_EXT_3,
290 static uint16_t group_MSA_EXT_4[] = {
291 S390_FEAT_GROUP_MSA_EXT_4,
293 static uint16_t group_MSA_EXT_5[] = {
294 S390_FEAT_GROUP_MSA_EXT_5,
296 static uint16_t group_MSA_EXT_6[] = {
297 S390_FEAT_GROUP_MSA_EXT_6,
299 static uint16_t group_MSA_EXT_7[] = {
300 S390_FEAT_GROUP_MSA_EXT_7,
302 static uint16_t group_MSA_EXT_8[] = {
303 S390_FEAT_GROUP_MSA_EXT_8,
306 static uint16_t group_MSA_EXT_9[] = {
307 S390_FEAT_GROUP_MSA_EXT_9,
310 static uint16_t group_MSA_EXT_9_PCKMO[] = {
311 S390_FEAT_GROUP_MSA_EXT_9_PCKMO,
314 static uint16_t group_ENH_SORT[] = {
315 S390_FEAT_GROUP_ENH_SORT,
318 static uint16_t group_DEFLATE_CONVERSION[] = {
319 S390_FEAT_GROUP_DEFLATE_CONVERSION,
322 /* Base features (in order of release)
323 * Only non-hypervisor managed features belong here.
324 * Base feature sets are static meaning they do not change in future QEMU
325 * releases.
327 static uint16_t base_GEN7_GA1[] = {
328 S390_FEAT_GROUP_PLO,
329 S390_FEAT_ESAN3,
330 S390_FEAT_ZARCH,
333 #define base_GEN7_GA2 EmptyFeat
334 #define base_GEN7_GA3 EmptyFeat
336 static uint16_t base_GEN8_GA1[] = {
337 S390_FEAT_DAT_ENH,
338 S390_FEAT_EXTENDED_TRANSLATION_2,
339 S390_FEAT_GROUP_MSA,
340 S390_FEAT_LONG_DISPLACEMENT,
341 S390_FEAT_LONG_DISPLACEMENT_FAST,
342 S390_FEAT_HFP_MADDSUB,
345 #define base_GEN8_GA2 EmptyFeat
346 #define base_GEN8_GA3 EmptyFeat
347 #define base_GEN8_GA4 EmptyFeat
348 #define base_GEN8_GA5 EmptyFeat
350 static uint16_t base_GEN9_GA1[] = {
351 S390_FEAT_IDTE_SEGMENT,
352 S390_FEAT_ASN_LX_REUSE,
353 S390_FEAT_STFLE,
354 S390_FEAT_SENSE_RUNNING_STATUS,
355 S390_FEAT_EXTENDED_IMMEDIATE,
356 S390_FEAT_EXTENDED_TRANSLATION_3,
357 S390_FEAT_HFP_UNNORMALIZED_EXT,
358 S390_FEAT_ETF2_ENH,
359 S390_FEAT_STORE_CLOCK_FAST,
360 S390_FEAT_GROUP_TOD_CLOCK_STEERING,
361 S390_FEAT_ETF3_ENH,
362 S390_FEAT_DAT_ENH_2,
365 #define base_GEN9_GA2 EmptyFeat
366 #define base_GEN9_GA3 EmptyFeat
368 static uint16_t base_GEN10_GA1[] = {
369 S390_FEAT_CONDITIONAL_SSKE,
370 S390_FEAT_PARSING_ENH,
371 S390_FEAT_MOVE_WITH_OPTIONAL_SPEC,
372 S390_FEAT_EXTRACT_CPU_TIME,
373 S390_FEAT_COMPARE_AND_SWAP_AND_STORE,
374 S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2,
375 S390_FEAT_GENERAL_INSTRUCTIONS_EXT,
376 S390_FEAT_EXECUTE_EXT,
377 S390_FEAT_FLOATING_POINT_SUPPPORT_ENH,
378 S390_FEAT_DFP,
379 S390_FEAT_DFP_FAST,
380 S390_FEAT_PFPO,
382 #define base_GEN10_GA2 EmptyFeat
383 #define base_GEN10_GA3 EmptyFeat
385 static uint16_t base_GEN11_GA1[] = {
386 S390_FEAT_NONQ_KEY_SETTING,
387 S390_FEAT_ENHANCED_MONITOR,
388 S390_FEAT_FLOATING_POINT_EXT,
389 S390_FEAT_SET_PROGRAM_PARAMETERS,
390 S390_FEAT_STFLE_45,
391 S390_FEAT_CMPSC_ENH,
392 S390_FEAT_INTERLOCKED_ACCESS_2,
395 #define base_GEN11_GA2 EmptyFeat
397 static uint16_t base_GEN12_GA1[] = {
398 S390_FEAT_DFP_ZONED_CONVERSION,
399 S390_FEAT_STFLE_49,
400 S390_FEAT_LOCAL_TLB_CLEARING,
403 #define base_GEN12_GA2 EmptyFeat
405 static uint16_t base_GEN13_GA1[] = {
406 S390_FEAT_STFLE_53,
407 S390_FEAT_DFP_PACKED_CONVERSION,
408 S390_FEAT_GROUP_GEN13_PTFF,
411 #define base_GEN13_GA2 EmptyFeat
413 static uint16_t base_GEN14_GA1[] = {
414 S390_FEAT_ENTROPY_ENC_COMP,
415 S390_FEAT_MISC_INSTRUCTION_EXT2,
416 S390_FEAT_SEMAPHORE_ASSIST,
417 S390_FEAT_TIME_SLICE_INSTRUMENTATION,
418 S390_FEAT_ORDER_PRESERVING_COMPRESSION,
421 #define base_GEN14_GA2 EmptyFeat
423 static uint16_t base_GEN15_GA1[] = {
424 S390_FEAT_MISC_INSTRUCTION_EXT3,
427 /* Full features (in order of release)
428 * Automatically includes corresponding base features.
429 * Full features are all features this hardware supports even if kvm/QEMU do not
430 * support these features yet.
432 static uint16_t full_GEN7_GA1[] = {
433 S390_FEAT_PPA15,
434 S390_FEAT_BPB,
435 S390_FEAT_SIE_F2,
436 S390_FEAT_SIE_SKEY,
437 S390_FEAT_SIE_GPERE,
438 S390_FEAT_SIE_IB,
439 S390_FEAT_SIE_CEI,
442 static uint16_t full_GEN7_GA2[] = {
443 S390_FEAT_EXTENDED_TRANSLATION_2,
446 static uint16_t full_GEN7_GA3[] = {
447 S390_FEAT_LONG_DISPLACEMENT,
448 S390_FEAT_SIE_SIIF,
451 static uint16_t full_GEN8_GA1[] = {
452 S390_FEAT_SIE_GSLS,
453 S390_FEAT_SIE_64BSCAO,
456 #define full_GEN8_GA2 EmptyFeat
458 static uint16_t full_GEN8_GA3[] = {
459 S390_FEAT_ASN_LX_REUSE,
460 S390_FEAT_EXTENDED_TRANSLATION_3,
463 #define full_GEN8_GA4 EmptyFeat
464 #define full_GEN8_GA5 EmptyFeat
466 static uint16_t full_GEN9_GA1[] = {
467 S390_FEAT_STORE_HYPERVISOR_INFO,
468 S390_FEAT_GROUP_MSA_EXT_1,
469 S390_FEAT_CMM,
470 S390_FEAT_SIE_CMMA,
473 static uint16_t full_GEN9_GA2[] = {
474 S390_FEAT_MOVE_WITH_OPTIONAL_SPEC,
475 S390_FEAT_EXTRACT_CPU_TIME,
476 S390_FEAT_COMPARE_AND_SWAP_AND_STORE,
477 S390_FEAT_FLOATING_POINT_SUPPPORT_ENH,
478 S390_FEAT_DFP,
481 static uint16_t full_GEN9_GA3[] = {
482 S390_FEAT_CONDITIONAL_SSKE,
483 S390_FEAT_PFPO,
486 static uint16_t full_GEN10_GA1[] = {
487 S390_FEAT_EDAT,
488 S390_FEAT_CONFIGURATION_TOPOLOGY,
489 S390_FEAT_GROUP_MSA_EXT_2,
490 S390_FEAT_ESOP,
491 S390_FEAT_SIE_PFMFI,
492 S390_FEAT_SIE_SIGPIF,
495 static uint16_t full_GEN10_GA2[] = {
496 S390_FEAT_SET_PROGRAM_PARAMETERS,
497 S390_FEAT_SIE_IBS,
500 static uint16_t full_GEN10_GA3[] = {
501 S390_FEAT_GROUP_MSA_EXT_3,
504 static uint16_t full_GEN11_GA1[] = {
505 S390_FEAT_IPTE_RANGE,
506 S390_FEAT_ACCESS_EXCEPTION_FS_INDICATION,
507 S390_FEAT_GROUP_MSA_EXT_4,
510 #define full_GEN11_GA2 EmptyFeat
512 static uint16_t full_GEN12_GA1[] = {
513 S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE,
514 S390_FEAT_TRANSACTIONAL_EXE,
515 S390_FEAT_RUNTIME_INSTRUMENTATION,
516 S390_FEAT_ZPCI,
517 S390_FEAT_ADAPTER_EVENT_NOTIFICATION,
518 S390_FEAT_ADAPTER_INT_SUPPRESSION,
519 S390_FEAT_EDAT_2,
520 S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2,
521 S390_FEAT_AP_QUERY_CONFIG_INFO,
522 S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL,
523 S390_FEAT_AP_FACILITIES_TEST,
524 S390_FEAT_AP,
525 S390_FEAT_EXTENDED_LENGTH_SCCB,
526 S390_FEAT_DIAG_318,
529 static uint16_t full_GEN12_GA2[] = {
530 S390_FEAT_GROUP_MSA_EXT_5,
533 static uint16_t full_GEN13_GA1[] = {
534 S390_FEAT_VECTOR,
537 #define full_GEN13_GA2 EmptyFeat
539 static uint16_t full_GEN14_GA1[] = {
540 S390_FEAT_INSTRUCTION_EXEC_PROT,
541 S390_FEAT_GUARDED_STORAGE,
542 S390_FEAT_VECTOR_PACKED_DECIMAL,
543 S390_FEAT_VECTOR_ENH,
544 S390_FEAT_MULTIPLE_EPOCH,
545 S390_FEAT_TEST_PENDING_EXT_INTERRUPTION,
546 S390_FEAT_INSERT_REFERENCE_BITS_MULT,
547 S390_FEAT_GROUP_MSA_EXT_6,
548 S390_FEAT_GROUP_MSA_EXT_7,
549 S390_FEAT_GROUP_MSA_EXT_8,
550 S390_FEAT_CMM_NT,
551 S390_FEAT_ETOKEN,
552 S390_FEAT_HPMA2,
553 S390_FEAT_SIE_KSS,
554 S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,
557 #define full_GEN14_GA2 EmptyFeat
559 static uint16_t full_GEN15_GA1[] = {
560 S390_FEAT_VECTOR_ENH2,
561 S390_FEAT_GROUP_ENH_SORT,
562 S390_FEAT_GROUP_DEFLATE_CONVERSION,
563 S390_FEAT_VECTOR_PACKED_DECIMAL_ENH,
564 S390_FEAT_GROUP_MSA_EXT_9,
565 S390_FEAT_GROUP_MSA_EXT_9_PCKMO,
566 S390_FEAT_ETOKEN,
567 S390_FEAT_UNPACK,
570 /* Default features (in order of release)
571 * Automatically includes corresponding base features.
572 * Default features are all features this version of QEMU supports for this
573 * hardware model. Default feature sets can grow with new QEMU releases.
575 #define default_GEN7_GA1 EmptyFeat
576 #define default_GEN7_GA2 EmptyFeat
577 #define default_GEN7_GA3 EmptyFeat
578 #define default_GEN8_GA1 EmptyFeat
579 #define default_GEN8_GA2 EmptyFeat
580 #define default_GEN8_GA3 EmptyFeat
581 #define default_GEN8_GA4 EmptyFeat
582 #define default_GEN8_GA5 EmptyFeat
584 static uint16_t default_GEN9_GA1[] = {
585 S390_FEAT_STORE_HYPERVISOR_INFO,
586 S390_FEAT_GROUP_MSA_EXT_1,
587 S390_FEAT_CMM,
590 #define default_GEN9_GA2 EmptyFeat
591 #define default_GEN9_GA3 EmptyFeat
593 static uint16_t default_GEN10_GA1[] = {
594 S390_FEAT_EDAT,
595 S390_FEAT_GROUP_MSA_EXT_2,
598 #define default_GEN10_GA2 EmptyFeat
599 #define default_GEN10_GA3 EmptyFeat
601 static uint16_t default_GEN11_GA1[] = {
602 S390_FEAT_GROUP_MSA_EXT_3,
603 S390_FEAT_IPTE_RANGE,
604 S390_FEAT_ACCESS_EXCEPTION_FS_INDICATION,
605 S390_FEAT_GROUP_MSA_EXT_4,
606 S390_FEAT_PPA15,
607 S390_FEAT_BPB,
610 #define default_GEN11_GA2 EmptyFeat
612 static uint16_t default_GEN12_GA1[] = {
613 S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE,
614 S390_FEAT_TRANSACTIONAL_EXE,
615 S390_FEAT_RUNTIME_INSTRUMENTATION,
616 S390_FEAT_ZPCI,
617 S390_FEAT_ADAPTER_EVENT_NOTIFICATION,
618 S390_FEAT_EDAT_2,
619 S390_FEAT_ESOP,
620 S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2,
623 #define default_GEN12_GA2 EmptyFeat
625 static uint16_t default_GEN13_GA1[] = {
626 S390_FEAT_GROUP_MSA_EXT_5,
627 S390_FEAT_VECTOR,
630 #define default_GEN13_GA2 EmptyFeat
632 static uint16_t default_GEN14_GA1[] = {
633 S390_FEAT_INSTRUCTION_EXEC_PROT,
634 S390_FEAT_GUARDED_STORAGE,
635 S390_FEAT_VECTOR_PACKED_DECIMAL,
636 S390_FEAT_VECTOR_ENH,
637 S390_FEAT_GROUP_MSA_EXT_6,
638 S390_FEAT_GROUP_MSA_EXT_7,
639 S390_FEAT_GROUP_MSA_EXT_8,
640 S390_FEAT_MULTIPLE_EPOCH,
641 S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,
644 #define default_GEN14_GA2 EmptyFeat
646 static uint16_t default_GEN15_GA1[] = {
647 S390_FEAT_VECTOR_ENH2,
648 S390_FEAT_GROUP_DEFLATE_CONVERSION,
649 S390_FEAT_VECTOR_PACKED_DECIMAL_ENH,
650 S390_FEAT_GROUP_MSA_EXT_9,
651 S390_FEAT_GROUP_MSA_EXT_9_PCKMO,
652 S390_FEAT_ETOKEN,
655 /* QEMU (CPU model) features */
657 static uint16_t qemu_V2_11[] = {
658 S390_FEAT_GROUP_PLO,
659 S390_FEAT_ESAN3,
660 S390_FEAT_ZARCH,
663 static uint16_t qemu_V3_1[] = {
664 S390_FEAT_DAT_ENH,
665 S390_FEAT_IDTE_SEGMENT,
666 S390_FEAT_STFLE,
667 S390_FEAT_SENSE_RUNNING_STATUS,
668 S390_FEAT_EXTENDED_TRANSLATION_2,
669 S390_FEAT_MSA,
670 S390_FEAT_LONG_DISPLACEMENT,
671 S390_FEAT_LONG_DISPLACEMENT_FAST,
672 S390_FEAT_EXTENDED_IMMEDIATE,
673 S390_FEAT_EXTENDED_TRANSLATION_3,
674 S390_FEAT_ETF2_ENH,
675 S390_FEAT_STORE_CLOCK_FAST,
676 S390_FEAT_MOVE_WITH_OPTIONAL_SPEC,
677 S390_FEAT_ETF3_ENH,
678 S390_FEAT_EXTRACT_CPU_TIME,
679 S390_FEAT_COMPARE_AND_SWAP_AND_STORE,
680 S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2,
681 S390_FEAT_GENERAL_INSTRUCTIONS_EXT,
682 S390_FEAT_EXECUTE_EXT,
683 S390_FEAT_SET_PROGRAM_PARAMETERS,
684 S390_FEAT_FLOATING_POINT_SUPPPORT_ENH,
685 S390_FEAT_STFLE_45,
686 S390_FEAT_STFLE_49,
687 S390_FEAT_LOCAL_TLB_CLEARING,
688 S390_FEAT_INTERLOCKED_ACCESS_2,
689 S390_FEAT_ADAPTER_EVENT_NOTIFICATION,
690 S390_FEAT_ADAPTER_INT_SUPPRESSION,
691 S390_FEAT_MSA_EXT_3,
692 S390_FEAT_MSA_EXT_4,
695 static uint16_t qemu_V4_0[] = {
697 * Only BFP bits are implemented (HFP, DFP, PFPO and DIVIDE TO INTEGER not
698 * implemented yet).
700 S390_FEAT_FLOATING_POINT_EXT,
701 S390_FEAT_ZPCI,
704 static uint16_t qemu_V4_1[] = {
705 S390_FEAT_STFLE_53,
706 S390_FEAT_VECTOR,
709 static uint16_t qemu_LATEST[] = {
710 S390_FEAT_ACCESS_EXCEPTION_FS_INDICATION,
711 S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2,
712 S390_FEAT_ESOP,
715 /* add all new definitions before this point */
716 static uint16_t qemu_MAX[] = {
717 /* generates a dependency warning, leave it out for now */
718 S390_FEAT_MSA_EXT_5,
719 /* features introduced after the z13 */
720 S390_FEAT_INSTRUCTION_EXEC_PROT,
721 S390_FEAT_MISC_INSTRUCTION_EXT2,
722 S390_FEAT_MSA_EXT_8,
725 /****** END FEATURE DEFS ******/
727 #define _YEARS "2016"
728 #define _NAME_H "TARGET_S390X_GEN_FEATURES_H"
730 #define CPU_FEAT_INITIALIZER(_name) \
732 .name = "S390_FEAT_LIST_" #_name, \
733 .base_bits = \
734 { .data = base_##_name, \
735 .len = ARRAY_SIZE(base_##_name) }, \
736 .default_bits = \
737 { .data = default_##_name, \
738 .len = ARRAY_SIZE(default_##_name) }, \
739 .full_bits = \
740 { .data = full_##_name, \
741 .len = ARRAY_SIZE(full_##_name) }, \
744 typedef struct BitSpec {
745 uint16_t *data;
746 uint32_t len;
747 } BitSpec;
749 typedef struct {
750 const char *name;
751 BitSpec base_bits;
752 BitSpec default_bits;
753 BitSpec full_bits;
754 } CpuFeatDefSpec;
756 static uint16_t EmptyFeat[] = {};
758 /*******************************
759 * processor GA series
760 *******************************/
761 static CpuFeatDefSpec CpuFeatDef[] = {
762 CPU_FEAT_INITIALIZER(GEN7_GA1),
763 CPU_FEAT_INITIALIZER(GEN7_GA2),
764 CPU_FEAT_INITIALIZER(GEN7_GA3),
765 CPU_FEAT_INITIALIZER(GEN8_GA1),
766 CPU_FEAT_INITIALIZER(GEN8_GA2),
767 CPU_FEAT_INITIALIZER(GEN8_GA3),
768 CPU_FEAT_INITIALIZER(GEN8_GA4),
769 CPU_FEAT_INITIALIZER(GEN8_GA5),
770 CPU_FEAT_INITIALIZER(GEN9_GA1),
771 CPU_FEAT_INITIALIZER(GEN9_GA2),
772 CPU_FEAT_INITIALIZER(GEN9_GA3),
773 CPU_FEAT_INITIALIZER(GEN10_GA1),
774 CPU_FEAT_INITIALIZER(GEN10_GA2),
775 CPU_FEAT_INITIALIZER(GEN10_GA3),
776 CPU_FEAT_INITIALIZER(GEN11_GA1),
777 CPU_FEAT_INITIALIZER(GEN11_GA2),
778 CPU_FEAT_INITIALIZER(GEN12_GA1),
779 CPU_FEAT_INITIALIZER(GEN12_GA2),
780 CPU_FEAT_INITIALIZER(GEN13_GA1),
781 CPU_FEAT_INITIALIZER(GEN13_GA2),
782 CPU_FEAT_INITIALIZER(GEN14_GA1),
783 CPU_FEAT_INITIALIZER(GEN14_GA2),
784 CPU_FEAT_INITIALIZER(GEN15_GA1),
787 #define FEAT_GROUP_INITIALIZER(_name) \
789 .name = "S390_FEAT_GROUP_LIST_" #_name, \
790 .enum_name = "S390_FEAT_GROUP_" #_name, \
791 .bits = \
792 { .data = group_##_name, \
793 .len = ARRAY_SIZE(group_##_name) }, \
796 typedef struct {
797 const char *name;
798 const char *enum_name;
799 BitSpec bits;
800 } FeatGroupDefSpec;
802 /*******************************
803 * feature groups
804 *******************************/
805 static FeatGroupDefSpec FeatGroupDef[] = {
806 FEAT_GROUP_INITIALIZER(PLO),
807 FEAT_GROUP_INITIALIZER(TOD_CLOCK_STEERING),
808 FEAT_GROUP_INITIALIZER(GEN13_PTFF),
809 FEAT_GROUP_INITIALIZER(MSA),
810 FEAT_GROUP_INITIALIZER(MSA_EXT_1),
811 FEAT_GROUP_INITIALIZER(MSA_EXT_2),
812 FEAT_GROUP_INITIALIZER(MSA_EXT_3),
813 FEAT_GROUP_INITIALIZER(MSA_EXT_4),
814 FEAT_GROUP_INITIALIZER(MSA_EXT_5),
815 FEAT_GROUP_INITIALIZER(MSA_EXT_6),
816 FEAT_GROUP_INITIALIZER(MSA_EXT_7),
817 FEAT_GROUP_INITIALIZER(MSA_EXT_8),
818 FEAT_GROUP_INITIALIZER(MSA_EXT_9),
819 FEAT_GROUP_INITIALIZER(MSA_EXT_9_PCKMO),
820 FEAT_GROUP_INITIALIZER(MULTIPLE_EPOCH_PTFF),
821 FEAT_GROUP_INITIALIZER(ENH_SORT),
822 FEAT_GROUP_INITIALIZER(DEFLATE_CONVERSION),
825 #define QEMU_FEAT_INITIALIZER(_name) \
827 .name = "S390_FEAT_LIST_QEMU_" #_name, \
828 .bits = \
829 { .data = qemu_##_name, \
830 .len = ARRAY_SIZE(qemu_##_name) }, \
833 /*******************************
834 * QEMU (CPU model) features
835 *******************************/
836 static FeatGroupDefSpec QemuFeatDef[] = {
837 QEMU_FEAT_INITIALIZER(V2_11),
838 QEMU_FEAT_INITIALIZER(V3_1),
839 QEMU_FEAT_INITIALIZER(V4_0),
840 QEMU_FEAT_INITIALIZER(V4_1),
841 QEMU_FEAT_INITIALIZER(LATEST),
842 QEMU_FEAT_INITIALIZER(MAX),
846 static void set_bits(uint64_t list[], BitSpec bits)
848 uint32_t i;
850 for (i = 0; i < bits.len; i++) {
851 list[bits.data[i] / 64] |= 1ULL << (bits.data[i] % 64);
855 static inline void clear_bit(uint64_t list[], unsigned long nr)
857 list[nr / 64] &= ~(1ULL << (nr % 64));
860 static void print_feature_defs(void)
862 uint64_t base_feat[S390_FEAT_MAX / 64 + 1] = {};
863 uint64_t default_feat[S390_FEAT_MAX / 64 + 1] = {};
864 uint64_t full_feat[S390_FEAT_MAX / 64 + 1] = {};
865 int i, j;
867 printf("\n/* CPU model feature list data */\n");
869 for (i = 0; i < ARRAY_SIZE(CpuFeatDef); i++) {
870 /* With gen15 CSSKE and BPB are deprecated */
871 if (strcmp(CpuFeatDef[i].name, "S390_FEAT_LIST_GEN15_GA1") == 0) {
872 clear_bit(base_feat, S390_FEAT_CONDITIONAL_SSKE);
873 clear_bit(default_feat, S390_FEAT_CONDITIONAL_SSKE);
874 clear_bit(default_feat, S390_FEAT_BPB);
876 set_bits(base_feat, CpuFeatDef[i].base_bits);
877 /* add the base to the default features */
878 set_bits(default_feat, CpuFeatDef[i].base_bits);
879 set_bits(default_feat, CpuFeatDef[i].default_bits);
880 /* add the base to the full features */
881 set_bits(full_feat, CpuFeatDef[i].base_bits);
882 set_bits(full_feat, CpuFeatDef[i].full_bits);
884 printf("#define %s_BASE\t", CpuFeatDef[i].name);
885 for (j = 0; j < ARRAY_SIZE(base_feat); j++) {
886 printf("0x%016"PRIx64"ULL", base_feat[j]);
887 if (j < ARRAY_SIZE(base_feat) - 1) {
888 printf(",");
889 } else {
890 printf("\n");
893 printf("#define %s_DEFAULT\t", CpuFeatDef[i].name);
894 for (j = 0; j < ARRAY_SIZE(default_feat); j++) {
895 printf("0x%016"PRIx64"ULL", default_feat[j]);
896 if (j < ARRAY_SIZE(default_feat) - 1) {
897 printf(",");
898 } else {
899 printf("\n");
902 printf("#define %s_FULL\t\t", CpuFeatDef[i].name);
903 for (j = 0; j < ARRAY_SIZE(full_feat); j++) {
904 printf("0x%016"PRIx64"ULL", full_feat[j]);
905 if (j < ARRAY_SIZE(full_feat) - 1) {
906 printf(",");
907 } else {
908 printf("\n");
914 static void print_qemu_feature_defs(void)
916 uint64_t feat[S390_FEAT_MAX / 64 + 1] = {};
917 int i, j;
919 printf("\n/* QEMU (CPU model) feature list data */\n");
921 /* for now we assume that we only add new features */
922 for (i = 0; i < ARRAY_SIZE(QemuFeatDef); i++) {
923 set_bits(feat, QemuFeatDef[i].bits);
925 printf("#define %s\t", QemuFeatDef[i].name);
926 for (j = 0; j < ARRAY_SIZE(feat); j++) {
927 printf("0x%016"PRIx64"ULL", feat[j]);
928 if (j < ARRAY_SIZE(feat) - 1) {
929 printf(",");
930 } else {
931 printf("\n");
937 static void print_feature_group_defs(void)
939 int i, j;
941 printf("\n/* CPU feature group list data */\n");
943 for (i = 0; i < ARRAY_SIZE(FeatGroupDef); i++) {
944 uint64_t feat[S390_FEAT_MAX / 64 + 1] = {};
946 set_bits(feat, FeatGroupDef[i].bits);
947 printf("#define %s\t", FeatGroupDef[i].name);
948 for (j = 0; j < ARRAY_SIZE(feat); j++) {
949 printf("0x%016"PRIx64"ULL", feat[j]);
950 if (j < ARRAY_SIZE(feat) - 1) {
951 printf(",");
952 } else {
953 printf("\n");
959 static void print_feature_group_enum_type(void)
961 int i;
963 printf("\n/* CPU feature group enum type */\n"
964 "typedef enum {\n");
965 for (i = 0; i < ARRAY_SIZE(FeatGroupDef); i++) {
966 printf("\t%s,\n", FeatGroupDef[i].enum_name);
968 printf("\tS390_FEAT_GROUP_MAX,\n"
969 "} S390FeatGroup;\n");
972 int main(int argc, char *argv[])
974 printf("/*\n"
975 " * AUTOMATICALLY GENERATED, DO NOT MODIFY HERE, EDIT\n"
976 " * SOURCE FILE \"%s\" INSTEAD.\n"
977 " *\n"
978 " * Copyright %s IBM Corp.\n"
979 " *\n"
980 " * This work is licensed under the terms of the GNU GPL, "
981 "version 2 or (at\n * your option) any later version. See "
982 "the COPYING file in the top-level\n * directory.\n"
983 " */\n\n"
984 "#ifndef %s\n#define %s\n", __FILE__, _YEARS, _NAME_H, _NAME_H);
985 print_feature_defs();
986 print_feature_group_defs();
987 print_qemu_feature_defs();
988 print_feature_group_enum_type();
989 printf("\n#endif\n");
990 return 0;