Skip to content

Commit 272ec41

Browse files
Steinar H. Gundersonchromeos-ci-prod
authored andcommitted
Turn off AVX2 lazy parsing if there is no PCLMUL.
Seemingly there are some obscure Chinese x86 CPUs that support AVX2 and not PCLMUL, even though the former came out years after the latter. Our AVX2 path had assumed (128-bit) PCLMUL was available and would crash on such CPUs. Thus, check for the correct CPUID flag (which we add support for) and go back to the SSE2 path if so. Fixed: 413722108 Change-Id: If4af8b408d380ada41d058e6af5bf57adbf1ad2b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6494806 Commit-Queue: Steinar H Gunderson <[email protected]> Reviewed-by: Nico Weber <[email protected]> Reviewed-by: Anders Hartvoll Ruud <[email protected]> Cr-Commit-Position: refs/heads/main@{#1458810} CrOS-Libchrome-Original-Commit: abf09a01b4ceaf11d2d4d27d078e0ede589eb627
1 parent da42832 commit 272ec41

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

base/cpu.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ void CPU::Initialize() {
235235
}
236236

237237
has_pku_ = (cpu_info7[2] & 0x00000010) != 0;
238+
has_pclmul_ = (cpu_info[2] & 0x00000002) != 0;
238239
}
239240

240241
// Get the brand string of the cpu.

base/cpu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ class BASE_EXPORT CPU final {
9494
bool has_avx512_f() const { return has_avx512_f_; }
9595
bool has_avx512_bw() const { return has_avx512_bw_; }
9696
bool has_avx512_vnni() const { return has_avx512_vnni_; }
97+
// NOTE: This does not include 256-bit PCLMUL, which is
98+
// a separate feature flag.
99+
bool has_pclmul() const { return has_pclmul_; }
97100
#endif
98101
bool has_aesni() const { return has_aesni_; }
99102
bool has_non_stop_time_stamp_counter() const {
@@ -149,6 +152,7 @@ class BASE_EXPORT CPU final {
149152
bool has_avx512_f_ = false;
150153
bool has_avx512_bw_ = false;
151154
bool has_avx512_vnni_ = false;
155+
bool has_pclmul_ = false;
152156
#endif
153157
bool has_aesni_ = false;
154158
#if defined(ARCH_CPU_ARM_FAMILY)

0 commit comments

Comments
 (0)