summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShravan Narayan <shravanrn@gmail.com>2024-11-07 19:57:52 -0600
committerShravan Narayan <shravanrn@gmail.com>2024-11-11 17:21:55 -0600
commit94c25a93c5ee81939bd1acfee06808f6745883ce (patch)
tree3645a692b9b9dee9bad53765293f5f139857e310
parentc7c89685fe7512d315d0a58e965c66b8e6a77be4 (diff)
downloadwabt-94c25a93c5ee81939bd1acfee06808f6745883ce.tar.gz
wabt-94c25a93c5ee81939bd1acfee06808f6745883ce.tar.bz2
wabt-94c25a93c5ee81939bd1acfee06808f6745883ce.zip
wasm2c: minor code cleanup for OS checks for segue
Define the fsgabase capability lookup to HWCAP2_FSGSBASE as per https://www.kernel.org/doc/html/latest/arch/x86/x86_64/fsgs.html#fsgsbase-instructions-enablement
-rw-r--r--wasm2c/wasm-rt-impl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/wasm2c/wasm-rt-impl.c b/wasm2c/wasm-rt-impl.c
index 92616351..20137b80 100644
--- a/wasm2c/wasm-rt-impl.c
+++ b/wasm2c/wasm-rt-impl.c
@@ -60,6 +60,10 @@ bool wasm_rt_fsgsbase_inst_supported = false;
#include <asm/prctl.h> // For ARCH_SET_GS
#include <sys/syscall.h> // For SYS_arch_prctl
#include <unistd.h> // For syscall
+
+#ifndef HWCAP2_FSGSBASE
+#define HWCAP2_FSGSBASE (1 << 1)
+#endif
#endif
#if WASM_RT_SEGUE_FREE_SEGMENT
@@ -245,7 +249,7 @@ void wasm_rt_init(void) {
#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 18
// Check for support for userspace wrgsbase instructions
unsigned long val = getauxval(AT_HWCAP2);
- wasm_rt_fsgsbase_inst_supported = val & (1 << 1);
+ wasm_rt_fsgsbase_inst_supported = val & HWCAP2_FSGSBASE;
#endif
#endif