Merge JDK-8200758-branch
authorherrick
Mon, 15 Apr 2019 09:34:52 -0400
branchJDK-8200758-branch
changeset 57327 8b01c7bfb36f
parent 57326 603101a378fe (current diff)
parent 54530 00c0906bf4d1 (diff)
child 57328 b33e5f36b59b
Merge
--- a/src/hotspot/cpu/x86/vm_version_ext_x86.cpp	Mon Apr 15 08:56:39 2019 -0400
+++ b/src/hotspot/cpu/x86/vm_version_ext_x86.cpp	Mon Apr 15 09:34:52 2019 -0400
@@ -43,10 +43,10 @@
    CPU_FAMILY_PENTIUM_4  = 0xF
 } FamilyFlag;
 
- typedef enum {
-    RDTSCP_FLAG  = 0x08000000, // bit 27
-    INTEL64_FLAG = 0x20000000  // bit 29
-  } _featureExtendedEdxFlag;
+typedef enum {
+  RDTSCP_FLAG  = 0x08000000, // bit 27
+  INTEL64_FLAG = 0x20000000  // bit 29
+} _featureExtendedEdxFlag;
 
 #define CPUID_STANDARD_FN   0x0
 #define CPUID_STANDARD_FN_1 0x1
@@ -403,18 +403,21 @@
 const char* VM_Version_Ext::cpu_family_description(void) {
   int cpu_family_id = extended_cpu_family();
   if (is_amd()) {
-    return _family_id_amd[cpu_family_id];
+    if (cpu_family_id < ExtendedFamilyIdLength_AMD) {
+      return _family_id_amd[cpu_family_id];
+    }
   }
   if (is_intel()) {
     if (cpu_family_id == CPU_FAMILY_PENTIUMPRO) {
       return cpu_model_description();
     }
-    return _family_id_intel[cpu_family_id];
+    if (cpu_family_id < ExtendedFamilyIdLength_INTEL) {
+      return _family_id_intel[cpu_family_id];
+    }
   }
   if (is_hygon()) {
     return "Dhyana";
   }
-
   return "Unknown x86";
 }
 
@@ -705,7 +708,7 @@
   return _max_qualified_cpu_frequency;
 }
 
-const char* const VM_Version_Ext::_family_id_intel[] = {
+const char* const VM_Version_Ext::_family_id_intel[ExtendedFamilyIdLength_INTEL] = {
   "8086/8088",
   "",
   "286",
@@ -724,7 +727,7 @@
   "Pentium 4"
 };
 
-const char* const VM_Version_Ext::_family_id_amd[] = {
+const char* const VM_Version_Ext::_family_id_amd[ExtendedFamilyIdLength_AMD] = {
   "",
   "",
   "",
@@ -742,6 +745,13 @@
   "",
   "Opteron/Athlon64",
   "Opteron QC/Phenom"  // Barcelona et.al.
+  "",
+  "",
+  "",
+  "",
+  "",
+  "",
+  "Zen"
 };
 // Partially from Intel 64 and IA-32 Architecture Software Developer's Manual,
 // September 2013, Vol 3C Table 35-1
--- a/src/hotspot/cpu/x86/vm_version_ext_x86.hpp	Mon Apr 15 08:56:39 2019 -0400
+++ b/src/hotspot/cpu/x86/vm_version_ext_x86.hpp	Mon Apr 15 09:34:52 2019 -0400
@@ -29,14 +29,20 @@
 #include "vm_version_x86.hpp"
 
 class VM_Version_Ext : public VM_Version {
+
+  enum {
+    ExtendedFamilyIdLength_INTEL = 16,
+    ExtendedFamilyIdLength_AMD   = 24
+  };
+
  private:
   static const size_t      VENDOR_LENGTH;
   static const size_t      CPU_EBS_MAX_LENGTH;
   static const size_t      CPU_TYPE_DESC_BUF_SIZE;
   static const size_t      CPU_DETAILED_DESC_BUF_SIZE;
 
-  static const char* const _family_id_intel[];
-  static const char* const _family_id_amd[];
+  static const char* const _family_id_intel[ExtendedFamilyIdLength_INTEL];
+  static const char* const _family_id_amd[ExtendedFamilyIdLength_AMD];
   static const char* const _brand_id[];
   static const char* const _model_id_pentium_pro[];
 
--- a/test/jdk/sun/security/tools/keytool/Serial64.java	Mon Apr 15 08:56:39 2019 -0400
+++ b/test/jdk/sun/security/tools/keytool/Serial64.java	Mon Apr 15 09:34:52 2019 -0400
@@ -23,15 +23,13 @@
 
 /*
  * @test
- * @bug 8221257
+ * @bug 8221257 8222275
  * @summary Improve serial number generation mechanism for keytool -gencert
  * @library /test/lib
  * @key randomness
  */
 
-import jdk.test.lib.Asserts;
 import jdk.test.lib.SecurityTools;
-import jdk.test.lib.process.OutputAnalyzer;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -39,57 +37,59 @@
 import java.security.KeyStore;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.List;
 
 public class Serial64 {
 
-    static List<BigInteger> numbers = new ArrayList<>();
-
     public static void main(String[] args) throws Exception {
 
-        // 10 Self-signed certs and issued certs
-        genkeypair("ca");
-        genkeypair("user");
-        for (int i = 0; i < 8; i++) {
-            gencert("ca", "user");
+        boolean see64 = false;
+
+        see64 |= see64(genkeypair("ca"));
+        see64 |= see64(genkeypair("user"));
+
+        keytool("-certreq -alias user -file req");
+
+        for (int i = 3; i <= 30; i++) {
+            see64 |= see64(gencert());
+            if (i >= 10 && see64) {
+                // As long as we have generated >=10 (non-negative) SNs and
+                // at least one is 64 bit it's good to go.
+                return;
+            }
         }
 
-        numbers.forEach(b -> System.out.println(b.toString(16)));
-
-        // Must be positive, therefore never zero.
-        Asserts.assertTrue(numbers.stream()
-                .allMatch(b -> b.signum() == 1));
-
-        // At least one should be 64 bit. There is a chance of
-        // 2^-10 this would fail.
-        Asserts.assertTrue(numbers.stream()
-                .anyMatch(b -> b.bitLength() == 64));
+        // None is 64 bit. There is a chance of 2^-30 we reach here.
+        // Or, maybe we do have a bug?
+        throw new RuntimeException("No 64-bit serial number");
     }
 
-    static OutputAnalyzer keytool(String s) throws Exception {
-        return SecurityTools.keytool(
-                "-storepass changeit -keypass changeit "
-                        + "-keystore ks -keyalg rsa " + s);
+    static boolean see64(BigInteger sn) {
+        System.out.println(sn.toString(16));
+
+        if (sn.signum() != 1) {
+            throw new RuntimeException("Must be positive");
+        }
+        return sn.bitLength() == 64;
     }
 
-    static void genkeypair(String a) throws Exception {
-        keytool("-genkeypair -alias " + a + " -dname CN=" + a)
+    static void keytool(String s) throws Exception {
+        SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keystore ks -keyalg rsa " + s)
                 .shouldHaveExitValue(0);
-        numbers.add(((X509Certificate)KeyStore.getInstance(
-                new File("ks"), "changeit".toCharArray())
-                    .getCertificate(a)).getSerialNumber());
     }
 
-    static void gencert(String signer, String owner)
-            throws Exception {
-        keytool("-certreq -alias " + owner + " -file req")
-                .shouldHaveExitValue(0);
-        keytool("-gencert -alias " + signer + " -infile req -outfile cert")
-                .shouldHaveExitValue(0);
+    static BigInteger genkeypair(String a) throws Exception {
+        keytool("-genkeypair -alias " + a + " -dname CN=" + a);
+        return ((X509Certificate)KeyStore.getInstance(
+                new File("ks"), "changeit".toCharArray())
+                    .getCertificate(a)).getSerialNumber();
+    }
+
+    static BigInteger gencert() throws Exception {
+        keytool("-gencert -alias ca -infile req -outfile cert");
         try (FileInputStream fis = new FileInputStream("cert")) {
-            numbers.add(((X509Certificate)CertificateFactory.getInstance("X.509")
-                    .generateCertificate(fis)).getSerialNumber());
+            return ((X509Certificate)CertificateFactory.getInstance("X.509")
+                    .generateCertificate(fis)).getSerialNumber();
         }
     }
 }
--- a/test/langtools/tools/javac/classreader/8171132/BadConstantValue.java	Mon Apr 15 08:56:39 2019 -0400
+++ b/test/langtools/tools/javac/classreader/8171132/BadConstantValue.java	Mon Apr 15 09:34:52 2019 -0400
@@ -134,6 +134,8 @@
                 "class Lib { static final int A = %s; static final %s B = %s; }",
                 value, type, (type.equals("boolean") ? "false" : "0")));
         compile("-d", classesdir.getPath(), lib.getPath());
+        // Lib.class may possibly not get a newer timestamp. Make sure .java file won't get used.
+        lib.delete();
         File libClass = new File(classesdir, "Lib.class");
         // Rewrite the class to only have field B of type "type" and with "value" (potentially
         // out of range).
@@ -147,6 +149,8 @@
                 "class Lib { static final String A = \"hello\"; static final %s CONST = %s; }",
                 type, type.equals("boolean") ? "false" : "0"));
         compile("-d", classesdir.getPath(), lib.getPath());
+        // Lib.class may possibly not get a newer timestamp. Make sure .java file won't get used.
+        lib.delete();
         File libClass = new File(classesdir, "Lib.class");
         swapConstantValues(libClass);