]> granicus.if.org Git - libjpeg-turbo/commitdiff
SIMD: Fix c000001d exception on Win 7 w/o SP1
authorDRC <information@libjpeg-turbo.org>
Fri, 28 Sep 2018 20:46:35 +0000 (15:46 -0500)
committerDRC <information@libjpeg-turbo.org>
Fri, 28 Sep 2018 21:23:14 +0000 (16:23 -0500)
Apparently Windows 7 without SP1 has O/S support for XSAVE but not for
YMM registers, and this exposed a bug in our usage of xgetbv.  The test
instruction will set ZF only if none of the bits match between the two
operarands, so in effect, we were enabling AVX2 instructions if the O/S
supported XSAVE and the CPU supported AVX2 but the O/S only supported
XMM registers.  This bug was not exposed on, for instance, Windows XP or
RHEL 5 because those O/S's do not support XSAVE.

Fixes #288

ChangeLog.md
simd/i386/jsimdcpu.asm
simd/x86_64/jsimdcpu.asm

index 3d998018b0c2ad1ec16bd187b140f67907293edc..47c730b93e92cdb2aae82aacd19d6509bec061bb 100644 (file)
@@ -14,6 +14,9 @@ functions in the MIPS DSPr2 SIMD extensions are now disabled at compile time
 if the soft float ABI is enabled.  Those functions use instructions that are
 incompatible with the soft float ABI.
 
+3. Fixed an issue in the SIMD feature detection code that caused libjpeg-turbo
+to crash on Windows 7 if Service Pack 1 was not installed.
+
 
 2.0.0
 =====
index 50a0d516e3461dd2a87a6f23bf3b7227fefca951..faddd389fdf2ab6baedd380d527a2a7773ccacf3 100644 (file)
@@ -94,9 +94,10 @@ EXTN(jpeg_simd_cpu_support):
 
     xor         ecx, ecx
     xgetbv
-    test        eax, 6                  ; O/S does not manage XMM/YMM state
+    and         eax, 6
+    cmp         eax, 6                  ; O/S does not manage XMM/YMM state
                                         ; using XSAVE
-    j         short .no_avx2
+    jnz         short .no_avx2
 
     or          edi, JSIMD_AVX2
 .no_avx2:
index 42979bef2bbe313759839bfd7385c95ab08f1269..38e1a7b99088e5b6014b3a8dd415b7ba73769a86 100644 (file)
@@ -60,9 +60,10 @@ EXTN(jpeg_simd_cpu_support):
 
     xor         rcx, rcx
     xgetbv
-    test        rax, 6                  ; O/S does not manage XMM/YMM state
+    and         rax, 6
+    cmp         rax, 6                  ; O/S does not manage XMM/YMM state
                                         ; using XSAVE
-    j         short .return
+    jnz         short .return
 
     or          rdi, JSIMD_AVX2