From bd3153b4bd311831b33571d523228b2d16ff039a Mon Sep 17 00:00:00 2001 From: Kevin Hui Date: Wed, 10 Apr 2024 14:27:44 -0700 Subject: [PATCH] Add flags to enable x86-64-v2 support Summary: Intel hosts without this diff are running into an issue where standard linux binaries are saying the following: ``` $ hermit run date Fatal glibc error: CPU does not support x86-64-v2 ``` This is unlike the AMD hosts because the AMD hosts do not actually properly intercept cpuid instructions (another issue we should deal with...). So they have this feature enabled since it's the equivalent of `no-virtualize-cpuid`. Looking online, it seems like we need to just enable the flags required to support that architectural level. More details in https://github.com/facebookexperimental/hermit/issues/49#issuecomment-2043047843 Reviewed By: jasonwhite Differential Revision: D55874608 fbshipit-source-id: 619116fe2f3a9d0bcfd667f1c6db26c031cee640 --- detcore/src/cpuid.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/detcore/src/cpuid.rs b/detcore/src/cpuid.rs index fbb4bee..38427c4 100644 --- a/detcore/src/cpuid.rs +++ b/detcore/src/cpuid.rs @@ -40,7 +40,13 @@ const fn cpuid_result(eax: u32, ebx: u32, ecx: u32, edx: u32) -> CpuIdResult { // masked off to prevent non-determinism. const CPUIDS: &[CpuIdResult] = &[ cpuid_result(0x0000000D, 0x756E6547, 0x6C65746E, 0x49656E69), - cpuid_result(0x00000663, 0x00000800, 0x90202001, 0x078BFBFD), + cpuid_result( + 0x00000663, + 0x00000800, + // These flags are required for x86-64-v2 support. Found via https://www.felixcloutier.com/x86/cpuid + 0x90202001 | (1 << 0) | (1 << 9) | (1 << 13) | (1 << 19) | (1 << 20) | (1 << 23), + 0x078BFBFD, + ), cpuid_result(0x00000001, 0x00000000, 0x0000004D, 0x002C307D), cpuid_result(0x00000000, 0x00000000, 0x00000000, 0x00000000), cpuid_result(0x00000120, 0x01C0003F, 0x0000003F, 0x00000001),