Skip to content

Commit 3d4e049

Browse files
author
Srinivas Vamsi Parasa
committed
8367780: Enable UseAPX on Intel CPUs only when both APX_F and APX_NCI_NDD_NF cpuid features are present
Reviewed-by: sviswanathan, vpaprotski
1 parent bca1e6e commit 3d4e049

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/hotspot/cpu/x86/vm_version_x86.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
139139
const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT);
140140
bool use_evex = FLAG_IS_DEFAULT(UseAVX) || (UseAVX > 2);
141141

142-
Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4, std_cpuid24;
142+
Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4, std_cpuid24, std_cpuid29;
143143
Label sef_cpuid, sefsl1_cpuid, ext_cpuid, ext_cpuid1, ext_cpuid5, ext_cpuid7;
144144
Label ext_cpuid8, done, wrapup, vector_save_restore, apx_save_restore_warning;
145145
Label legacy_setup, save_restore_except, legacy_save_restore, start_simd_check;
@@ -338,6 +338,16 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
338338
__ movl(Address(rsi, 0), rax);
339339
__ movl(Address(rsi, 4), rdx);
340340

341+
//
342+
// cpuid(0x29) APX NCI NDD NF (EAX = 29H, ECX = 0).
343+
//
344+
__ bind(std_cpuid29);
345+
__ movl(rax, 0x29);
346+
__ movl(rcx, 0);
347+
__ cpuid();
348+
__ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid29_offset())));
349+
__ movl(Address(rsi, 0), rbx);
350+
341351
//
342352
// cpuid(0x24) Converged Vector ISA Main Leaf (EAX = 24H, ECX = 0).
343353
//
@@ -2914,7 +2924,8 @@ VM_Version::VM_Features VM_Version::CpuidInfo::feature_flags() const {
29142924
if (std_cpuid1_ecx.bits.popcnt != 0)
29152925
vm_features.set_feature(CPU_POPCNT);
29162926
if (sefsl1_cpuid7_edx.bits.apx_f != 0 &&
2917-
xem_xcr0_eax.bits.apx_f != 0) {
2927+
xem_xcr0_eax.bits.apx_f != 0 &&
2928+
std_cpuid29_ebx.bits.apx_nci_ndd_nf != 0) {
29182929
vm_features.set_feature(CPU_APX_F);
29192930
}
29202931
if (std_cpuid1_ecx.bits.avx != 0 &&

src/hotspot/cpu/x86/vm_version_x86.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ class VM_Version : public Abstract_VM_Version {
306306
} bits;
307307
};
308308

309+
union StdCpuidEax29Ecx0 {
310+
uint32_t value;
311+
struct {
312+
uint32_t apx_nci_ndd_nf : 1,
313+
: 31;
314+
} bits;
315+
};
316+
309317
union StdCpuid24MainLeafEax {
310318
uint32_t value;
311319
struct {
@@ -591,6 +599,10 @@ class VM_Version : public Abstract_VM_Version {
591599
StdCpuid24MainLeafEax std_cpuid24_eax;
592600
StdCpuid24MainLeafEbx std_cpuid24_ebx;
593601

602+
// cpuid function 0x29 APX Advanced Performance Extensions Leaf
603+
// eax = 0x29, ecx = 0
604+
StdCpuidEax29Ecx0 std_cpuid29_ebx;
605+
594606
// cpuid function 0xB (processor topology)
595607
// ecx = 0
596608
uint32_t tpl_cpuidB0_eax;
@@ -711,6 +723,7 @@ class VM_Version : public Abstract_VM_Version {
711723
static ByteSize std_cpuid0_offset() { return byte_offset_of(CpuidInfo, std_max_function); }
712724
static ByteSize std_cpuid1_offset() { return byte_offset_of(CpuidInfo, std_cpuid1_eax); }
713725
static ByteSize std_cpuid24_offset() { return byte_offset_of(CpuidInfo, std_cpuid24_eax); }
726+
static ByteSize std_cpuid29_offset() { return byte_offset_of(CpuidInfo, std_cpuid29_ebx); }
714727
static ByteSize dcp_cpuid4_offset() { return byte_offset_of(CpuidInfo, dcp_cpuid4_eax); }
715728
static ByteSize sef_cpuid7_offset() { return byte_offset_of(CpuidInfo, sef_cpuid7_eax); }
716729
static ByteSize sefsl1_cpuid7_offset() { return byte_offset_of(CpuidInfo, sefsl1_cpuid7_eax); }
@@ -760,7 +773,9 @@ class VM_Version : public Abstract_VM_Version {
760773
_features.set_feature(CPU_SSE2);
761774
_features.set_feature(CPU_VZEROUPPER);
762775
}
763-
static void set_apx_cpuFeatures() { _features.set_feature(CPU_APX_F); }
776+
static void set_apx_cpuFeatures() {
777+
_features.set_feature(CPU_APX_F);
778+
}
764779
static void set_bmi_cpuFeatures() {
765780
_features.set_feature(CPU_BMI1);
766781
_features.set_feature(CPU_BMI2);

0 commit comments

Comments
 (0)