RFR(S): x86: 8190494: fix for different results with UseAVX=3 when calling AVX-512 native function via JNI.

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Fri Dec 1 19:47:38 UTC 2017


Thanks for the clarifications, Vivek!

The fix looks good as it is.

I missed that PostLoopMultiversioning is broken.

I’m still concerned JVM doesn’t fully comply with system ABI and system libraries JVM relies on (which are out of our control, e.g., libc) can internally utilize AVX-512 thus breaking the JVM.

But I consider that more of a theoretical possibility at the moment and I’m fine with addressing that later.

Best regards,
Vladimir Ivanov

> On 1 Dec 2017, at 22:02, Deshpande, Vivek R <vivek.r.deshpande at intel.com> wrote:
> 
> Hi Vladimir
> 
> Our understanding is that the fix is correct, works in all circumstances with the JVM/JIT code as checked in, and is the least disruptive fix.  
> Only the JNI has potential to kill K1. No other call into the JVM can modify K1 as the JVM is compiled for SSE2 being the base for 64 bit.
> The stubs/intrinsics that use mask register all make sure that K1 is restored properly.
> PostLoopMultiversioning has major issues and is turned off per https://bugs.openjdk.java.net/browse/JDK-8183390. 
> 
> Regards,
> Vivek
> 
> -----Original Message-----
> From: Vladimir Ivanov [mailto:vladimir.x.ivanov at oracle.com] 
> Sent: Friday, December 01, 2017 3:51 AM
> To: Deshpande, Vivek R <vivek.r.deshpande at intel.com>; hotspot-compiler-dev at openjdk.java.net
> Subject: Re: RFR(S): x86: 8190494: fix for different results with UseAVX=3 when calling AVX-512 native function via JNI.
> 
>> Thanks for testing the patch.
>> To be on the safe side,  I am preserving the rcx register and don't want to introduce any new bugs.
> 
> Thinking more about this, I came to the conclusion that I don't fully understand what is the motivation to add the code in MA::restore_cpu_control_state_after_jni().
> 
> If there are other instructions left which are affected by the same encoding problem, resetting k1 after JNI call is not sufficient to hide the problem (e.g., any call into the JVM can potentially use k1).
> 
> Moreover, C2 w/ PostLoopMultiversioning (turned off by default) produces post loops with k1 usage, but doesn't reset it.
> 
> So, it seems it doesn't fix anything, but makes hitting similar bug less likely.
> 
> Best regards,
> Vladimir Ivanov
> 
>> -----Original Message-----
>> From: Vladimir Ivanov [mailto:vladimir.x.ivanov at oracle.com]
>> Sent: Thursday, November 30, 2017 1:29 PM
>> To: Deshpande, Vivek R <vivek.r.deshpande at intel.com>; 
>> hotspot-compiler-dev at openjdk.java.net
>> Subject: Re: RFR(S): x86: 8190494: fix for different results with UseAVX=3 when calling AVX-512 native function via JNI.
>> 
>>> http://cr.openjdk.java.net/~vdeshpande/8190494/webrev.00/
>> 
>> Thanks, Vivek. I verified that the reported problem goes away with the fix.
>> 
>> src/hotspot/cpu/x86/macroAssembler_x86.cpp
>> 
>> +  // Reset k1 to 0xffff.
>> +  if (VM_Version::supports_evex()) {
>> +    push(rcx);
>> +    movl(rcx, 0xffff);
>> +    kmovwl(k1, rcx);
>> +    pop(rcx);
>> +  }
>> 
>> Why do you preserve rcx which is already caller-saved and shouldn't contain anything valuable after a JNI call?
>> 
>> Best regards,
>> Vladimir Ivanov
>> 



More information about the hotspot-compiler-dev mailing list