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