< prev index next >

src/hotspot/cpu/s390/vm_version_s390.hpp

Print this page




  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_S390_VM_VM_VERSION_S390_HPP
  27 #define CPU_S390_VM_VM_VERSION_S390_HPP
  28 
  29 
  30 #include "runtime/abstract_vm_version.hpp"
  31 #include "runtime/globals_extension.hpp"
  32 
  33 class VM_Version: public Abstract_VM_Version {
  34 
  35  protected:
  36 // The following list contains the (approximate) announcement/availability
  37 // dates of the many System z generations in existence as of now which
  38 // implement the z/Architecture.
  39 //   z900: 2000-10
  40 //   z990: 2003-06
  41 //   z9:   2005-09
  42 //   z10:  2007-04
  43 //   z10:  2008-02
  44 //   z196: 2010-08
  45 //   ec12: 2012-09
  46 //   z13:  2015-03
  47 //
  48 // z/Architecture is the name of the 64-bit extension of the 31-bit s390
  49 // architecture.
  50 //




  51 // ----------------------------------------------
  52 // --- FeatureBitString Bits   0.. 63 (DW[0]) ---
  53 // ----------------------------------------------
  54 //                                           11222334445566
  55 //                                        04826048260482604
  56 #define  StoreFacilityListExtendedMask  0x0100000000000000UL  // z9
  57 #define  ETF2Mask                       0x0000800000000000UL  // z900
  58 #define  CryptoFacilityMask             0x0000400000000000UL  // z990
  59 #define  LongDispFacilityMask           0x0000200000000000UL  // z900 with microcode update
  60 #define  LongDispFacilityHighPerfMask   0x0000300000000000UL  // z990
  61 #define  HFPMultiplyAndAddMask          0x0000080000000000UL  // z990
  62 #define  ExtImmedFacilityMask           0x0000040000000000UL  // z9
  63 #define  ETF3Mask                       0x0000020000000000UL  // z990/z9 (?)
  64 #define  HFPUnnormalizedMask            0x0000010000000000UL  // z9
  65 #define  ETF2EnhancementMask            0x0000008000000000UL  // z9
  66 #define  StoreClockFastMask             0x0000004000000000UL  // z9
  67 #define  ParsingEnhancementsMask        0x0000002000000000UL  // z10(?)
  68 #define  ETF3EnhancementMask            0x0000000200000000UL  // z9
  69 #define  ExtractCPUTimeMask             0x0000000100000000UL  // z10
  70 #define  CompareSwapStoreMask           0x00000000c0000000UL  // z10


  77 #define  DistinctOpndsMask              0x0000000000040000UL  // z196
  78 #define  FastBCRSerializationMask       DistinctOpndsMask
  79 #define  HighWordMask                   DistinctOpndsMask
  80 #define  LoadStoreConditionalMask       DistinctOpndsMask
  81 #define  PopulationCountMask            DistinctOpndsMask
  82 #define  InterlockedAccess1Mask         DistinctOpndsMask
  83 // z196 end
  84 // EC12 begin
  85 #define  DFPZonedConversionMask         0x0000000000008000UL  // ec12
  86 #define  MiscInstrExtMask               0x0000000000004000UL  // ec12
  87 #define  ExecutionHintMask              MiscInstrExtMask
  88 #define  LoadAndTrapMask                MiscInstrExtMask
  89 #define  ProcessorAssistMask            MiscInstrExtMask
  90 #define  ConstrainedTxExecutionMask     0x0000000000002000UL  // ec12
  91 #define  InterlockedAccess2Mask         0x0000000000000800UL  // ec12
  92 // EC12 end
  93 // z13 begin
  94 #define  LoadStoreConditional2Mask      0x0000000000000400UL  // z13
  95 #define  CryptoExtension5Mask           0x0000000000000040UL  // z13
  96 // z13 end
  97 // Feature-DW[0] starts to fill up. Use of these masks is risky.
  98 #define  TestFeature1ImplMask           0x0000000000000001UL
  99 #define  TestFeature2ImplMask           0x0000000000000002UL
 100 #define  TestFeature4ImplMask           0x0000000000000004UL
 101 #define  TestFeature8ImplMask           0x0000000000000008UL
 102 // ----------------------------------------------
 103 // --- FeatureBitString Bits  64..127 (DW[1]) ---
 104 // ----------------------------------------------
 105 //                                                 11111111
 106 //                                        66778889900011222
 107 //                                        48260482604826048
 108 #define  TransactionalExecutionMask     0x0040000000000000UL  // ec12
 109 #define  CryptoExtension3Mask           0x0008000000000000UL  // z196
 110 #define  CryptoExtension4Mask           0x0004000000000000UL  // z196
 111 #define  DFPPackedConversionMask        0x0000800000000000UL  // z13
 112 // ----------------------------------------------
 113 // --- FeatureBitString Bits 128..192 (DW[2]) ---
 114 // ----------------------------------------------
 115 //                                        11111111111111111
 116 //                                        23344455666778889
 117 //                                        82604826048260482
 118 #define  VectorFacilityMask             0x4000000000000000UL  // z13, not avail in VM guest mode!









 119 
 120   enum {
 121     _max_cache_levels = 8,    // As limited by ECAG instruction.
 122     _features_buffer_len = 4, // in DW
 123     _code_buffer_len = 2*256  // For feature detection code.
 124   };
 125   static unsigned long _features[_features_buffer_len];
 126   static unsigned long _cipher_features[_features_buffer_len];
 127   static unsigned long _msgdigest_features[_features_buffer_len];
 128   static unsigned int  _nfeatures;
 129   static unsigned int  _ncipher_features;
 130   static unsigned int  _nmsgdigest_features;
 131   static unsigned int  _Dcache_lineSize;
 132   static unsigned int  _Icache_lineSize;
 133   static bool          _is_determine_features_test_running;
 134   static const char*   _model_string;
 135 
 136   static bool test_feature_bit(unsigned long* featureBuffer, int featureNum, unsigned int bufLen);
 137   static void set_features_string();
 138   static void print_features_internal(const char* text, bool print_anyway=false);
 139   static void determine_features();
 140   static long call_getFeatures(unsigned long* buffer, int buflen, int functionCode);
 141   static void set_getFeatures(address entryPoint);
 142   static int  calculate_ECAG_functionCode(unsigned int attributeIndication,
 143                                           unsigned int levelIndication,
 144                                           unsigned int typeIndication);
 145 
 146   // Setting features via march=z900|z990|z9|z10|z196|ec12|z13|ztest commandline option.
 147   static void reset_features(bool reset);
 148   static void set_features_z900(bool reset = true);
 149   static void set_features_z990(bool reset = true);
 150   static void set_features_z9(bool reset = true);
 151   static void set_features_z10(bool reset = true);
 152   static void set_features_z196(bool reset = true);
 153   static void set_features_ec12(bool reset = true);
 154   static void set_features_z13(bool reset = true);


 155   static void set_features_from(const char* march);
 156 







 157   // Get the CPU type from feature bit settings.
 158   static bool is_z900() { return has_long_displacement()      && !has_long_displacement_fast(); }
 159   static bool is_z990() { return has_long_displacement_fast() && !has_extended_immediate();  }
 160   static bool is_z9()   { return has_extended_immediate()     && !has_GnrlInstrExtensions(); }
 161   static bool is_z10()  { return has_GnrlInstrExtensions()    && !has_DistinctOpnds(); }
 162   static bool is_z196() { return has_DistinctOpnds()          && !has_MiscInstrExt(); }
 163   static bool is_ec12() { return has_MiscInstrExt()           && !has_CryptoExt5(); }
 164   static bool is_z13()  { return has_CryptoExt5();}
 165 
 166   // Get information about cache line sizes.
 167   // As of now and the foreseeable future, line size of all levels will be the same and 256.
 168   static unsigned int Dcache_lineSize(unsigned int level = 0) { return _Dcache_lineSize; }
 169   static unsigned int Icache_lineSize(unsigned int level = 0) { return _Icache_lineSize; }
 170 
 171  public:
 172 
 173   // Need to use nested class with unscoped enum.
 174   // C++11 declaration "enum class Cipher { ... } is not supported.
 175   class CipherMode {
 176     public:
 177       enum {
 178         cipher   = 0x00,
 179         decipher = 0x80
 180       };
 181   };
 182   class Cipher {
 183    public:
 184     enum { // KM only!!! KMC uses different parmBlk sizes.
 185       _Query              =   0,
 186       _DEA                =   1,
 187       _TDEA128            =   2,
 188       _TDEA192            =   3,
 189       _EncryptedDEA       =   9,
 190       _EncryptedDEA128    =  10,
 191       _EncryptedDEA192    =  11,


 382   // Memory-immediate arithmetic instructions. There is no performance penalty in using them.
 383   // Moreover, these memory-immediate instructions are quasi-atomic (>99.99%) on z10
 384   // and 100% atomic from z196 onwards, thanks to the specific operand serialization that comes new with z196.
 385   static bool has_MemWithImmALUOps()          { return  has_GnrlInstrExtensions(); }
 386   static bool has_AtomicMemWithImmALUOps()    { return   has_MemWithImmALUOps() && has_InterlockedAccessV1(); }
 387   static bool has_FPExtensions()              { return  (_features[0] & FPExtensionsMask)              == FPExtensionsMask; }
 388   static bool has_FPSupportEnhancements()     { return  (_features[0] & FPSupportEnhancementsMask)     == FPSupportEnhancementsMask; }
 389   static bool has_DecimalFloatingPoint()      { return  (_features[0] & DecimalFloatingPointMask)      == DecimalFloatingPointMask; }
 390   static bool has_InterlockedAccessV1()       { return  (_features[0] & InterlockedAccess1Mask)        == InterlockedAccess1Mask; }
 391   static bool has_LoadAndALUAtomicV1()        { return  (_features[0] & InterlockedAccess1Mask)        == InterlockedAccess1Mask; }
 392   static bool has_PopCount()                  { return  (_features[0] & PopulationCountMask)           == PopulationCountMask; }
 393   static bool has_LoadStoreConditional()      { return  (_features[0] & LoadStoreConditionalMask)      == LoadStoreConditionalMask; }
 394   static bool has_HighWordInstr()             { return  (_features[0] & HighWordMask)                  == HighWordMask; }
 395   static bool has_FastSync()                  { return  (_features[0] & FastBCRSerializationMask)      == FastBCRSerializationMask; }
 396   static bool has_DistinctOpnds()             { return  (_features[0] & DistinctOpndsMask)             == DistinctOpndsMask; }
 397   static bool has_CryptoExt3()                { return  (_features[1] & CryptoExtension3Mask)          == CryptoExtension3Mask; }
 398   static bool has_CryptoExt4()                { return  (_features[1] & CryptoExtension4Mask)          == CryptoExtension4Mask; }
 399   static bool has_DFPZonedConversion()        { return  (_features[0] & DFPZonedConversionMask)        == DFPZonedConversionMask; }
 400   static bool has_DFPPackedConversion()       { return  (_features[1] & DFPPackedConversionMask)       == DFPPackedConversionMask; }
 401   static bool has_MiscInstrExt()              { return  (_features[0] & MiscInstrExtMask)              == MiscInstrExtMask; }


 402   static bool has_ExecutionHint()             { return  (_features[0] & ExecutionHintMask)             == ExecutionHintMask; }
 403   static bool has_LoadAndTrap()               { return  (_features[0] & LoadAndTrapMask)               == LoadAndTrapMask; }
 404   static bool has_ProcessorAssist()           { return  (_features[0] & ProcessorAssistMask)           == ProcessorAssistMask; }
 405   static bool has_InterlockedAccessV2()       { return  (_features[0] & InterlockedAccess2Mask)        == InterlockedAccess2Mask; }
 406   static bool has_LoadAndALUAtomicV2()        { return  (_features[0] & InterlockedAccess2Mask)        == InterlockedAccess2Mask; }
 407   static bool has_TxMem()                     { return ((_features[1] & TransactionalExecutionMask)    == TransactionalExecutionMask) &&
 408                                                        ((_features[0] & ConstrainedTxExecutionMask)    == ConstrainedTxExecutionMask); }
 409   static bool has_CryptoExt5()                { return  (_features[0] & CryptoExtension5Mask)          == CryptoExtension5Mask; }


 410   static bool has_LoadStoreConditional2()     { return  (_features[0] & LoadStoreConditional2Mask)     == LoadStoreConditional2Mask; }
 411   static bool has_VectorFacility()            { return  (_features[2] & VectorFacilityMask)            == VectorFacilityMask; }
 412 
 413   static bool has_TestFeatureImpl()           { return  (_features[0] & TestFeature1ImplMask)          == TestFeature1ImplMask; }
 414   static bool has_TestFeature1Impl()          { return  (_features[0] & TestFeature1ImplMask)          == TestFeature1ImplMask; }
 415   static bool has_TestFeature2Impl()          { return  (_features[0] & TestFeature2ImplMask)          == TestFeature2ImplMask; }
 416   static bool has_TestFeature4Impl()          { return  (_features[0] & TestFeature4ImplMask)          == TestFeature4ImplMask; }
 417   static bool has_TestFeature8Impl()          { return  (_features[0] & TestFeature8ImplMask)          == TestFeature8ImplMask; }
 418   static bool has_TestFeaturesImpl()          { return  has_TestFeature1Impl() || has_TestFeature2Impl() || has_TestFeature4Impl() || has_TestFeature8Impl(); }
 419 
 420   // Crypto features query functions.
 421   static bool has_Crypto_AES128()             { return has_Crypto() && test_feature_bit(&_cipher_features[0], Cipher::_AES128, Cipher::_featureBits); }
 422   static bool has_Crypto_AES192()             { return has_Crypto() && test_feature_bit(&_cipher_features[0], Cipher::_AES192, Cipher::_featureBits); }
 423   static bool has_Crypto_AES256()             { return has_Crypto() && test_feature_bit(&_cipher_features[0], Cipher::_AES256, Cipher::_featureBits); }
 424   static bool has_Crypto_AES()                { return has_Crypto_AES128() || has_Crypto_AES192() || has_Crypto_AES256(); }
 425 
 426   static bool has_Crypto_SHA1()               { return has_Crypto() && test_feature_bit(&_msgdigest_features[0], MsgDigest::_SHA1,   MsgDigest::_featureBits); }
 427   static bool has_Crypto_SHA256()             { return has_Crypto() && test_feature_bit(&_msgdigest_features[0], MsgDigest::_SHA256, MsgDigest::_featureBits); }
 428   static bool has_Crypto_SHA512()             { return has_Crypto() && test_feature_bit(&_msgdigest_features[0], MsgDigest::_SHA512, MsgDigest::_featureBits); }
 429   static bool has_Crypto_GHASH()              { return has_Crypto() && test_feature_bit(&_msgdigest_features[0], MsgDigest::_GHASH,  MsgDigest::_featureBits); }
 430   static bool has_Crypto_SHA()                { return has_Crypto_SHA1() || has_Crypto_SHA256() || has_Crypto_SHA512() || has_Crypto_GHASH(); }
 431 
 432   // CPU feature setters (to force model-specific behaviour). Test/debugging only.
 433   static void set_has_TestFeature1Impl()          { _features[0] |= TestFeature1ImplMask; }
 434   static void set_has_TestFeature2Impl()          { _features[0] |= TestFeature2ImplMask; }
 435   static void set_has_TestFeature4Impl()          { _features[0] |= TestFeature4ImplMask; }
 436   static void set_has_TestFeature8Impl()          { _features[0] |= TestFeature8ImplMask; }
 437   static void set_has_DecimalFloatingPoint()      { _features[0] |= DecimalFloatingPointMask; }
 438   static void set_has_FPSupportEnhancements()     { _features[0] |= FPSupportEnhancementsMask; }
 439   static void set_has_ExecuteExtensions()         { _features[0] |= ExecuteExtensionsMask; }
 440   static void set_has_MemWithImmALUOps()          { _features[0] |= GnrlInstrExtFacilityMask; }
 441   static void set_has_MoveImmToMem()              { _features[0] |= GnrlInstrExtFacilityMask; }
 442   static void set_has_Prefetch()                  { _features[0] |= GnrlInstrExtFacilityMask; }
 443   static void set_has_MultiplySingleImm32()       { _features[0] |= GnrlInstrExtFacilityMask; }
 444   static void set_has_CompareBranch()             { _features[0] |= GnrlInstrExtFacilityMask; }
 445   static void set_has_CompareTrap()               { _features[0] |= GnrlInstrExtFacilityMask; }
 446   static void set_has_RelativeLoadStore()         { _features[0] |= GnrlInstrExtFacilityMask; }
 447   static void set_has_GnrlInstrExtensions()       { _features[0] |= GnrlInstrExtFacilityMask; }
 448   static void set_has_CompareSwapStore()          { _features[0] |= CompareSwapStoreMask; }
 449   static void set_has_HFPMultiplyAndAdd()         { _features[0] |= HFPMultiplyAndAddMask; }
 450   static void set_has_HFPUnnormalized()           { _features[0] |= HFPUnnormalizedMask; }
 451   static void set_has_ExtractCPUtime()            { _features[0] |= ExtractCPUTimeMask; }
 452   static void set_has_StoreClockFast()            { _features[0] |= StoreClockFastMask; }
 453   static void set_has_extended_immediate()        { _features[0] |= ExtImmedFacilityMask; }
 454   static void set_has_long_displacement_fast()    { _features[0] |= LongDispFacilityHighPerfMask; }
 455   static void set_has_long_displacement()         { _features[0] |= LongDispFacilityMask; }
 456   static void set_has_ETF2()                      { _features[0] |= ETF2Mask; }
 457   static void set_has_ETF3()                      { _features[0] |= ETF3Mask; }
 458   static void set_has_ETF2Enhancements()          { _features[0] |= ETF2EnhancementMask; }
 459   static void set_has_ETF3Enhancements()          { _features[0] |= ETF3EnhancementMask; }
 460   static void set_has_Crypto()                    { _features[0] |= CryptoFacilityMask; }
 461   static void set_has_StoreFacilityListExtended() { _features[0] |= StoreFacilityListExtendedMask; }
 462 
 463   static void set_has_InterlockedAccessV1()       { _features[0] |= InterlockedAccess1Mask; }
 464   static void set_has_PopCount()                  { _features[0] |= PopulationCountMask; }
 465   static void set_has_LoadStoreConditional()      { _features[0] |= LoadStoreConditionalMask; }
 466   static void set_has_HighWordInstr()             { _features[0] |= HighWordMask; }
 467   static void set_has_FastSync()                  { _features[0] |= FastBCRSerializationMask; }
 468   static void set_has_DistinctOpnds()             { _features[0] |= DistinctOpndsMask; }
 469   static void set_has_FPExtensions()              { _features[0] |= FPExtensionsMask; }
 470   static void set_has_MiscInstrExt()              { _features[0] |= MiscInstrExtMask; }


 471   static void set_has_ProcessorAssist()           { _features[0] |= ProcessorAssistMask; }
 472   static void set_has_InterlockedAccessV2()       { _features[0] |= InterlockedAccess2Mask; }
 473   static void set_has_LoadAndALUAtomicV2()        { _features[0] |= InterlockedAccess2Mask; }
 474   static void set_has_TxMem()                     { _features[0] |= ConstrainedTxExecutionMask; _features[1] |= TransactionalExecutionMask; }
 475   static void set_has_CryptoExt3()                { _features[1] |= CryptoExtension3Mask; }
 476   static void set_has_CryptoExt4()                { _features[1] |= CryptoExtension4Mask; }
 477   static void set_has_LoadStoreConditional2()     { _features[0] |= LoadStoreConditional2Mask; }
 478   static void set_has_CryptoExt5()                { _features[0] |= CryptoExtension5Mask; }


 479   static void set_has_VectorFacility()            { _features[2] |= VectorFacilityMask; }




 480 
 481   static void reset_has_VectorFacility()          { _features[2] &= ~VectorFacilityMask; }
 482 
 483   // Assembler testing.
 484   static void allow_all();
 485   static void revert();
 486 
 487   // Generate trapping instructions into C-code.
 488   // Sometimes helpful for debugging.
 489   static unsigned long z_SIGILL();
 490   static unsigned long z_SIGSEGV();
 491 };
 492 
 493 #endif // CPU_S390_VM_VM_VERSION_S390_HPP


  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_S390_VM_VM_VERSION_S390_HPP
  27 #define CPU_S390_VM_VM_VERSION_S390_HPP
  28 
  29 
  30 #include "runtime/abstract_vm_version.hpp"
  31 #include "runtime/globals_extension.hpp"
  32 
  33 class VM_Version: public Abstract_VM_Version {
  34 
  35  protected:












  36 // z/Architecture is the name of the 64-bit extension of the 31-bit s390
  37 // architecture.
  38 //
  39 // For information concerning the life span of the individual
  40 // z/Architecture models, please check out the comments/tables
  41 // in vm_version_s390.cpp
  42 
  43 // ----------------------------------------------
  44 // --- FeatureBitString Bits   0.. 63 (DW[0]) ---
  45 // ----------------------------------------------
  46 //                                           11222334445566
  47 //                                        04826048260482604
  48 #define  StoreFacilityListExtendedMask  0x0100000000000000UL  // z9
  49 #define  ETF2Mask                       0x0000800000000000UL  // z900
  50 #define  CryptoFacilityMask             0x0000400000000000UL  // z990
  51 #define  LongDispFacilityMask           0x0000200000000000UL  // z900 with microcode update
  52 #define  LongDispFacilityHighPerfMask   0x0000300000000000UL  // z990
  53 #define  HFPMultiplyAndAddMask          0x0000080000000000UL  // z990
  54 #define  ExtImmedFacilityMask           0x0000040000000000UL  // z9
  55 #define  ETF3Mask                       0x0000020000000000UL  // z990/z9 (?)
  56 #define  HFPUnnormalizedMask            0x0000010000000000UL  // z9
  57 #define  ETF2EnhancementMask            0x0000008000000000UL  // z9
  58 #define  StoreClockFastMask             0x0000004000000000UL  // z9
  59 #define  ParsingEnhancementsMask        0x0000002000000000UL  // z10(?)
  60 #define  ETF3EnhancementMask            0x0000000200000000UL  // z9
  61 #define  ExtractCPUTimeMask             0x0000000100000000UL  // z10
  62 #define  CompareSwapStoreMask           0x00000000c0000000UL  // z10


  69 #define  DistinctOpndsMask              0x0000000000040000UL  // z196
  70 #define  FastBCRSerializationMask       DistinctOpndsMask
  71 #define  HighWordMask                   DistinctOpndsMask
  72 #define  LoadStoreConditionalMask       DistinctOpndsMask
  73 #define  PopulationCountMask            DistinctOpndsMask
  74 #define  InterlockedAccess1Mask         DistinctOpndsMask
  75 // z196 end
  76 // EC12 begin
  77 #define  DFPZonedConversionMask         0x0000000000008000UL  // ec12
  78 #define  MiscInstrExtMask               0x0000000000004000UL  // ec12
  79 #define  ExecutionHintMask              MiscInstrExtMask
  80 #define  LoadAndTrapMask                MiscInstrExtMask
  81 #define  ProcessorAssistMask            MiscInstrExtMask
  82 #define  ConstrainedTxExecutionMask     0x0000000000002000UL  // ec12
  83 #define  InterlockedAccess2Mask         0x0000000000000800UL  // ec12
  84 // EC12 end
  85 // z13 begin
  86 #define  LoadStoreConditional2Mask      0x0000000000000400UL  // z13
  87 #define  CryptoExtension5Mask           0x0000000000000040UL  // z13
  88 // z13 end
  89 #define  MiscInstrExt2Mask              0x0000000000000020UL  // z14
  90 #define  MiscInstrExt3Mask              0x0000000000000004UL  // z15



  91 // ----------------------------------------------
  92 // --- FeatureBitString Bits  64..127 (DW[1]) ---
  93 // ----------------------------------------------
  94 //                                                 11111111
  95 //                                        66778889900011222
  96 //                                        48260482604826048
  97 #define  TransactionalExecutionMask     0x0040000000000000UL  // ec12
  98 #define  CryptoExtension3Mask           0x0008000000000000UL  // z196
  99 #define  CryptoExtension4Mask           0x0004000000000000UL  // z196
 100 #define  DFPPackedConversionMask        0x0000800000000000UL  // z13
 101 // ----------------------------------------------
 102 // --- FeatureBitString Bits 128..192 (DW[2]) ---
 103 // ----------------------------------------------
 104 //                                        11111111111111111
 105 //                                        23344455666778889
 106 //                                        82604826048260482
 107 #define  VectorFacilityMask             0x4000000000000000UL  // z13, not avail in VM guest mode!
 108 #define  ExecutionProtectionMask        0x2000000000000000UL  // z14
 109 #define  GuardedStorageMask             0x0400000000000000UL  // z14
 110 #define  VectorEnhancements1Mask        0x0100000000000000UL  // z14
 111 #define  VectorPackedDecimalMask        0x0200000000000000UL  // z14
 112 #define  CryptoExtension8Mask           0x0000200000000040UL  // z14
 113 #define  VectorEnhancements2Mask        0x0000080000000000UL  // z15
 114 #define  VectorPackedDecimalEnhMask     0x0000008000000000UL  // z15
 115 #define  CryptoExtension9Mask           0x0000001000000040UL  // z15
 116 #define  DeflateMask                    0x0000010000000040UL  // z15
 117 
 118   enum {
 119     _max_cache_levels = 8,    // As limited by ECAG instruction.
 120     _features_buffer_len = 4, // in DW
 121     _code_buffer_len = 2*256  // For feature detection code.
 122   };
 123   static unsigned long _features[_features_buffer_len];
 124   static unsigned long _cipher_features[_features_buffer_len];
 125   static unsigned long _msgdigest_features[_features_buffer_len];
 126   static unsigned int  _nfeatures;
 127   static unsigned int  _ncipher_features;
 128   static unsigned int  _nmsgdigest_features;
 129   static unsigned int  _Dcache_lineSize;
 130   static unsigned int  _Icache_lineSize;
 131   static bool          _is_determine_features_test_running;
 132   static const char*   _model_string;
 133 
 134   static bool test_feature_bit(unsigned long* featureBuffer, int featureNum, unsigned int bufLen);
 135   static void set_features_string();
 136   static void print_features_internal(const char* text, bool print_anyway=false);
 137   static void determine_features();
 138   static long call_getFeatures(unsigned long* buffer, int buflen, int functionCode);
 139   static void set_getFeatures(address entryPoint);
 140   static int  calculate_ECAG_functionCode(unsigned int attributeIndication,
 141                                           unsigned int levelIndication,
 142                                           unsigned int typeIndication);
 143 
 144   // Setting features via march=z900|z990|z9|z10|z196|ec12|z13|z14|z15 commandline option.
 145   static void reset_features(bool reset);
 146   static void set_features_z900(bool reset = true);
 147   static void set_features_z990(bool reset = true);
 148   static void set_features_z9(bool reset = true);
 149   static void set_features_z10(bool reset = true);
 150   static void set_features_z196(bool reset = true);
 151   static void set_features_ec12(bool reset = true);
 152   static void set_features_z13(bool reset = true);
 153   static void set_features_z14(bool reset = true);
 154   static void set_features_z15(bool reset = true);
 155   static void set_features_from(const char* march);
 156 
 157   // Get information about cache line sizes.
 158   // As of now and the foreseeable future, line size of all levels will be the same and 256.
 159   static unsigned int Dcache_lineSize(unsigned int level = 0) { return _Dcache_lineSize; }
 160   static unsigned int Icache_lineSize(unsigned int level = 0) { return _Icache_lineSize; }
 161 
 162  public:
 163 
 164   // Get the CPU type from feature bit settings.
 165   static bool is_z900() { return has_long_displacement()      && !has_long_displacement_fast(); }
 166   static bool is_z990() { return has_long_displacement_fast() && !has_extended_immediate();  }
 167   static bool is_z9()   { return has_extended_immediate()     && !has_GnrlInstrExtensions(); }
 168   static bool is_z10()  { return has_GnrlInstrExtensions()    && !has_DistinctOpnds(); }
 169   static bool is_z196() { return has_DistinctOpnds()          && !has_MiscInstrExt(); }
 170   static bool is_ec12() { return has_MiscInstrExt()           && !has_CryptoExt5(); }
 171   static bool is_z13()  { return has_CryptoExt5()             && !has_MiscInstrExt2();}
 172   static bool is_z14()  { return has_MiscInstrExt2()          && !has_MiscInstrExt3();}
 173   static bool is_z15()  { return has_MiscInstrExt3();}





 174 
 175   // Need to use nested class with unscoped enum.
 176   // C++11 declaration "enum class Cipher { ... } is not supported.
 177   class CipherMode {
 178     public:
 179       enum {
 180         cipher   = 0x00,
 181         decipher = 0x80
 182       };
 183   };
 184   class Cipher {
 185    public:
 186     enum { // KM only!!! KMC uses different parmBlk sizes.
 187       _Query              =   0,
 188       _DEA                =   1,
 189       _TDEA128            =   2,
 190       _TDEA192            =   3,
 191       _EncryptedDEA       =   9,
 192       _EncryptedDEA128    =  10,
 193       _EncryptedDEA192    =  11,


 384   // Memory-immediate arithmetic instructions. There is no performance penalty in using them.
 385   // Moreover, these memory-immediate instructions are quasi-atomic (>99.99%) on z10
 386   // and 100% atomic from z196 onwards, thanks to the specific operand serialization that comes new with z196.
 387   static bool has_MemWithImmALUOps()          { return  has_GnrlInstrExtensions(); }
 388   static bool has_AtomicMemWithImmALUOps()    { return   has_MemWithImmALUOps() && has_InterlockedAccessV1(); }
 389   static bool has_FPExtensions()              { return  (_features[0] & FPExtensionsMask)              == FPExtensionsMask; }
 390   static bool has_FPSupportEnhancements()     { return  (_features[0] & FPSupportEnhancementsMask)     == FPSupportEnhancementsMask; }
 391   static bool has_DecimalFloatingPoint()      { return  (_features[0] & DecimalFloatingPointMask)      == DecimalFloatingPointMask; }
 392   static bool has_InterlockedAccessV1()       { return  (_features[0] & InterlockedAccess1Mask)        == InterlockedAccess1Mask; }
 393   static bool has_LoadAndALUAtomicV1()        { return  (_features[0] & InterlockedAccess1Mask)        == InterlockedAccess1Mask; }
 394   static bool has_PopCount()                  { return  (_features[0] & PopulationCountMask)           == PopulationCountMask; }
 395   static bool has_LoadStoreConditional()      { return  (_features[0] & LoadStoreConditionalMask)      == LoadStoreConditionalMask; }
 396   static bool has_HighWordInstr()             { return  (_features[0] & HighWordMask)                  == HighWordMask; }
 397   static bool has_FastSync()                  { return  (_features[0] & FastBCRSerializationMask)      == FastBCRSerializationMask; }
 398   static bool has_DistinctOpnds()             { return  (_features[0] & DistinctOpndsMask)             == DistinctOpndsMask; }
 399   static bool has_CryptoExt3()                { return  (_features[1] & CryptoExtension3Mask)          == CryptoExtension3Mask; }
 400   static bool has_CryptoExt4()                { return  (_features[1] & CryptoExtension4Mask)          == CryptoExtension4Mask; }
 401   static bool has_DFPZonedConversion()        { return  (_features[0] & DFPZonedConversionMask)        == DFPZonedConversionMask; }
 402   static bool has_DFPPackedConversion()       { return  (_features[1] & DFPPackedConversionMask)       == DFPPackedConversionMask; }
 403   static bool has_MiscInstrExt()              { return  (_features[0] & MiscInstrExtMask)              == MiscInstrExtMask; }
 404   static bool has_MiscInstrExt2()             { return  (_features[0] & MiscInstrExt2Mask)             == MiscInstrExt2Mask; }
 405   static bool has_MiscInstrExt3()             { return  (_features[0] & MiscInstrExt3Mask)             == MiscInstrExt3Mask; }
 406   static bool has_ExecutionHint()             { return  (_features[0] & ExecutionHintMask)             == ExecutionHintMask; }
 407   static bool has_LoadAndTrap()               { return  (_features[0] & LoadAndTrapMask)               == LoadAndTrapMask; }
 408   static bool has_ProcessorAssist()           { return  (_features[0] & ProcessorAssistMask)           == ProcessorAssistMask; }
 409   static bool has_InterlockedAccessV2()       { return  (_features[0] & InterlockedAccess2Mask)        == InterlockedAccess2Mask; }
 410   static bool has_LoadAndALUAtomicV2()        { return  (_features[0] & InterlockedAccess2Mask)        == InterlockedAccess2Mask; }
 411   static bool has_TxMem()                     { return ((_features[1] & TransactionalExecutionMask)    == TransactionalExecutionMask) &&
 412                                                        ((_features[0] & ConstrainedTxExecutionMask)    == ConstrainedTxExecutionMask); }
 413   static bool has_CryptoExt5()                { return  (_features[0] & CryptoExtension5Mask)          == CryptoExtension5Mask; }
 414   static bool has_CryptoExt8()                { return  (_features[2] & CryptoExtension8Mask)          == CryptoExtension8Mask; }
 415   static bool has_CryptoExt9()                { return  (_features[2] & CryptoExtension9Mask)          == CryptoExtension9Mask; }
 416   static bool has_LoadStoreConditional2()     { return  (_features[0] & LoadStoreConditional2Mask)     == LoadStoreConditional2Mask; }
 417   static bool has_VectorFacility()            { return  (_features[2] & VectorFacilityMask)            == VectorFacilityMask; }
 418   static bool has_VectorEnhancements1()       { return  (_features[2] & VectorEnhancements1Mask)       == VectorEnhancements1Mask; }
 419   static bool has_VectorEnhancements2()       { return  (_features[2] & VectorEnhancements2Mask)       == VectorEnhancements2Mask; }
 420   static bool has_VectorPackedDecimal()       { return  (_features[2] & VectorPackedDecimalMask)       == VectorPackedDecimalMask; }
 421   static bool has_VectorPackedDecimalEnh()    { return  (_features[2] & VectorPackedDecimalEnhMask)    == VectorPackedDecimalEnhMask; }



 422 
 423   // Crypto features query functions.
 424   static bool has_Crypto_AES128()             { return has_Crypto() && test_feature_bit(&_cipher_features[0], Cipher::_AES128, Cipher::_featureBits); }
 425   static bool has_Crypto_AES192()             { return has_Crypto() && test_feature_bit(&_cipher_features[0], Cipher::_AES192, Cipher::_featureBits); }
 426   static bool has_Crypto_AES256()             { return has_Crypto() && test_feature_bit(&_cipher_features[0], Cipher::_AES256, Cipher::_featureBits); }
 427   static bool has_Crypto_AES()                { return has_Crypto_AES128() || has_Crypto_AES192() || has_Crypto_AES256(); }
 428 
 429   static bool has_Crypto_SHA1()               { return has_Crypto() && test_feature_bit(&_msgdigest_features[0], MsgDigest::_SHA1,   MsgDigest::_featureBits); }
 430   static bool has_Crypto_SHA256()             { return has_Crypto() && test_feature_bit(&_msgdigest_features[0], MsgDigest::_SHA256, MsgDigest::_featureBits); }
 431   static bool has_Crypto_SHA512()             { return has_Crypto() && test_feature_bit(&_msgdigest_features[0], MsgDigest::_SHA512, MsgDigest::_featureBits); }
 432   static bool has_Crypto_GHASH()              { return has_Crypto() && test_feature_bit(&_msgdigest_features[0], MsgDigest::_GHASH,  MsgDigest::_featureBits); }
 433   static bool has_Crypto_SHA()                { return has_Crypto_SHA1() || has_Crypto_SHA256() || has_Crypto_SHA512() || has_Crypto_GHASH(); }
 434 
 435   // CPU feature setters (to force model-specific behaviour). Test/debugging only.




 436   static void set_has_DecimalFloatingPoint()      { _features[0] |= DecimalFloatingPointMask; }
 437   static void set_has_FPSupportEnhancements()     { _features[0] |= FPSupportEnhancementsMask; }
 438   static void set_has_ExecuteExtensions()         { _features[0] |= ExecuteExtensionsMask; }
 439   static void set_has_MemWithImmALUOps()          { _features[0] |= GnrlInstrExtFacilityMask; }
 440   static void set_has_MoveImmToMem()              { _features[0] |= GnrlInstrExtFacilityMask; }
 441   static void set_has_Prefetch()                  { _features[0] |= GnrlInstrExtFacilityMask; }
 442   static void set_has_MultiplySingleImm32()       { _features[0] |= GnrlInstrExtFacilityMask; }
 443   static void set_has_CompareBranch()             { _features[0] |= GnrlInstrExtFacilityMask; }
 444   static void set_has_CompareTrap()               { _features[0] |= GnrlInstrExtFacilityMask; }
 445   static void set_has_RelativeLoadStore()         { _features[0] |= GnrlInstrExtFacilityMask; }
 446   static void set_has_GnrlInstrExtensions()       { _features[0] |= GnrlInstrExtFacilityMask; }
 447   static void set_has_CompareSwapStore()          { _features[0] |= CompareSwapStoreMask; }
 448   static void set_has_HFPMultiplyAndAdd()         { _features[0] |= HFPMultiplyAndAddMask; }
 449   static void set_has_HFPUnnormalized()           { _features[0] |= HFPUnnormalizedMask; }
 450   static void set_has_ExtractCPUtime()            { _features[0] |= ExtractCPUTimeMask; }
 451   static void set_has_StoreClockFast()            { _features[0] |= StoreClockFastMask; }
 452   static void set_has_extended_immediate()        { _features[0] |= ExtImmedFacilityMask; }
 453   static void set_has_long_displacement_fast()    { _features[0] |= LongDispFacilityHighPerfMask; }
 454   static void set_has_long_displacement()         { _features[0] |= LongDispFacilityMask; }
 455   static void set_has_ETF2()                      { _features[0] |= ETF2Mask; }
 456   static void set_has_ETF3()                      { _features[0] |= ETF3Mask; }
 457   static void set_has_ETF2Enhancements()          { _features[0] |= ETF2EnhancementMask; }
 458   static void set_has_ETF3Enhancements()          { _features[0] |= ETF3EnhancementMask; }
 459   static void set_has_Crypto()                    { _features[0] |= CryptoFacilityMask; }
 460   static void set_has_StoreFacilityListExtended() { _features[0] |= StoreFacilityListExtendedMask; }
 461 
 462   static void set_has_InterlockedAccessV1()       { _features[0] |= InterlockedAccess1Mask; }
 463   static void set_has_PopCount()                  { _features[0] |= PopulationCountMask; }
 464   static void set_has_LoadStoreConditional()      { _features[0] |= LoadStoreConditionalMask; }
 465   static void set_has_HighWordInstr()             { _features[0] |= HighWordMask; }
 466   static void set_has_FastSync()                  { _features[0] |= FastBCRSerializationMask; }
 467   static void set_has_DistinctOpnds()             { _features[0] |= DistinctOpndsMask; }
 468   static void set_has_FPExtensions()              { _features[0] |= FPExtensionsMask; }
 469   static void set_has_MiscInstrExt()              { _features[0] |= MiscInstrExtMask; }
 470   static void set_has_MiscInstrExt2()             { _features[0] |= MiscInstrExt2Mask; }
 471   static void set_has_MiscInstrExt3()             { _features[0] |= MiscInstrExt3Mask; }
 472   static void set_has_ProcessorAssist()           { _features[0] |= ProcessorAssistMask; }
 473   static void set_has_InterlockedAccessV2()       { _features[0] |= InterlockedAccess2Mask; }
 474   static void set_has_LoadAndALUAtomicV2()        { _features[0] |= InterlockedAccess2Mask; }
 475   static void set_has_TxMem()                     { _features[0] |= ConstrainedTxExecutionMask; _features[1] |= TransactionalExecutionMask; }
 476   static void set_has_CryptoExt3()                { _features[1] |= CryptoExtension3Mask; }
 477   static void set_has_CryptoExt4()                { _features[1] |= CryptoExtension4Mask; }
 478   static void set_has_LoadStoreConditional2()     { _features[0] |= LoadStoreConditional2Mask; }
 479   static void set_has_CryptoExt5()                { _features[0] |= CryptoExtension5Mask; }
 480   static void set_has_CryptoExt8()                { _features[2] |= CryptoExtension8Mask; }
 481   static void set_has_CryptoExt9()                { _features[2] |= CryptoExtension9Mask; }
 482   static void set_has_VectorFacility()            { _features[2] |= VectorFacilityMask; }
 483   static void set_has_VectorEnhancements1()       { _features[2] |= VectorEnhancements1Mask; }
 484   static void set_has_VectorEnhancements2()       { _features[2] |= VectorEnhancements2Mask; }
 485   static void set_has_VectorPackedDecimal()       { _features[2] |= VectorPackedDecimalMask; }
 486   static void set_has_VectorPackedDecimalEnh()    { _features[2] |= VectorPackedDecimalEnhMask; }
 487 
 488   static void reset_has_VectorFacility()          { _features[2] &= ~VectorFacilityMask; }
 489 
 490   // Assembler testing.
 491   static void allow_all();
 492   static void revert();
 493 
 494   // Generate trapping instructions into C-code.
 495   // Sometimes helpful for debugging.
 496   static unsigned long z_SIGILL();
 497   static unsigned long z_SIGSEGV();
 498 };
 499 
 500 #endif // CPU_S390_VM_VM_VERSION_S390_HPP
< prev index next >