-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8329031: CPUID feature detection for Advanced Performance Extensions (Intel® APX) #18562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b38266c
de7d8cb
ad39d99
e98b5c6
93adcc2
3284fd9
24baa30
97d6538
0881e43
b5da093
68df08c
d8fcde9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ address VM_Version::_cpuinfo_segv_addr_apx = 0; | |
| // Address of instruction after the one which causes APX specific SEGV | ||
| address VM_Version::_cpuinfo_cont_addr_apx = 0; | ||
| // Address of apx state restore error handler. | ||
| address VM_Version::_apx_state_restore_error_handler = (address)VM_Version::report_apx_state_restore_error; | ||
| address VM_Version::_apx_state_restore_warning_handler = (address)VM_Version::report_apx_state_restore_warning; | ||
|
|
||
| static BufferBlob* stub_blob; | ||
| static const int stub_size = 2000; | ||
|
|
@@ -113,11 +113,16 @@ class VM_Version_StubGenerator: public StubCodeGenerator { | |
| address clear_apx_test_state() { | ||
| # define __ _masm-> | ||
| address start = __ pc(); | ||
| //__ mov64(r15, 0L); | ||
| // FIXME Uncomment following code after OS enablement of | ||
| /* FIXME Uncomment following code after OS enablement of | ||
| bool save_apx = UseAPX; | ||
| VM_Version::set_apx_cpuFeatures(); | ||
| UseAPX = true; | ||
| // EGPR state save/restoration. | ||
| //__ mov64(r16, 0L); | ||
| //__ mov64(r31, 0L); | ||
| __ mov64(r16, 0L); | ||
| __ mov64(r31, 0L); | ||
| UseAPX = save_apx; | ||
| VM_Version::clean_cpuFeatures(); | ||
| */ | ||
| __ ret(0); | ||
| return start; | ||
| } | ||
|
|
@@ -134,7 +139,7 @@ class VM_Version_StubGenerator: public StubCodeGenerator { | |
|
|
||
| Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4; | ||
| Label sef_cpuid, sefsl1_cpuid, ext_cpuid, ext_cpuid1, ext_cpuid5, ext_cpuid7; | ||
| Label ext_cpuid8, done, wrapup, vector_save_restore, apx_save_restore_error; | ||
| Label ext_cpuid8, done, wrapup, vector_save_restore, apx_save_restore_warning; | ||
| Label legacy_setup, save_restore_except, legacy_save_restore, start_simd_check; | ||
|
|
||
| StubCodeMark mark(this, "VM_Version", "get_cpu_info_stub"); | ||
|
|
@@ -430,8 +435,10 @@ class VM_Version_StubGenerator: public StubCodeGenerator { | |
| __ cmpl(rax, 0x80000); | ||
| __ jcc(Assembler::notEqual, vector_save_restore); | ||
|
|
||
| /* FIXME: Uncomment after integration of JDK-8328998 | ||
| __ mov64(r15, VM_Version::egpr_test_value()); | ||
| /* FIXME: Uncomment while integrating JDK-8329032 | ||
| bool save_apx = UseAPX; | ||
|
Comment on lines
+440
to
+441
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are you missing to uncomment this code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we already have that in place with #19042, which will be open for review after this patch. I added it in comments since this piece of logic is centered around CPUID feature check and pertinent to this patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. |
||
| VM_Version::set_apx_cpuFeatures(); | ||
| UseAPX = true; | ||
| __ mov64(r16, VM_Version::egpr_test_value()); | ||
jatin-bhateja marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| __ mov64(r31, VM_Version::egpr_test_value()); | ||
| */ | ||
|
|
@@ -441,19 +448,18 @@ class VM_Version_StubGenerator: public StubCodeGenerator { | |
| __ movl(rax, Address(rsi, 0)); | ||
|
|
||
| VM_Version::set_cpuinfo_cont_addr_apx(__ pc()); | ||
| // Validate the contents of r15, r16 and r31 | ||
| /* FIXME: Uncomment after integration of JDK-8328998 | ||
| // Validate the contents of r16 and r31 | ||
| /* FIXME: Uncomment after integration of JDK-8329032 | ||
| __ mov64(rax, VM_Version::egpr_test_value()); | ||
| __ cmpq(rax, r15); | ||
| __ jccb(Assembler::notEqual, apx_save_restore_error); | ||
| __ cmpq(rax, r16); | ||
| __ jccb(Assembler::notEqual, apx_save_restore_error); | ||
| __ jccb(Assembler::notEqual, apx_save_restore_warning); | ||
| __ cmpq(rax, r31); | ||
| __ jccb(Assembler::equal, vector_save_restore); | ||
|
|
||
| // Generate SEGV to signal unsuccessful save/restore. | ||
| __ bind(apx_save_restore_error); | ||
| __ lea(rax, ExternalAddress(VM_Version::_apx_state_restore_error_handler)); | ||
| UseAPX = save_apx; | ||
|
|
||
| __ bind(apx_save_restore_warning); | ||
| __ lea(rax, ExternalAddress(VM_Version::_apx_state_restore_warning_handler)); | ||
| __ call(rax); | ||
| */ | ||
| #endif | ||
|
|
@@ -868,6 +874,11 @@ class VM_Version_StubGenerator: public StubCodeGenerator { | |
| }; | ||
| }; | ||
|
|
||
| void VM_Version::report_apx_state_restore_warning() { | ||
| tty->print("warning: Unsuccessful EGPRs state restoration across signal handling, setting UseAPX to false.\n"); | ||
|
||
| _cpuid_info.sefsl1_cpuid7_edx.bits.apx_f = 0; | ||
| } | ||
|
|
||
| void VM_Version::get_processor_features() { | ||
|
|
||
| _cpu = 4; // 486 by default | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to clear_apx_test_state? r16 onwards are not callee saved. And checking r15 save/restore is not needed so we could remove r15 changes altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, EGPRs are call clobbered registers, but here we are trying to ascertain if their values are preserved across signal handling. Explicit clearing of r16 and r31 during signal handling guarantees that preserved register values post signal handling were re-instantiated by operating system and not because they were not modified externally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add comment about that.