Skip to content

Zend: clear the AVX bit in ECX when the OS has not enabled AVX state - #23966

Closed
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/aph-zend-avx-feature-mask-m9xa-84-work
Closed

iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/aph-zend-avx-feature-mask-m9xa-84-work

Conversation

@iliaal

@iliaal iliaal commented Sep 28, 2026

Copy link
Copy Markdown
Member

zend_cpu_startup() cleared the AVX bit from EDX, where bit 28 is HTT, instead of ECX, so AVX stayed reported when XCR0 has AVX state disabled. Builds without __builtin_cpu_supports(), such as MSVC, then let the JIT emit VEX-encoded instructions that fault on such hosts. The mask dates from 4e30ab3. There is no test, since it needs a host with AVX state disabled in XCR0.

zend_cpu_startup() masked ZEND_CPU_FEATURE_AVX out of EDX when XCR0 lacks
the SSE or AVX state bits, but AVX is CPUID.1:ECX bit 28 and EDX bit 28 is
HTT. zend_cpu_supports(ZEND_CPU_FEATURE_AVX) kept reporting AVX, so builds
without __builtin_cpu_supports(), such as MSVC, let the JIT emit VEX-encoded
instructions that fault on such hosts.

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow this is surprising.
Good find

@iliaal iliaal closed this in eb32f52 Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants