35 #include "utilities/align.hpp" |
35 #include "utilities/align.hpp" |
36 #include "utilities/defaultStream.hpp" |
36 #include "utilities/defaultStream.hpp" |
37 #include "utilities/globalDefinitions.hpp" |
37 #include "utilities/globalDefinitions.hpp" |
38 #include "vm_version_ppc.hpp" |
38 #include "vm_version_ppc.hpp" |
39 |
39 |
40 # include <sys/sysinfo.h> |
40 #include <sys/sysinfo.h> |
|
41 |
|
42 #if defined(LINUX) && defined(VM_LITTLE_ENDIAN) |
|
43 #include <sys/auxv.h> |
|
44 |
|
45 #ifndef PPC_FEATURE2_HTM_NOSC |
|
46 #define PPC_FEATURE2_HTM_NOSC (1 << 24) |
|
47 #endif |
|
48 #endif |
41 |
49 |
42 bool VM_Version::_is_determine_features_test_running = false; |
50 bool VM_Version::_is_determine_features_test_running = false; |
43 uint64_t VM_Version::_dscr_val = 0; |
51 uint64_t VM_Version::_dscr_val = 0; |
44 |
52 |
45 #define MSG(flag) \ |
53 #define MSG(flag) \ |
121 #endif |
129 #endif |
122 |
130 |
123 // Create and print feature-string. |
131 // Create and print feature-string. |
124 char buf[(num_features+1) * 16]; // Max 16 chars per feature. |
132 char buf[(num_features+1) * 16]; // Max 16 chars per feature. |
125 jio_snprintf(buf, sizeof(buf), |
133 jio_snprintf(buf, sizeof(buf), |
126 "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", |
134 "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", |
127 (has_fsqrt() ? " fsqrt" : ""), |
135 (has_fsqrt() ? " fsqrt" : ""), |
128 (has_isel() ? " isel" : ""), |
136 (has_isel() ? " isel" : ""), |
129 (has_lxarxeh() ? " lxarxeh" : ""), |
137 (has_lxarxeh() ? " lxarxeh" : ""), |
130 (has_cmpb() ? " cmpb" : ""), |
138 (has_cmpb() ? " cmpb" : ""), |
131 //(has_mftgpr()? " mftgpr" : ""), |
139 //(has_mftgpr()? " mftgpr" : ""), |
134 (has_fcfids() ? " fcfids" : ""), |
142 (has_fcfids() ? " fcfids" : ""), |
135 (has_vand() ? " vand" : ""), |
143 (has_vand() ? " vand" : ""), |
136 (has_lqarx() ? " lqarx" : ""), |
144 (has_lqarx() ? " lqarx" : ""), |
137 (has_vcipher() ? " aes" : ""), |
145 (has_vcipher() ? " aes" : ""), |
138 (has_vpmsumb() ? " vpmsumb" : ""), |
146 (has_vpmsumb() ? " vpmsumb" : ""), |
139 (has_tcheck() ? " tcheck" : ""), |
|
140 (has_mfdscr() ? " mfdscr" : ""), |
147 (has_mfdscr() ? " mfdscr" : ""), |
141 (has_vsx() ? " vsx" : ""), |
148 (has_vsx() ? " vsx" : ""), |
142 (has_ldbrx() ? " ldbrx" : ""), |
149 (has_ldbrx() ? " ldbrx" : ""), |
143 (has_stdbrx() ? " stdbrx" : ""), |
150 (has_stdbrx() ? " stdbrx" : ""), |
144 (has_vshasig() ? " sha" : "") |
151 (has_vshasig() ? " sha" : "") |
302 } |
309 } |
303 |
310 |
304 |
311 |
305 // Adjust RTM (Restricted Transactional Memory) flags. |
312 // Adjust RTM (Restricted Transactional Memory) flags. |
306 if (UseRTMLocking) { |
313 if (UseRTMLocking) { |
307 // If CPU or OS are too old: |
314 // If CPU or OS do not support TM: |
308 // Can't continue because UseRTMLocking affects UseBiasedLocking flag |
315 // Can't continue because UseRTMLocking affects UseBiasedLocking flag |
309 // setting during arguments processing. See use_biased_locking(). |
316 // setting during arguments processing. See use_biased_locking(). |
310 // VM_Version_init() is executed after UseBiasedLocking is used |
317 // VM_Version_init() is executed after UseBiasedLocking is used |
311 // in Thread::allocate(). |
318 // in Thread::allocate(). |
312 if (!has_tcheck()) { |
319 if (PowerArchitecturePPC64 < 8) { |
313 vm_exit_during_initialization("RTM instructions are not available on this CPU"); |
320 vm_exit_during_initialization("RTM instructions are not available on this CPU."); |
314 } |
321 } |
315 bool os_too_old = true; |
322 bool os_support_tm = false; |
316 #ifdef AIX |
323 #ifdef AIX |
317 // Actually, this is supported since AIX 7.1.. Unfortunately, this first |
324 // Actually, this is supported since AIX 7.1.. Unfortunately, this first |
318 // contained bugs, so that it can only be enabled after AIX 7.1.3.30. |
325 // contained bugs, so that it can only be enabled after AIX 7.1.3.30. |
319 // The Java property os.version, which is used in RTM tests to decide |
326 // The Java property os.version, which is used in RTM tests to decide |
320 // whether the feature is available, only knows major and minor versions. |
327 // whether the feature is available, only knows major and minor versions. |
321 // We don't want to change this property, as user code might depend on it. |
328 // We don't want to change this property, as user code might depend on it. |
322 // So the tests can not check on subversion 3.30, and we only enable RTM |
329 // So the tests can not check on subversion 3.30, and we only enable RTM |
323 // with AIX 7.2. |
330 // with AIX 7.2. |
324 if (os::Aix::os_version() >= 0x07020000) { // At least AIX 7.2. |
331 if (os::Aix::os_version() >= 0x07020000) { // At least AIX 7.2. |
325 os_too_old = false; |
332 os_support_tm = true; |
326 } |
333 } |
327 #endif |
334 #endif |
328 #ifdef LINUX |
335 #if defined(LINUX) && defined(VM_LITTLE_ENDIAN) |
329 // At least Linux kernel 4.2, as the problematic behavior of syscalls |
336 unsigned long auxv = getauxval(AT_HWCAP2); |
330 // being called in the middle of a transaction has been addressed. |
337 |
331 // Please, refer to commit b4b56f9ecab40f3b4ef53e130c9f6663be491894 |
338 if (auxv & PPC_FEATURE2_HTM_NOSC) { |
332 // in Linux kernel source tree: https://goo.gl/Kc5i7A |
339 if (auxv & PPC_FEATURE2_HAS_HTM) { |
333 if (os::Linux::os_version_is_known()) { |
340 // TM on POWER8 and POWER9 in compat mode (VM) is supported by the JVM. |
334 if (os::Linux::os_version() >= 0x040200) |
341 // TM on POWER9 DD2.1 NV (baremetal) is not supported by the JVM (TM on |
335 os_too_old = false; |
342 // POWER9 DD2.1 NV has a few issues that need a couple of firmware |
336 } else { |
343 // and kernel workarounds, so there is a new mode only supported |
337 vm_exit_during_initialization("RTM can not be enabled: kernel version is unknown."); |
344 // on non-virtualized P9 machines called HTM with no Suspend Mode). |
|
345 // TM on POWER9 D2.2+ NV is not supported at all by Linux. |
|
346 os_support_tm = true; |
|
347 } |
338 } |
348 } |
339 #endif |
349 #endif |
340 if (os_too_old) { |
350 if (!os_support_tm) { |
341 vm_exit_during_initialization("RTM is not supported on this OS version."); |
351 vm_exit_during_initialization("RTM is not supported on this OS version."); |
342 } |
352 } |
343 } |
353 } |
344 |
354 |
345 if (UseRTMLocking) { |
355 if (UseRTMLocking) { |
678 a->vand(VR0, VR0, VR0); // code[8] -> vand |
688 a->vand(VR0, VR0, VR0); // code[8] -> vand |
679 // arg0 of lqarx must be an even register, (arg1 + arg2) must be a multiple of 16 |
689 // arg0 of lqarx must be an even register, (arg1 + arg2) must be a multiple of 16 |
680 a->lqarx_unchecked(R6, R3_ARG1, R4_ARG2, 1); // code[9] -> lqarx_m |
690 a->lqarx_unchecked(R6, R3_ARG1, R4_ARG2, 1); // code[9] -> lqarx_m |
681 a->vcipher(VR0, VR1, VR2); // code[10] -> vcipher |
691 a->vcipher(VR0, VR1, VR2); // code[10] -> vcipher |
682 a->vpmsumb(VR0, VR1, VR2); // code[11] -> vpmsumb |
692 a->vpmsumb(VR0, VR1, VR2); // code[11] -> vpmsumb |
683 a->tcheck(0); // code[12] -> tcheck |
693 a->mfdscr(R0); // code[12] -> mfdscr |
684 a->mfdscr(R0); // code[13] -> mfdscr |
694 a->lxvd2x(VSR0, R3_ARG1); // code[13] -> vsx |
685 a->lxvd2x(VSR0, R3_ARG1); // code[14] -> vsx |
695 a->ldbrx(R7, R3_ARG1, R4_ARG2); // code[14] -> ldbrx |
686 a->ldbrx(R7, R3_ARG1, R4_ARG2); // code[15] -> ldbrx |
696 a->stdbrx(R7, R3_ARG1, R4_ARG2); // code[15] -> stdbrx |
687 a->stdbrx(R7, R3_ARG1, R4_ARG2); // code[16] -> stdbrx |
697 a->vshasigmaw(VR0, VR1, 1, 0xF); // code[16] -> vshasig |
688 a->vshasigmaw(VR0, VR1, 1, 0xF); // code[17] -> vshasig |
|
689 a->blr(); |
698 a->blr(); |
690 |
699 |
691 // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it. |
700 // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it. |
692 void (*zero_cacheline_func_ptr)(char*) = (void(*)(char*))(void *)a->function_entry(); |
701 void (*zero_cacheline_func_ptr)(char*) = (void(*)(char*))(void *)a->function_entry(); |
693 a->dcbz(R3_ARG1); // R3_ARG1 = addr |
702 a->dcbz(R3_ARG1); // R3_ARG1 = addr |
730 if (code[feature_cntr++]) features |= fcfids_m; |
739 if (code[feature_cntr++]) features |= fcfids_m; |
731 if (code[feature_cntr++]) features |= vand_m; |
740 if (code[feature_cntr++]) features |= vand_m; |
732 if (code[feature_cntr++]) features |= lqarx_m; |
741 if (code[feature_cntr++]) features |= lqarx_m; |
733 if (code[feature_cntr++]) features |= vcipher_m; |
742 if (code[feature_cntr++]) features |= vcipher_m; |
734 if (code[feature_cntr++]) features |= vpmsumb_m; |
743 if (code[feature_cntr++]) features |= vpmsumb_m; |
735 if (code[feature_cntr++]) features |= tcheck_m; |
|
736 if (code[feature_cntr++]) features |= mfdscr_m; |
744 if (code[feature_cntr++]) features |= mfdscr_m; |
737 if (code[feature_cntr++]) features |= vsx_m; |
745 if (code[feature_cntr++]) features |= vsx_m; |
738 if (code[feature_cntr++]) features |= ldbrx_m; |
746 if (code[feature_cntr++]) features |= ldbrx_m; |
739 if (code[feature_cntr++]) features |= stdbrx_m; |
747 if (code[feature_cntr++]) features |= stdbrx_m; |
740 if (code[feature_cntr++]) features |= vshasig_m; |
748 if (code[feature_cntr++]) features |= vshasig_m; |