Bug 1520760 - Fix AVX2 detection to ensure we have all required CPU parameters. r=jrmuizel
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 18 Jan 2019 12:04:21 -0500
changeset 454752 1e76cea31571ed9274acd577b515e2c928cd207b
parent 454751 305c7ed630542b9610b80608311313ad6e96172f
child 454753 fe7e9442e6cc503ad0fa385a1c380e3b3a23b147
push id35412
push usercsabou@mozilla.com
push dateTue, 22 Jan 2019 03:56:27 +0000
treeherdermozilla-central@956bd26eec5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1520760
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1520760 - Fix AVX2 detection to ensure we have all required CPU parameters. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D16994
media/libjpeg/1520760-avx2-detection.diff
media/libjpeg/simd/i386/jsimdcpu.asm
media/libjpeg/simd/x86_64/jsimdcpu.asm
media/update-libjpeg.sh
new file mode 100644
--- /dev/null
+++ b/media/libjpeg/1520760-avx2-detection.diff
@@ -0,0 +1,32 @@
+Bug 1520760 - Fix AVX2 detection to ensure we have all required CPU parameters.
+
+diff --git simd/i386/jsimdcpu.asm simd/i386/jsimdcpu.asm
+--- simd/i386/jsimdcpu.asm
++++ simd/i386/jsimdcpu.asm
+@@ -87,8 +87,10 @@ EXTN(jpeg_simd_cpu_support):
+     mov         eax, 1
+     xor         ecx, ecx
+     cpuid
+-    test        ecx, 1<<27
++    test        ecx, 1<<26
+     jz          short .no_avx2          ; O/S does not support XSAVE
++    test        ecx, 1<<27
++    jz          short .no_avx2          ; O/S does not support OSXSAVE
+     test        ecx, 1<<28
+     jz          short .no_avx2          ; CPU does not support AVX2
+ 
+diff --git simd/x86_64/jsimdcpu.asm simd/x86_64/jsimdcpu.asm
+--- simd/x86_64/jsimdcpu.asm
++++ simd/x86_64/jsimdcpu.asm
+@@ -53,8 +53,10 @@ EXTN(jpeg_simd_cpu_support):
+     mov         rax, 1
+     xor         rcx, rcx
+     cpuid
+-    test        rcx, 1<<27
++    test        rcx, 1<<26
+     jz          short .return           ; O/S does not support XSAVE
++    test        rcx, 1<<27
++    jz          short .return           ; O/S does not support OSXSAVE
+     test        rcx, 1<<28
+     jz          short .return           ; CPU does not support AVX2
+ 
--- a/media/libjpeg/simd/i386/jsimdcpu.asm
+++ b/media/libjpeg/simd/i386/jsimdcpu.asm
@@ -82,18 +82,20 @@ EXTN(jpeg_simd_cpu_support):
     mov         eax, ebx
     test        eax, 1<<5               ; bit5:AVX2
     jz          short .no_avx2
 
     ; Check for AVX2 O/S support
     mov         eax, 1
     xor         ecx, ecx
     cpuid
+    test        ecx, 1<<26
+    jz          short .no_avx2          ; O/S does not support XSAVE
     test        ecx, 1<<27
-    jz          short .no_avx2          ; O/S does not support XSAVE
+    jz          short .no_avx2          ; O/S does not support OSXSAVE
     test        ecx, 1<<28
     jz          short .no_avx2          ; CPU does not support AVX2
 
     xor         ecx, ecx
     xgetbv
     and         eax, 6
     cmp         eax, 6                  ; O/S does not manage XMM/YMM state
                                         ; using XSAVE
--- a/media/libjpeg/simd/x86_64/jsimdcpu.asm
+++ b/media/libjpeg/simd/x86_64/jsimdcpu.asm
@@ -48,18 +48,20 @@ EXTN(jpeg_simd_cpu_support):
     or          rdi, JSIMD_SSE
     test        rax, 1<<5               ; bit5:AVX2
     jz          short .return
 
     ; Check for AVX2 O/S support
     mov         rax, 1
     xor         rcx, rcx
     cpuid
+    test        rcx, 1<<26
+    jz          short .return           ; O/S does not support XSAVE
     test        rcx, 1<<27
-    jz          short .return           ; O/S does not support XSAVE
+    jz          short .return           ; O/S does not support OSXSAVE
     test        rcx, 1<<28
     jz          short .return           ; CPU does not support AVX2
 
     xor         rcx, rcx
     xgetbv
     and         rax, 6
     cmp         rax, 6                  ; O/S does not manage XMM/YMM state
                                         ; using XSAVE
--- a/media/update-libjpeg.sh
+++ b/media/update-libjpeg.sh
@@ -14,19 +14,20 @@ rm -rf $srcdir/libjpeg
 repo=$1
 tag=${2-HEAD}
 
 (cd $repo; git archive --prefix=media/libjpeg/ $tag) | (cd $srcdir/..; tar xf -)
 
 cd $srcdir/libjpeg
 cp win/jsimdcfg.inc simd/
 
-revert_files="1050342.diff assembly-tables.diff externalize-table.diff jconfig.h jconfigint.h jpeg_nbits_table.c moz.build MOZCHANGES mozilla.diff simd/jsimdcfg.inc"
+revert_files="1050342.diff assembly-tables.diff externalize-table.diff 1520760-avx2-detection.diff jconfig.h jconfigint.h jpeg_nbits_table.c moz.build MOZCHANGES mozilla.diff simd/jsimdcfg.inc"
 if test -d ${topsrcdir}/.hg; then
     hg revert --no-backup $revert_files
 elif test -d ${topsrcdir}/.git; then
     git checkout HEAD -- $revert_files
 fi
 
 patch -p0 -i mozilla.diff
 patch -p0 -i 1050342.diff
 patch -p3 -i externalize-table.diff
 patch -p3 -i assembly-tables.diff
+patch -p0 -i 1520760-avx2-detection.diff