src/hotspot/cpu/s390/vm_version_s390.cpp
changeset 47607 c2ff34932cbd
parent 47216 71c04702a3d5
child 47634 6a0c42c40cd1
--- a/src/hotspot/cpu/s390/vm_version_s390.cpp	Mon Oct 09 11:43:42 2017 +0200
+++ b/src/hotspot/cpu/s390/vm_version_s390.cpp	Mon Oct 09 11:51:20 2017 +0200
@@ -706,12 +706,13 @@
   Label    getCPUFEATURES;                   // fcode = -1 (cache)
   Label    getCIPHERFEATURES;                // fcode = -2 (cipher)
   Label    getMSGDIGESTFEATURES;             // fcode = -3 (SHA)
+  Label    getVECTORFEATURES;                // fcode = -4 (OS support for vector instructions)
   Label    checkLongDispFast;
   Label    noLongDisp;
   Label    posDisp, negDisp;
   Label    errRTN;
   a->z_ltgfr(Z_R0, Z_ARG2);                  // Buf len to r0 and test.
-  a->z_brl(getFEATURES);                     // negative -> Get machine features.
+  a->z_brl(getFEATURES);                     // negative -> Get machine features not covered by facility list.
   a->z_brz(checkLongDispFast);               // zero -> Check for high-speed Long Displacement Facility.
   a->z_aghi(Z_R0, -1);
   a->z_stfle(0, Z_ARG1);
@@ -736,6 +737,8 @@
   a->z_bre(getCIPHERFEATURES);
   a->z_cghi(Z_R0, -3);                       // -3: Extract detailed crypto capabilities (msg digest instructions).
   a->z_bre(getMSGDIGESTFEATURES);
+  a->z_cghi(Z_R0, -4);                       // -4: Verify vector instruction availability (OS support).
+  a->z_bre(getVECTORFEATURES);
 
   a->z_xgr(Z_RET, Z_RET);                    // Not a valid function code.
   a->z_br(Z_R14);                            // Return "operation aborted".
@@ -766,6 +769,11 @@
   a->z_ecag(Z_RET,Z_R0,0,Z_ARG3);            // Extract information as requested by Z_ARG1 contents.
   a->z_br(Z_R14);
 
+  // Use a vector instruction to verify OS support. Will fail with SIGFPE if OS support is missing.
+  a->bind(getVECTORFEATURES);
+  a->z_vtm(Z_V0,Z_V0);                       // non-destructive vector instruction. Will cause SIGFPE if not supported.
+  a->z_br(Z_R14);
+
   // Check the performance of the Long Displacement Facility, i.e. find out if we are running on z900 or newer.
   a->bind(checkLongDispFast);
   a->z_llill(Z_R0, 0xffff);                  // preset #iterations
@@ -962,6 +970,19 @@
     _nfeatures = 0;
   }
 
+  if (has_VectorFacility()) {
+    // Verify that feature can actually be used. OS support required.
+    call_getFeatures(buffer, -4, 0);
+    if (printVerbose) {
+      ttyLocker ttyl;
+      if (has_VectorFacility()) {
+        tty->print_cr("  Vector Facility has been verified to be supported by OS");
+      } else {
+        tty->print_cr("  Vector Facility has been disabled - not supported by OS");
+      }
+    }
+  }
+
   // Extract Crypto Facility details.
   if (has_Crypto()) {
     // Get cipher features.