summaryrefslogtreecommitdiff
path: root/Zend/zend_cpuinfo.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-03 10:24:48 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-01-03 10:24:48 +0100
commit5a361c3a54c055cdf7088e76aa8efa159334e096 (patch)
tree4ffd59487475ce12ecfcafea1e15ce8ed6515afe /Zend/zend_cpuinfo.c
parent349dbb7938148226635ab8a59ca13bca75b255f9 (diff)
downloadphp-git-5a361c3a54c055cdf7088e76aa8efa159334e096.tar.gz
Possible fix for bug #77357
Don't invoke CPUID with feature levels above the supported maximum. In this case CPUID will return the highest supported basic information leaf, which will have unrelated bits in the relevant positions.
Diffstat (limited to 'Zend/zend_cpuinfo.c')
-rw-r--r--Zend/zend_cpuinfo.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Zend/zend_cpuinfo.c b/Zend/zend_cpuinfo.c
index ea1f08f948..4cbd2ac776 100644
--- a/Zend/zend_cpuinfo.c
+++ b/Zend/zend_cpuinfo.c
@@ -77,16 +77,24 @@ void zend_cpu_startup(void)
{
if (!cpuinfo.initialized) {
zend_cpu_info ebx;
+ int max_feature;
cpuinfo.initialized = 1;
__zend_cpuid(0, 0, &cpuinfo);
- if (cpuinfo.eax == 0) {
+ max_feature = cpuinfo.eax;
+ if (max_feature == 0) {
return;
}
+
__zend_cpuid(1, 0, &cpuinfo);
+
/* for avx2 */
- __zend_cpuid(7, 0, &ebx);
- cpuinfo.ebx = ebx.ebx;
+ if (max_feature >= 7) {
+ __zend_cpuid(7, 0, &ebx);
+ cpuinfo.ebx = ebx.ebx;
+ } else {
+ cpuinfo.ebx = 0;
+ }
}
}