elasticsearch/libs
Lorenzo Dematté 115062c643
Fix vec_caps to test for OS support too (on x64) (#126911)
On x64, we are testing if we support vector capabilities (1 = "basic" = AVX2, 2 = "advanced" = AVX-512) in order to enable and choose a native implementation for some vector functions, using CPUID.

However, under some circumstances, this is not sufficient: the OS on which we are running also needs to support AVX/AVX2 etc; basically, it needs to acknowledge it knows about the additional register and that it is able to handle them e.g. in context switches. To do that we need to a) test if the CPU has xsave feature and b) use the xgetbv to test if the OS set it (declaring it supports AVX/AVX2/etc).

In most cases this is not needed, as all modern OSes do that, but for some virtualized situations (hypervisors, emulators, etc.) all the component along the chain must support it, and in some cases this is not a given.

This PR introduces a change to the x64 version of vec_caps to check for OS support too, and a warning on the Java side in case the CPU supports vector capabilities but those are not enabled at OS level.

Tested by passing noxsave to my linux box kernel boot options, and ensuring that the avx flags "disappear" from /proc/cpuinfo, and we fall back to the "no native vector" case.

Fixes #126809
2025-04-16 16:06:46 +02:00
..
cli Use logs dir as working directory (#124966) 2025-04-09 07:07:11 -07:00
core Remove @UpdateForV9 annotation (#125024) 2025-03-18 12:52:18 +01:00
dissect Use directory name as project name for libs (#115720) 2024-10-29 13:02:28 -07:00
entitlement Remove unnecessary network entitlements from server (#126799) 2025-04-15 11:39:29 -07:00
geo Support explicit Z/M attributes using WKT geometry (#125896) 2025-04-03 17:00:12 +02:00
grok Fix a bunch of non-final static fields (#119185) 2024-12-26 19:14:36 +01:00
h3 Reapply "Update Gradle wrapper to 8.13 (#122421)" (#123889) (#123896) 2025-03-05 08:02:13 +01:00
log4j Patch log4j JAR to remove JndiLookup class (#81629) 2021-12-10 15:51:38 -08:00
logging Set root logger level for CLIs (#123742) 2025-03-02 17:55:09 +00:00
logstash-bridge Make enrich project-aware (#124099) 2025-03-06 19:20:46 +01:00
lz4 Use directory name as project name for libs (#115720) 2024-10-29 13:02:28 -07:00
native Fix vec_caps to test for OS support too (on x64) (#126911) 2025-04-16 16:06:46 +02:00
plugin-analysis-api [Build] Remove deprecated BuildParams (#116984) 2024-11-22 16:30:57 +01:00
plugin-api Add AGPLv3 as a supported license 2024-09-13 15:29:46 -07:00
plugin-scanner Update ASM 9.7 -> 9.7.1 to support JDK 24 (#118094) 2024-12-06 08:16:46 +01:00
secure-sm Do not try to enable SecurityManager on JDK 24 (#117999) 2024-12-10 18:00:58 +01:00
simdvec Fix vec_caps to test for OS support too (on x64) (#126911) 2025-04-16 16:06:46 +02:00
ssl-config Add exclusive access files for security module (#123676) 2025-03-08 07:02:36 -08:00
tdigest Reapply "Update Gradle wrapper to 8.13 (#122421)" (#123889) (#123896) 2025-03-05 08:02:13 +01:00
x-content Workaround max name limit imposed by Jackson 2.17 (#126806) 2025-04-15 11:40:27 -07:00
build.gradle Use directory name as project name for libs (#115720) 2024-10-29 13:02:28 -07:00