1 /* 2 * S390 feature list generator 3 * 4 * Copyright 2016 IBM Corp. 5 * 6 * Author(s): Michael Mueller <mimu@linux.vnet.ibm.com> 7 * David Hildenbrand <dahi@linux.vnet.ibm.com> 8 * 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. 12 */ 13 14 #include <inttypes.h> 15 #include <stdio.h> 16 #include "cpu_features_def.h" 17 18 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) 19 20 /***** BEGIN FEATURE DEFS *****/ 21 22 #define S390_FEAT_GROUP_PLO \ 23 S390_FEAT_PLO_CL, \ 24 S390_FEAT_PLO_CLG, \ 25 S390_FEAT_PLO_CLGR, \ 26 S390_FEAT_PLO_CLX, \ 27 S390_FEAT_PLO_CS, \ 28 S390_FEAT_PLO_CSG, \ 29 S390_FEAT_PLO_CSGR, \ 30 S390_FEAT_PLO_CSX, \ 31 S390_FEAT_PLO_DCS, \ 32 S390_FEAT_PLO_DCSG, \ 33 S390_FEAT_PLO_DCSGR, \ 34 S390_FEAT_PLO_DCSX, \ 35 S390_FEAT_PLO_CSST, \ 36 S390_FEAT_PLO_CSSTG, \ 37 S390_FEAT_PLO_CSSTGR, \ 38 S390_FEAT_PLO_CSSTX, \ 39 S390_FEAT_PLO_CSDST, \ 40 S390_FEAT_PLO_CSDSTG, \ 41 S390_FEAT_PLO_CSDSTGR, \ 42 S390_FEAT_PLO_CSDSTX, \ 43 S390_FEAT_PLO_CSTST, \ 44 S390_FEAT_PLO_CSTSTG, \ 45 S390_FEAT_PLO_CSTSTGR, \ 46 S390_FEAT_PLO_CSTSTX 47 48 #define S390_FEAT_GROUP_TOD_CLOCK_STEERING \ 49 S390_FEAT_TOD_CLOCK_STEERING, \ 50 S390_FEAT_PTFF_QTO, \ 51 S390_FEAT_PTFF_QSI, \ 52 S390_FEAT_PTFF_QPT, \ 53 S390_FEAT_PTFF_STO 54 55 #define S390_FEAT_GROUP_GEN13_PTFF \ 56 S390_FEAT_PTFF_QUI, \ 57 S390_FEAT_PTFF_QTOU, \ 58 S390_FEAT_PTFF_STOU 59 60 #define S390_FEAT_GROUP_MSA \ 61 S390_FEAT_MSA, \ 62 S390_FEAT_KMAC_DEA, \ 63 S390_FEAT_KMAC_TDEA_128, \ 64 S390_FEAT_KMAC_TDEA_192, \ 65 S390_FEAT_KMC_DEA, \ 66 S390_FEAT_KMC_TDEA_128, \ 67 S390_FEAT_KMC_TDEA_192, \ 68 S390_FEAT_KM_DEA, \ 69 S390_FEAT_KM_TDEA_128, \ 70 S390_FEAT_KM_TDEA_192, \ 71 S390_FEAT_KIMD_SHA_1, \ 72 S390_FEAT_KLMD_SHA_1 73 74 #define S390_FEAT_GROUP_MSA_EXT_1 \ 75 S390_FEAT_KMC_AES_128, \ 76 S390_FEAT_KM_AES_128, \ 77 S390_FEAT_KIMD_SHA_256, \ 78 S390_FEAT_KLMD_SHA_256 79 80 #define S390_FEAT_GROUP_MSA_EXT_2 \ 81 S390_FEAT_KMC_AES_192, \ 82 S390_FEAT_KMC_AES_256, \ 83 S390_FEAT_KMC_PRNG, \ 84 S390_FEAT_KM_AES_192, \ 85 S390_FEAT_KM_AES_256, \ 86 S390_FEAT_KIMD_SHA_512, \ 87 S390_FEAT_KLMD_SHA_512 88 89 #define S390_FEAT_GROUP_MSA_EXT_3 \ 90 S390_FEAT_MSA_EXT_3, \ 91 S390_FEAT_KMAC_EDEA, \ 92 S390_FEAT_KMAC_ETDEA_128, \ 93 S390_FEAT_KMAC_ETDEA_192, \ 94 S390_FEAT_KMC_EAES_128, \ 95 S390_FEAT_KMC_EAES_192, \ 96 S390_FEAT_KMC_EAES_256, \ 97 S390_FEAT_KMC_EDEA, \ 98 S390_FEAT_KMC_ETDEA_128, \ 99 S390_FEAT_KMC_ETDEA_192, \ 100 S390_FEAT_KM_EDEA, \ 101 S390_FEAT_KM_ETDEA_128, \ 102 S390_FEAT_KM_ETDEA_192, \ 103 S390_FEAT_KM_EAES_128, \ 104 S390_FEAT_KM_EAES_192, \ 105 S390_FEAT_KM_EAES_256, \ 106 S390_FEAT_PCKMO_EDEA, \ 107 S390_FEAT_PCKMO_ETDEA_128, \ 108 S390_FEAT_PCKMO_ETDEA_256, \ 109 S390_FEAT_PCKMO_AES_128, \ 110 S390_FEAT_PCKMO_AES_192, \ 111 S390_FEAT_PCKMO_AES_256 112 113 #define S390_FEAT_GROUP_MSA_EXT_4 \ 114 S390_FEAT_MSA_EXT_4, \ 115 S390_FEAT_KMAC_AES_128, \ 116 S390_FEAT_KMAC_AES_192, \ 117 S390_FEAT_KMAC_AES_256, \ 118 S390_FEAT_KMAC_EAES_128, \ 119 S390_FEAT_KMAC_EAES_192, \ 120 S390_FEAT_KMAC_EAES_256, \ 121 S390_FEAT_KM_XTS_AES_128, \ 122 S390_FEAT_KM_XTS_AES_256, \ 123 S390_FEAT_KM_XTS_EAES_128, \ 124 S390_FEAT_KM_XTS_EAES_256, \ 125 S390_FEAT_KIMD_GHASH, \ 126 S390_FEAT_KMCTR_DEA, \ 127 S390_FEAT_KMCTR_TDEA_128, \ 128 S390_FEAT_KMCTR_TDEA_192, \ 129 S390_FEAT_KMCTR_EDEA, \ 130 S390_FEAT_KMCTR_ETDEA_128, \ 131 S390_FEAT_KMCTR_ETDEA_192, \ 132 S390_FEAT_KMCTR_AES_128, \ 133 S390_FEAT_KMCTR_AES_192, \ 134 S390_FEAT_KMCTR_AES_256, \ 135 S390_FEAT_KMCTR_EAES_128, \ 136 S390_FEAT_KMCTR_EAES_192, \ 137 S390_FEAT_KMCTR_EAES_256, \ 138 S390_FEAT_KMF_DEA, \ 139 S390_FEAT_KMF_TDEA_128, \ 140 S390_FEAT_KMF_TDEA_192, \ 141 S390_FEAT_KMF_EDEA, \ 142 S390_FEAT_KMF_ETDEA_128, \ 143 S390_FEAT_KMF_ETDEA_192, \ 144 S390_FEAT_KMF_AES_128, \ 145 S390_FEAT_KMF_AES_192, \ 146 S390_FEAT_KMF_AES_256, \ 147 S390_FEAT_KMF_EAES_128, \ 148 S390_FEAT_KMF_EAES_192, \ 149 S390_FEAT_KMF_EAES_256, \ 150 S390_FEAT_KMO_DEA, \ 151 S390_FEAT_KMO_TDEA_128, \ 152 S390_FEAT_KMO_TDEA_192, \ 153 S390_FEAT_KMO_EDEA, \ 154 S390_FEAT_KMO_ETDEA_128, \ 155 S390_FEAT_KMO_ETDEA_192, \ 156 S390_FEAT_KMO_AES_128, \ 157 S390_FEAT_KMO_AES_192, \ 158 S390_FEAT_KMO_AES_256, \ 159 S390_FEAT_KMO_EAES_128, \ 160 S390_FEAT_KMO_EAES_192, \ 161 S390_FEAT_KMO_EAES_256, \ 162 S390_FEAT_PCC_CMAC_DEA, \ 163 S390_FEAT_PCC_CMAC_TDEA_128, \ 164 S390_FEAT_PCC_CMAC_TDEA_192, \ 165 S390_FEAT_PCC_CMAC_ETDEA_128, \ 166 S390_FEAT_PCC_CMAC_ETDEA_192, \ 167 S390_FEAT_PCC_CMAC_TDEA, \ 168 S390_FEAT_PCC_CMAC_AES_128, \ 169 S390_FEAT_PCC_CMAC_AES_192, \ 170 S390_FEAT_PCC_CMAC_AES_256, \ 171 S390_FEAT_PCC_CMAC_EAES_128, \ 172 S390_FEAT_PCC_CMAC_EAES_192, \ 173 S390_FEAT_PCC_CMAC_EAES_256, \ 174 S390_FEAT_PCC_XTS_AES_128, \ 175 S390_FEAT_PCC_XTS_AES_256, \ 176 S390_FEAT_PCC_XTS_EAES_128, \ 177 S390_FEAT_PCC_XTS_EAES_256 178 179 #define S390_FEAT_GROUP_MSA_EXT_5 \ 180 S390_FEAT_MSA_EXT_5, \ 181 S390_FEAT_PPNO_SHA_512_DRNG 182 183 #define S390_FEAT_GROUP_MSA_EXT_6 \ 184 S390_FEAT_KIMD_SHA3_224, \ 185 S390_FEAT_KIMD_SHA3_256, \ 186 S390_FEAT_KIMD_SHA3_384, \ 187 S390_FEAT_KIMD_SHA3_512, \ 188 S390_FEAT_KIMD_SHAKE_128, \ 189 S390_FEAT_KIMD_SHAKE_256, \ 190 S390_FEAT_KLMD_SHA3_224, \ 191 S390_FEAT_KLMD_SHA3_256, \ 192 S390_FEAT_KLMD_SHA3_384, \ 193 S390_FEAT_KLMD_SHA3_512, \ 194 S390_FEAT_KLMD_SHAKE_128, \ 195 S390_FEAT_KLMD_SHAKE_256 196 197 #define S390_FEAT_GROUP_MSA_EXT_7 \ 198 S390_FEAT_PRNO_TRNG_QRTCR, \ 199 S390_FEAT_PRNO_TRNG 200 201 #define S390_FEAT_GROUP_MSA_EXT_8 \ 202 S390_FEAT_MSA_EXT_8, \ 203 S390_FEAT_KMA_GCM_AES_128, \ 204 S390_FEAT_KMA_GCM_AES_192, \ 205 S390_FEAT_KMA_GCM_AES_256 , \ 206 S390_FEAT_KMA_GCM_EAES_128, \ 207 S390_FEAT_KMA_GCM_EAES_192, \ 208 S390_FEAT_KMA_GCM_EAES_256 209 210 /* cpu feature groups */ 211 static uint16_t group_PLO[] = { 212 S390_FEAT_GROUP_PLO, 213 }; 214 static uint16_t group_TOD_CLOCK_STEERING[] = { 215 S390_FEAT_GROUP_TOD_CLOCK_STEERING, 216 }; 217 static uint16_t group_GEN13_PTFF[] = { 218 S390_FEAT_GROUP_GEN13_PTFF, 219 }; 220 static uint16_t group_MSA[] = { 221 S390_FEAT_GROUP_MSA, 222 }; 223 static uint16_t group_MSA_EXT_1[] = { 224 S390_FEAT_GROUP_MSA_EXT_1, 225 }; 226 static uint16_t group_MSA_EXT_2[] = { 227 S390_FEAT_GROUP_MSA_EXT_2, 228 }; 229 static uint16_t group_MSA_EXT_3[] = { 230 S390_FEAT_GROUP_MSA_EXT_3, 231 }; 232 static uint16_t group_MSA_EXT_4[] = { 233 S390_FEAT_GROUP_MSA_EXT_4, 234 }; 235 static uint16_t group_MSA_EXT_5[] = { 236 S390_FEAT_GROUP_MSA_EXT_5, 237 }; 238 static uint16_t group_MSA_EXT_6[] = { 239 S390_FEAT_GROUP_MSA_EXT_6, 240 }; 241 static uint16_t group_MSA_EXT_7[] = { 242 S390_FEAT_GROUP_MSA_EXT_7, 243 }; 244 static uint16_t group_MSA_EXT_8[] = { 245 S390_FEAT_GROUP_MSA_EXT_8, 246 }; 247 248 /* Base features (in order of release) 249 * Only non-hypervisor managed features belong here. 250 * Base feature sets are static meaning they do not change in future QEMU 251 * releases. 252 */ 253 static uint16_t base_GEN7_GA1[] = { 254 S390_FEAT_GROUP_PLO, 255 S390_FEAT_ESAN3, 256 S390_FEAT_ZARCH, 257 }; 258 259 #define base_GEN7_GA2 EmptyFeat 260 #define base_GEN7_GA3 EmptyFeat 261 262 static uint16_t base_GEN8_GA1[] = { 263 S390_FEAT_DAT_ENH, 264 S390_FEAT_EXTENDED_TRANSLATION_2, 265 S390_FEAT_GROUP_MSA, 266 S390_FEAT_LONG_DISPLACEMENT, 267 S390_FEAT_LONG_DISPLACEMENT_FAST, 268 S390_FEAT_HFP_MADDSUB, 269 }; 270 271 #define base_GEN8_GA2 EmptyFeat 272 #define base_GEN8_GA3 EmptyFeat 273 #define base_GEN8_GA4 EmptyFeat 274 #define base_GEN8_GA5 EmptyFeat 275 276 static uint16_t base_GEN9_GA1[] = { 277 S390_FEAT_IDTE_SEGMENT, 278 S390_FEAT_ASN_LX_REUSE, 279 S390_FEAT_STFLE, 280 S390_FEAT_SENSE_RUNNING_STATUS, 281 S390_FEAT_EXTENDED_IMMEDIATE, 282 S390_FEAT_EXTENDED_TRANSLATION_3, 283 S390_FEAT_HFP_UNNORMALIZED_EXT, 284 S390_FEAT_ETF2_ENH, 285 S390_FEAT_STORE_CLOCK_FAST, 286 S390_FEAT_GROUP_TOD_CLOCK_STEERING, 287 S390_FEAT_ETF3_ENH, 288 S390_FEAT_DAT_ENH_2, 289 }; 290 291 #define base_GEN9_GA2 EmptyFeat 292 #define base_GEN9_GA3 EmptyFeat 293 294 static uint16_t base_GEN10_GA1[] = { 295 S390_FEAT_CONDITIONAL_SSKE, 296 S390_FEAT_PARSING_ENH, 297 S390_FEAT_MOVE_WITH_OPTIONAL_SPEC, 298 S390_FEAT_EXTRACT_CPU_TIME, 299 S390_FEAT_COMPARE_AND_SWAP_AND_STORE, 300 S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2, 301 S390_FEAT_GENERAL_INSTRUCTIONS_EXT, 302 S390_FEAT_EXECUTE_EXT, 303 S390_FEAT_FLOATING_POINT_SUPPPORT_ENH, 304 S390_FEAT_DFP, 305 S390_FEAT_DFP_FAST, 306 S390_FEAT_PFPO, 307 }; 308 #define base_GEN10_GA2 EmptyFeat 309 #define base_GEN10_GA3 EmptyFeat 310 311 static uint16_t base_GEN11_GA1[] = { 312 S390_FEAT_NONQ_KEY_SETTING, 313 S390_FEAT_ENHANCED_MONITOR, 314 S390_FEAT_FLOATING_POINT_EXT, 315 S390_FEAT_SET_PROGRAM_PARAMETERS, 316 S390_FEAT_STFLE_45, 317 S390_FEAT_CMPSC_ENH, 318 S390_FEAT_INTERLOCKED_ACCESS_2, 319 }; 320 321 #define base_GEN11_GA2 EmptyFeat 322 323 static uint16_t base_GEN12_GA1[] = { 324 S390_FEAT_DFP_ZONED_CONVERSION, 325 S390_FEAT_STFLE_49, 326 S390_FEAT_LOCAL_TLB_CLEARING, 327 }; 328 329 #define base_GEN12_GA2 EmptyFeat 330 331 static uint16_t base_GEN13_GA1[] = { 332 S390_FEAT_STFLE_53, 333 S390_FEAT_DFP_PACKED_CONVERSION, 334 S390_FEAT_GROUP_GEN13_PTFF, 335 }; 336 337 #define base_GEN13_GA2 EmptyFeat 338 339 static uint16_t base_GEN14_GA1[] = { 340 S390_FEAT_ENTROPY_ENC_COMP, 341 S390_FEAT_MISC_INSTRUCTION_EXT, 342 S390_FEAT_SEMAPHORE_ASSIST, 343 S390_FEAT_TIME_SLICE_INSTRUMENTATION, 344 S390_FEAT_ORDER_PRESERVING_COMPRESSION, 345 }; 346 347 /* Full features (in order of release) 348 * Automatically includes corresponding base features. 349 * Full features are all features this hardware supports even if kvm/QEMU do not 350 * support these features yet. 351 */ 352 static uint16_t full_GEN7_GA1[] = { 353 S390_FEAT_PPA15, 354 S390_FEAT_BPB, 355 S390_FEAT_SIE_F2, 356 S390_FEAT_SIE_SKEY, 357 S390_FEAT_SIE_GPERE, 358 S390_FEAT_SIE_IB, 359 S390_FEAT_SIE_CEI, 360 }; 361 362 static uint16_t full_GEN7_GA2[] = { 363 S390_FEAT_EXTENDED_TRANSLATION_2, 364 }; 365 366 static uint16_t full_GEN7_GA3[] = { 367 S390_FEAT_LONG_DISPLACEMENT, 368 S390_FEAT_SIE_SIIF, 369 }; 370 371 static uint16_t full_GEN8_GA1[] = { 372 S390_FEAT_SIE_GSLS, 373 S390_FEAT_SIE_64BSCAO, 374 }; 375 376 #define full_GEN8_GA2 EmptyFeat 377 378 static uint16_t full_GEN8_GA3[] = { 379 S390_FEAT_ASN_LX_REUSE, 380 S390_FEAT_EXTENDED_TRANSLATION_3, 381 }; 382 383 #define full_GEN8_GA4 EmptyFeat 384 #define full_GEN8_GA5 EmptyFeat 385 386 static uint16_t full_GEN9_GA1[] = { 387 S390_FEAT_STORE_HYPERVISOR_INFO, 388 S390_FEAT_GROUP_MSA_EXT_1, 389 S390_FEAT_CMM, 390 S390_FEAT_SIE_CMMA, 391 }; 392 393 static uint16_t full_GEN9_GA2[] = { 394 S390_FEAT_MOVE_WITH_OPTIONAL_SPEC, 395 S390_FEAT_EXTRACT_CPU_TIME, 396 S390_FEAT_COMPARE_AND_SWAP_AND_STORE, 397 S390_FEAT_FLOATING_POINT_SUPPPORT_ENH, 398 S390_FEAT_DFP, 399 }; 400 401 static uint16_t full_GEN9_GA3[] = { 402 S390_FEAT_CONDITIONAL_SSKE, 403 S390_FEAT_PFPO, 404 }; 405 406 static uint16_t full_GEN10_GA1[] = { 407 S390_FEAT_EDAT, 408 S390_FEAT_CONFIGURATION_TOPOLOGY, 409 S390_FEAT_GROUP_MSA_EXT_2, 410 S390_FEAT_ESOP, 411 S390_FEAT_SIE_PFMFI, 412 S390_FEAT_SIE_SIGPIF, 413 }; 414 415 static uint16_t full_GEN10_GA2[] = { 416 S390_FEAT_SET_PROGRAM_PARAMETERS, 417 S390_FEAT_SIE_IBS, 418 }; 419 420 static uint16_t full_GEN10_GA3[] = { 421 S390_FEAT_GROUP_MSA_EXT_3, 422 }; 423 424 static uint16_t full_GEN11_GA1[] = { 425 S390_FEAT_IPTE_RANGE, 426 S390_FEAT_ACCESS_EXCEPTION_FS_INDICATION, 427 S390_FEAT_GROUP_MSA_EXT_4, 428 }; 429 430 #define full_GEN11_GA2 EmptyFeat 431 432 static uint16_t full_GEN12_GA1[] = { 433 S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE, 434 S390_FEAT_TRANSACTIONAL_EXE, 435 S390_FEAT_RUNTIME_INSTRUMENTATION, 436 S390_FEAT_ZPCI, 437 S390_FEAT_ADAPTER_EVENT_NOTIFICATION, 438 S390_FEAT_ADAPTER_INT_SUPPRESSION, 439 S390_FEAT_EDAT_2, 440 S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2, 441 }; 442 443 static uint16_t full_GEN12_GA2[] = { 444 S390_FEAT_GROUP_MSA_EXT_5, 445 }; 446 447 static uint16_t full_GEN13_GA1[] = { 448 S390_FEAT_VECTOR, 449 }; 450 451 #define full_GEN13_GA2 EmptyFeat 452 453 static uint16_t full_GEN14_GA1[] = { 454 S390_FEAT_INSTRUCTION_EXEC_PROT, 455 S390_FEAT_GUARDED_STORAGE, 456 S390_FEAT_VECTOR_PACKED_DECIMAL, 457 S390_FEAT_VECTOR_ENH, 458 S390_FEAT_MULTIPLE_EPOCH, 459 S390_FEAT_TEST_PENDING_EXT_INTERRUPTION, 460 S390_FEAT_INSERT_REFERENCE_BITS_MULT, 461 S390_FEAT_GROUP_MSA_EXT_6, 462 S390_FEAT_GROUP_MSA_EXT_7, 463 S390_FEAT_GROUP_MSA_EXT_8, 464 S390_FEAT_CMM_NT, 465 S390_FEAT_HPMA2, 466 S390_FEAT_SIE_KSS, 467 }; 468 469 /* Default features (in order of release) 470 * Automatically includes corresponding base features. 471 * Default features are all features this version of QEMU supports for this 472 * hardware model. Default feature sets can grow with new QEMU releases. 473 */ 474 #define default_GEN7_GA1 EmptyFeat 475 #define default_GEN7_GA2 EmptyFeat 476 #define default_GEN7_GA3 EmptyFeat 477 #define default_GEN8_GA1 EmptyFeat 478 #define default_GEN8_GA2 EmptyFeat 479 #define default_GEN8_GA3 EmptyFeat 480 #define default_GEN8_GA4 EmptyFeat 481 #define default_GEN8_GA5 EmptyFeat 482 483 static uint16_t default_GEN9_GA1[] = { 484 S390_FEAT_STORE_HYPERVISOR_INFO, 485 S390_FEAT_GROUP_MSA_EXT_1, 486 S390_FEAT_CMM, 487 }; 488 489 #define default_GEN9_GA2 EmptyFeat 490 #define default_GEN9_GA3 EmptyFeat 491 492 static uint16_t default_GEN10_GA1[] = { 493 S390_FEAT_EDAT, 494 S390_FEAT_GROUP_MSA_EXT_2, 495 }; 496 497 #define default_GEN10_GA2 EmptyFeat 498 #define default_GEN10_GA3 EmptyFeat 499 500 static uint16_t default_GEN11_GA1[] = { 501 S390_FEAT_GROUP_MSA_EXT_3, 502 S390_FEAT_IPTE_RANGE, 503 S390_FEAT_ACCESS_EXCEPTION_FS_INDICATION, 504 S390_FEAT_GROUP_MSA_EXT_4, 505 }; 506 507 #define default_GEN11_GA2 EmptyFeat 508 509 static uint16_t default_GEN12_GA1[] = { 510 S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE, 511 S390_FEAT_TRANSACTIONAL_EXE, 512 S390_FEAT_RUNTIME_INSTRUMENTATION, 513 S390_FEAT_ZPCI, 514 S390_FEAT_ADAPTER_EVENT_NOTIFICATION, 515 S390_FEAT_EDAT_2, 516 S390_FEAT_ESOP, 517 S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2, 518 }; 519 520 #define default_GEN12_GA2 EmptyFeat 521 522 static uint16_t default_GEN13_GA1[] = { 523 S390_FEAT_GROUP_MSA_EXT_5, 524 S390_FEAT_VECTOR, 525 }; 526 527 #define default_GEN13_GA2 EmptyFeat 528 529 static uint16_t default_GEN14_GA1[] = { 530 S390_FEAT_INSTRUCTION_EXEC_PROT, 531 S390_FEAT_GUARDED_STORAGE, 532 S390_FEAT_VECTOR_PACKED_DECIMAL, 533 S390_FEAT_VECTOR_ENH, 534 S390_FEAT_GROUP_MSA_EXT_6, 535 S390_FEAT_GROUP_MSA_EXT_7, 536 S390_FEAT_GROUP_MSA_EXT_8, 537 }; 538 539 /* QEMU (CPU model) features */ 540 541 static uint16_t qemu_V2_11[] = { 542 S390_FEAT_GROUP_PLO, 543 S390_FEAT_ESAN3, 544 S390_FEAT_ZARCH, 545 }; 546 547 static uint16_t qemu_LATEST[] = { 548 S390_FEAT_DAT_ENH, 549 S390_FEAT_IDTE_SEGMENT, 550 S390_FEAT_STFLE, 551 S390_FEAT_SENSE_RUNNING_STATUS, 552 S390_FEAT_EXTENDED_TRANSLATION_2, 553 S390_FEAT_MSA, 554 S390_FEAT_LONG_DISPLACEMENT, 555 S390_FEAT_LONG_DISPLACEMENT_FAST, 556 S390_FEAT_EXTENDED_IMMEDIATE, 557 S390_FEAT_EXTENDED_TRANSLATION_3, 558 S390_FEAT_ETF2_ENH, 559 S390_FEAT_STORE_CLOCK_FAST, 560 S390_FEAT_MOVE_WITH_OPTIONAL_SPEC, 561 S390_FEAT_ETF3_ENH, 562 S390_FEAT_EXTRACT_CPU_TIME, 563 S390_FEAT_COMPARE_AND_SWAP_AND_STORE, 564 S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2, 565 S390_FEAT_GENERAL_INSTRUCTIONS_EXT, 566 S390_FEAT_EXECUTE_EXT, 567 S390_FEAT_SET_PROGRAM_PARAMETERS, 568 S390_FEAT_FLOATING_POINT_SUPPPORT_ENH, 569 S390_FEAT_STFLE_45, 570 S390_FEAT_STFLE_49, 571 S390_FEAT_LOCAL_TLB_CLEARING, 572 S390_FEAT_INTERLOCKED_ACCESS_2, 573 S390_FEAT_MSA_EXT_4, 574 S390_FEAT_MSA_EXT_3, 575 }; 576 577 /* add all new definitions before this point */ 578 static uint16_t qemu_MAX[] = { 579 /* z13+ features */ 580 S390_FEAT_STFLE_53, 581 /* generates a dependency warning, leave it out for now */ 582 S390_FEAT_MSA_EXT_5, 583 }; 584 585 /****** END FEATURE DEFS ******/ 586 587 #define _YEARS "2016" 588 #define _NAME_H "TARGET_S390X_GEN_FEATURES_H" 589 590 #define CPU_FEAT_INITIALIZER(_name) \ 591 { \ 592 .name = "S390_FEAT_LIST_" #_name, \ 593 .base_bits = \ 594 { .data = base_##_name, \ 595 .len = ARRAY_SIZE(base_##_name) }, \ 596 .default_bits = \ 597 { .data = default_##_name, \ 598 .len = ARRAY_SIZE(default_##_name) }, \ 599 .full_bits = \ 600 { .data = full_##_name, \ 601 .len = ARRAY_SIZE(full_##_name) }, \ 602 } 603 604 typedef struct BitSpec { 605 uint16_t *data; 606 uint32_t len; 607 } BitSpec; 608 609 typedef struct { 610 const char *name; 611 BitSpec base_bits; 612 BitSpec default_bits; 613 BitSpec full_bits; 614 } CpuFeatDefSpec; 615 616 static uint16_t EmptyFeat[] = {}; 617 618 /******************************* 619 * processor GA series 620 *******************************/ 621 static CpuFeatDefSpec CpuFeatDef[] = { 622 CPU_FEAT_INITIALIZER(GEN7_GA1), 623 CPU_FEAT_INITIALIZER(GEN7_GA2), 624 CPU_FEAT_INITIALIZER(GEN7_GA3), 625 CPU_FEAT_INITIALIZER(GEN8_GA1), 626 CPU_FEAT_INITIALIZER(GEN8_GA2), 627 CPU_FEAT_INITIALIZER(GEN8_GA3), 628 CPU_FEAT_INITIALIZER(GEN8_GA4), 629 CPU_FEAT_INITIALIZER(GEN8_GA5), 630 CPU_FEAT_INITIALIZER(GEN9_GA1), 631 CPU_FEAT_INITIALIZER(GEN9_GA2), 632 CPU_FEAT_INITIALIZER(GEN9_GA3), 633 CPU_FEAT_INITIALIZER(GEN10_GA1), 634 CPU_FEAT_INITIALIZER(GEN10_GA2), 635 CPU_FEAT_INITIALIZER(GEN10_GA3), 636 CPU_FEAT_INITIALIZER(GEN11_GA1), 637 CPU_FEAT_INITIALIZER(GEN11_GA2), 638 CPU_FEAT_INITIALIZER(GEN12_GA1), 639 CPU_FEAT_INITIALIZER(GEN12_GA2), 640 CPU_FEAT_INITIALIZER(GEN13_GA1), 641 CPU_FEAT_INITIALIZER(GEN13_GA2), 642 CPU_FEAT_INITIALIZER(GEN14_GA1), 643 }; 644 645 #define FEAT_GROUP_INITIALIZER(_name) \ 646 { \ 647 .name = "S390_FEAT_GROUP_LIST_" #_name, \ 648 .bits = \ 649 { .data = group_##_name, \ 650 .len = ARRAY_SIZE(group_##_name) }, \ 651 } 652 653 typedef struct { 654 const char *name; 655 BitSpec bits; 656 } FeatGroupDefSpec; 657 658 /******************************* 659 * feature groups 660 *******************************/ 661 static FeatGroupDefSpec FeatGroupDef[] = { 662 FEAT_GROUP_INITIALIZER(PLO), 663 FEAT_GROUP_INITIALIZER(TOD_CLOCK_STEERING), 664 FEAT_GROUP_INITIALIZER(GEN13_PTFF), 665 FEAT_GROUP_INITIALIZER(MSA), 666 FEAT_GROUP_INITIALIZER(MSA_EXT_1), 667 FEAT_GROUP_INITIALIZER(MSA_EXT_2), 668 FEAT_GROUP_INITIALIZER(MSA_EXT_3), 669 FEAT_GROUP_INITIALIZER(MSA_EXT_4), 670 FEAT_GROUP_INITIALIZER(MSA_EXT_5), 671 FEAT_GROUP_INITIALIZER(MSA_EXT_6), 672 FEAT_GROUP_INITIALIZER(MSA_EXT_7), 673 FEAT_GROUP_INITIALIZER(MSA_EXT_8), 674 }; 675 676 #define QEMU_FEAT_INITIALIZER(_name) \ 677 { \ 678 .name = "S390_FEAT_LIST_QEMU_" #_name, \ 679 .bits = \ 680 { .data = qemu_##_name, \ 681 .len = ARRAY_SIZE(qemu_##_name) }, \ 682 } 683 684 /******************************* 685 * QEMU (CPU model) features 686 *******************************/ 687 static FeatGroupDefSpec QemuFeatDef[] = { 688 QEMU_FEAT_INITIALIZER(V2_11), 689 QEMU_FEAT_INITIALIZER(LATEST), 690 QEMU_FEAT_INITIALIZER(MAX), 691 }; 692 693 694 static void set_bits(uint64_t list[], BitSpec bits) 695 { 696 uint32_t i; 697 698 for (i = 0; i < bits.len; i++) { 699 list[bits.data[i] / 64] |= 1ULL << (bits.data[i] % 64); 700 } 701 } 702 703 static void print_feature_defs(void) 704 { 705 uint64_t base_feat[S390_FEAT_MAX / 64 + 1] = {}; 706 uint64_t default_feat[S390_FEAT_MAX / 64 + 1] = {}; 707 uint64_t full_feat[S390_FEAT_MAX / 64 + 1] = {}; 708 int i, j; 709 710 printf("\n/* CPU model feature list data */\n"); 711 712 for (i = 0; i < ARRAY_SIZE(CpuFeatDef); i++) { 713 set_bits(base_feat, CpuFeatDef[i].base_bits); 714 /* add the base to the default features */ 715 set_bits(default_feat, CpuFeatDef[i].base_bits); 716 set_bits(default_feat, CpuFeatDef[i].default_bits); 717 /* add the base to the full features */ 718 set_bits(full_feat, CpuFeatDef[i].base_bits); 719 set_bits(full_feat, CpuFeatDef[i].full_bits); 720 721 printf("#define %s_BASE\t", CpuFeatDef[i].name); 722 for (j = 0; j < ARRAY_SIZE(base_feat); j++) { 723 printf("0x%016"PRIx64"ULL", base_feat[j]); 724 if (j < ARRAY_SIZE(base_feat) - 1) { 725 printf(","); 726 } else { 727 printf("\n"); 728 } 729 } 730 printf("#define %s_DEFAULT\t", CpuFeatDef[i].name); 731 for (j = 0; j < ARRAY_SIZE(default_feat); j++) { 732 printf("0x%016"PRIx64"ULL", default_feat[j]); 733 if (j < ARRAY_SIZE(default_feat) - 1) { 734 printf(","); 735 } else { 736 printf("\n"); 737 } 738 } 739 printf("#define %s_FULL\t\t", CpuFeatDef[i].name); 740 for (j = 0; j < ARRAY_SIZE(full_feat); j++) { 741 printf("0x%016"PRIx64"ULL", full_feat[j]); 742 if (j < ARRAY_SIZE(full_feat) - 1) { 743 printf(","); 744 } else { 745 printf("\n"); 746 } 747 } 748 } 749 } 750 751 static void print_qemu_feature_defs(void) 752 { 753 uint64_t feat[S390_FEAT_MAX / 64 + 1] = {}; 754 int i, j; 755 756 printf("\n/* QEMU (CPU model) feature list data */\n"); 757 758 /* for now we assume that we only add new features */ 759 for (i = 0; i < ARRAY_SIZE(QemuFeatDef); i++) { 760 set_bits(feat, QemuFeatDef[i].bits); 761 762 printf("#define %s\t", QemuFeatDef[i].name); 763 for (j = 0; j < ARRAY_SIZE(feat); j++) { 764 printf("0x%016"PRIx64"ULL", feat[j]); 765 if (j < ARRAY_SIZE(feat) - 1) { 766 printf(","); 767 } else { 768 printf("\n"); 769 } 770 } 771 } 772 } 773 774 static void print_feature_group_defs(void) 775 { 776 int i, j; 777 778 printf("\n/* CPU feature group list data */\n"); 779 780 for (i = 0; i < ARRAY_SIZE(FeatGroupDef); i++) { 781 uint64_t feat[S390_FEAT_MAX / 64 + 1] = {}; 782 783 set_bits(feat, FeatGroupDef[i].bits); 784 printf("#define %s\t", FeatGroupDef[i].name); 785 for (j = 0; j < ARRAY_SIZE(feat); j++) { 786 printf("0x%016"PRIx64"ULL", feat[j]); 787 if (j < ARRAY_SIZE(feat) - 1) { 788 printf(","); 789 } else { 790 printf("\n"); 791 } 792 } 793 } 794 } 795 796 int main(int argc, char *argv[]) 797 { 798 printf("/*\n" 799 " * AUTOMATICALLY GENERATED, DO NOT MODIFY HERE, EDIT\n" 800 " * SOURCE FILE \"%s\" INSTEAD.\n" 801 " *\n" 802 " * Copyright %s IBM Corp.\n" 803 " *\n" 804 " * This work is licensed under the terms of the GNU GPL, " 805 "version 2 or (at\n * your option) any later version. See " 806 "the COPYING file in the top-level\n * directory.\n" 807 " */\n\n" 808 "#ifndef %s\n#define %s\n", __FILE__, _YEARS, _NAME_H, _NAME_H); 809 print_feature_defs(); 810 print_feature_group_defs(); 811 print_qemu_feature_defs(); 812 printf("\n#endif\n"); 813 return 0; 814 } 815