JDK-8234160 implemented the mitigation feature and JDK-8240370 provided the JVM flag to opt-out of it. Unfortunately, current implementation does not set the flag ergonomically, instead it just sets the internal `VM_Version` flag. So we end up in a situation where we have *no* visibility whether the mitigation is actually enabled or not. More confusingly, the option would say `true` for machines where ergonomics does not enable the mitigation.
```
% build/linux-x86_64-server-release/images/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal 2>&1 | grep IntelJcc
bool IntelJccErratumMitigation = true
% lscpu
...
Model name: AMD EPYC 9R14
```
It would be good to set the flag value itself ergonomically.
Something simple might do:
```
diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp
index 42661bd7a2b..baeea79e7ea 100644
--- a/src/hotspot/cpu/x86/vm_version_x86.cpp
+++ b/src/hotspot/cpu/x86/vm_version_x86.cpp
@@ -1068,7 +1068,9 @@ void VM_Version::get_processor_features() {
}
if (FLAG_IS_DEFAULT(IntelJccErratumMitigation)) {
- _has_intel_jcc_erratum = compute_has_intel_jcc_erratum();
+ bool r = compute_has_intel_jcc_erratum();
+ _has_intel_jcc_erratum = r;
+ FLAG_SET_ERGO(IntelJccErratumMitigation, r);
} else {
_has_intel_jcc_erratum = IntelJccErratumMitigation;
}
```
Or, maybe purge the `VM_Version::_has_intel_jcc_erratum` completely, and replace it with `IntelJccErratumMitigation` checks.