8249672: Include microcode revision in features_string on x86
Reviewed-by: kvn, stuefe
This commit is contained in:
parent
006d0bcec1
commit
cd98f7d5bf
src/hotspot
cpu/x86
os_cpu
bsd_x86
linux_x86
windows_x86
@ -733,11 +733,11 @@ void VM_Version::get_processor_features() {
|
||||
|
||||
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" : ""),
|
||||
|
@ -801,6 +801,18 @@ bool os::is_allocatable(size_t bytes) {
|
||||
#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
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
static void setup_fpu();
|
||||
static bool supports_sse();
|
||||
static juint cpu_microcode_revision();
|
||||
|
||||
static jlong rdtsc();
|
||||
|
||||
|
@ -620,6 +620,26 @@ bool os::supports_sse() {
|
||||
#endif // AMD64
|
||||
}
|
||||
|
||||
juint os::cpu_microcode_revision() {
|
||||
juint result = 0;
|
||||
char data[2048] = {0}; // lines should fit in 2K buf
|
||||
size_t len = sizeof(data);
|
||||
FILE *fp = fopen("/proc/cpuinfo", "r");
|
||||
if (fp) {
|
||||
while (!feof(fp)) {
|
||||
if (fgets(data, len, fp)) {
|
||||
if (strstr(data, "microcode") != NULL) {
|
||||
char* rev = strchr(data, ':');
|
||||
if (rev != NULL) sscanf(rev + 1, "%x", &result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool os::is_allocatable(size_t bytes) {
|
||||
#ifdef AMD64
|
||||
// unused on amd64?
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
static void setup_fpu();
|
||||
static bool supports_sse();
|
||||
static juint cpu_microcode_revision();
|
||||
|
||||
static jlong rdtsc();
|
||||
|
||||
|
@ -649,6 +649,23 @@ extern "C" int SpinPause () {
|
||||
#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
|
||||
|
@ -59,6 +59,7 @@
|
||||
|
||||
static void setup_fpu();
|
||||
static bool supports_sse() { return true; }
|
||||
static juint cpu_microcode_revision();
|
||||
|
||||
static jlong rdtsc();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user