--- old/src/hotspot/cpu/x86/vm_version_x86.cpp 2020-07-17 15:30:45.196861065 -0700 +++ new/src/hotspot/cpu/x86/vm_version_x86.cpp 2020-07-17 15:30:45.008861056 -0700 @@ -733,11 +733,11 @@ char buf[512]; int res = jio_snprintf(buf, sizeof(buf), - "(%u cores per cpu, %u threads per core) family %d model %d stepping %d" + "(%u cores per cpu, %u threads per core) family %d model %d stepping %d microcode 0x%x" "%s%s%s%s%s%s%s%s%s%s" "%s%s%s%s%s%s%s%s%s%s" "%s%s%s%s%s%s%s%s%s%s" "%s%s%s%s%s%s%s%s%s%s" "%s%s%s%s%s%s", cores_per_cpu(), threads_per_core(), - cpu_family(), _model, _stepping, + cpu_family(), _model, _stepping, os::cpu_microcode_revision(), (supports_cmov() ? ", cmov" : ""), (supports_cmpxchg8() ? ", cx8" : ""), --- old/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp 2020-07-17 15:30:45.626861086 -0700 +++ new/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp 2020-07-17 15:30:45.436861077 -0700 @@ -801,6 +801,18 @@ #endif // AMD64 } +juint os::cpu_microcode_revision() { + juint result = 0; + char data[8]; + size_t sz = sizeof(data); + int ret = sysctlbyname("machdep.cpu.microcode_version", data, &sz, NULL, 0); + if (ret == 0) { + if (sz == 4) result = *((juint*)data); + if (sz == 8) result = *((juint*)data + 1); // upper 32-bits + } + return result; +} + //////////////////////////////////////////////////////////////////////////////// // thread stack --- old/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.hpp 2020-07-17 15:30:46.051861106 -0700 +++ new/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.hpp 2020-07-17 15:30:45.865861097 -0700 @@ -27,6 +27,7 @@ static void setup_fpu(); static bool supports_sse(); + static juint cpu_microcode_revision(); static jlong rdtsc(); --- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp 2020-07-17 15:30:46.473861127 -0700 +++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp 2020-07-17 15:30:46.286861118 -0700 @@ -620,6 +620,26 @@ #endif // AMD64 } +juint os::cpu_microcode_revision() { + juint result = 0; + char * line = NULL; + size_t len = 0; + ssize_t read; + FILE *fp = fopen("/proc/cpuinfo", "r"); + if (fp) { + while ((read = getline(&line, &len, fp)) != -1) { + if (len > 10 && strstr(line, "microcode") != NULL) { + char* rev = strchr(line, ':'); + if (rev != NULL) sscanf(rev + 1, "%x", &result); + break; + } + } + free(line); + fclose(fp); + } + return result; +} + bool os::is_allocatable(size_t bytes) { #ifdef AMD64 // unused on amd64? --- old/src/hotspot/os_cpu/linux_x86/os_linux_x86.hpp 2020-07-17 15:30:46.897861147 -0700 +++ new/src/hotspot/os_cpu/linux_x86/os_linux_x86.hpp 2020-07-17 15:30:46.710861138 -0700 @@ -27,6 +27,7 @@ static void setup_fpu(); static bool supports_sse(); + static juint cpu_microcode_revision(); static jlong rdtsc(); --- old/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp 2020-07-17 15:30:47.317861167 -0700 +++ new/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp 2020-07-17 15:30:47.130861158 -0700 @@ -649,6 +649,23 @@ #endif // AMD64 } +juint os::cpu_microcode_revision() { + juint result = 0; + BYTE data[8] = {0}; + HKEY key; + DWORD status = RegOpenKey(HKEY_LOCAL_MACHINE, + "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &key); + if (status == ERROR_SUCCESS) { + DWORD size = sizeof(data); + status = RegQueryValueEx(key, "Update Revision", NULL, NULL, data, &size); + if (status == ERROR_SUCCESS) { + if (size == 4) result = *((juint*)data); + if (size == 8) result = *((juint*)data + 1); // upper 32-bits + } + RegCloseKey(key); + } + return result; +} void os::setup_fpu() { #ifndef AMD64 --- old/src/hotspot/os_cpu/windows_x86/os_windows_x86.hpp 2020-07-17 15:30:47.740861188 -0700 +++ new/src/hotspot/os_cpu/windows_x86/os_windows_x86.hpp 2020-07-17 15:30:47.552861179 -0700 @@ -59,6 +59,7 @@ static void setup_fpu(); static bool supports_sse() { return true; } + static juint cpu_microcode_revision(); static jlong rdtsc();