Details
-
Bug
-
Resolution: Fixed
-
P3
-
8, 11, 17, 18, 19
-
b08
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8284253 | 18.0.2 | Tobias Hartmann | P3 | Resolved | Fixed | b02 |
JDK-8283823 | 17.0.4-oracle | Tobias Hartmann | P3 | Resolved | Fixed | b01 |
JDK-8284078 | 17.0.4 | Martin Doerr | P3 | Resolved | Fixed | b01 |
JDK-8284139 | 11.0.16-oracle | Tobias Hartmann | P3 | Resolved | Fixed | b02 |
JDK-8284348 | 11.0.16 | Goetz Lindenmaier | P3 | Resolved | Fixed | b01 |
Description
If you look at our current CPU feature handling here:
https://github.com/openjdk/jdk/blob/c2ee1b33c37e6f2848dc8b3e5417b93b1dac1112/src/hotspot/cpu/x86/vm_version_x86.hpp#L145-L158
union ExtCpuid1Ecx {
uint32_t value;
struct {
uint32_t LahfSahf : 1, // bit 0
CmpLegacy : 1, // bit 1
: 3, // bits 2..4
lzcnt_intel : 1, // bit 5
lzcnt : 1, // bit 6
sse4a : 1, // bit 7
misalignsse : 1, // bit 8
prefetchw : 1, // bit 9
: 22;
} bits;
};
And compare it with Intel SDM and AMD APM, then you'll notice a discrepancy in bit positions.
AMD APM V3 says (https://www.amd.com/system/files/TechDocs/40332.pdf, "Obtaining Processor Information Via the CPUID Instruction", page 610):
Bit 0: LahfSahf LAHF and SAHF instruction support in 64-bit mode.
Bit 1: CmpLegacy Core multi-processing legacy mode.
Bit 2: SVM Secure virtual machine.
Bit 3: ExtApicSpace
Bit 4: AltMovCr8 LOCK MOV CR0 means MOV CR8.
Bit 5: ABM Advanced bit manipulation. LZCNT instruction support.
Bit 6: SSE4A
Bit 7: MisAlignSse
Bit 8: 3DNowPrefetch
Bit 9: OSVW OS visible workaround.
So CPUID returns {LZCNT, SSE4A, MisAlignSse, 3DNowPrefetch} in bits 5..8. Hotspot's code, however, reads {lzcnt, sse4a, misalignsse, prefetchw} from bits 6..9!
Intel SDM 2A says (https://cdrdv2.intel.com/v1/dl/getContent/671199, "CPUID—CPU Identification", page 3-233):
Bit 00: LAHF/SAHF available in 64-bit mode
Bits 04-01 Reserved
Bit 05: LZCNT
Bits 07-06 Reserved
Bit 08: PREFETCHW
Bits 31-09 Reserved
It matches the current structure well, except for prefetchw oddity (CPUID sets bit 8, Hotspot reads bit 9 "misalignsse") that is handled separately:
// Intel features.
if (is_intel()) {
...
// for Intel, ecx.bits.misalignsse bit (bit 8) indicates support for prefetchw
if (_cpuid_info.ext_cpuid1_ecx.bits.misalignsse != 0) {
result |= CPU_3DNOW_PREFETCH;
}
...
}
I believe this went unnoticed, because all adjacent bits 6..9 are set on modern AMD CPUs.
Attachments
Issue Links
- backported by
-
JDK-8283823 Cpuid1Ecx feature parsing is incorrect for AMD CPUs
- Resolved
-
JDK-8284078 Cpuid1Ecx feature parsing is incorrect for AMD CPUs
- Resolved
-
JDK-8284139 Cpuid1Ecx feature parsing is incorrect for AMD CPUs
- Resolved
-
JDK-8284253 Cpuid1Ecx feature parsing is incorrect for AMD CPUs
- Resolved
-
JDK-8284348 Cpuid1Ecx feature parsing is incorrect for AMD CPUs
- Resolved
- links to
-
Commit openjdk/jdk11u-dev/7f8a11b3
-
Commit openjdk/jdk17u-dev/e2f6bb8c
-
Commit openjdk/jdk18u/26356150
-
Commit openjdk/jdk/a18beb47
-
Review openjdk/jdk11u-dev/989
-
Review openjdk/jdk17u-dev/295
-
Review openjdk/jdk18u/70
-
Review openjdk/jdk/7287