Commit b68c1000 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-34565 MariaDB crashes with SIGILL because the OS does not support AVX512

In commit 232d7a5e we almost got
the detection logic right. However, the XGETBV instruction would
crash if Linux was started up with the option noxsave.

have_vpclmulqdq(): Check for the XSAVE flag at the correct position
and also for the AVX flag.

This was tested on Ubuntu 22.04 by starting up its Linux 5.15 kernel
with and without the noxsave option.
parent ae02999c
......@@ -39,7 +39,7 @@ extern "C" unsigned crc32c_sse42(unsigned crc, const void* buf, size_t size);
constexpr uint32_t cpuid_ecx_SSE42= 1U << 20;
constexpr uint32_t cpuid_ecx_SSE42_AND_PCLMUL= cpuid_ecx_SSE42 | 1U << 1;
constexpr uint32_t cpuid_ecx_XSAVE= 1U << 26;
constexpr uint32_t cpuid_ecx_AVX_AND_XSAVE= 1U << 28 | 1U << 27;
static uint32_t cpuid_ecx()
{
......@@ -395,7 +395,7 @@ static bool os_have_avx512()
static ATTRIBUTE_NOINLINE bool have_vpclmulqdq(uint32_t cpuid_ecx)
{
if (!(cpuid_ecx & cpuid_ecx_XSAVE) || !os_have_avx512())
if ((~cpuid_ecx & cpuid_ecx_AVX_AND_XSAVE) || !os_have_avx512())
return false;
# ifdef _MSC_VER
int regs[4];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment