summaryrefslogtreecommitdiff
path: root/test/wasm2c/export-names.txt
diff options
context:
space:
mode:
authorShravan Narayan <shravanrn@gmail.com>2024-07-15 17:06:24 -0500
committerShravan Narayan <shravanrn@gmail.com>2024-09-06 16:48:31 -0500
commitc6853eb4857908072fd1d7c28dffb1d2613a0ee6 (patch)
tree78ef4f5369ee821c94aa643f7b82ebca726d6ad4 /test/wasm2c/export-names.txt
parente3b16dae4166b138bbd04bbe67281f4fa47fd4de (diff)
downloadwabt-c6853eb4857908072fd1d7c28dffb1d2613a0ee6.tar.gz
wabt-c6853eb4857908072fd1d7c28dffb1d2613a0ee6.tar.bz2
wabt-c6853eb4857908072fd1d7c28dffb1d2613a0ee6.zip
wasm2c: Segue support for CPUs without wrgsbase instructions
Diffstat (limited to 'test/wasm2c/export-names.txt')
-rw-r--r--test/wasm2c/export-names.txt64
1 files changed, 40 insertions, 24 deletions
diff --git a/test/wasm2c/export-names.txt b/test/wasm2c/export-names.txt
index 7c4e6eda..f5762a19 100644
--- a/test/wasm2c/export-names.txt
+++ b/test/wasm2c/export-names.txt
@@ -123,11 +123,16 @@ void w2c_test_0xE20x9D0xA40xEF0xB80x8F(w2c_test*);
// for accessing pointers, and supports memcpy on pointers with custom
// "address namespaces". GCC does not support the memcpy requirement, so
// this leaves only clang for now.
-// (5) The OS doesn't replace the segment register on context switch which
+// (5) The OS provides a way to query if (rd|wr)gsbase is allowed by the kernel
+// or the implementation has to use a syscall for this.
+// (6) The OS doesn't replace the segment register on context switch which
// eliminates windows for now
+//
+// While more OS can be supported in the future, we only support linux for now
#if WASM_RT_ALLOW_SEGUE && !WABT_BIG_ENDIAN && \
(defined(__x86_64__) || defined(_M_X64)) && IS_SINGLE_UNSHARED_MEMORY && \
- __clang__ && __has_builtin(__builtin_ia32_wrgsbase64) && !defined(_WIN32)
+ __clang__ && __has_builtin(__builtin_ia32_wrgsbase64) && \
+ !defined(_WIN32) && defined(__linux__)
#define WASM_RT_USE_SEGUE 1
#else
#define WASM_RT_USE_SEGUE 0
@@ -136,9 +141,20 @@ void w2c_test_0xE20x9D0xA40xEF0xB80x8F(w2c_test*);
#if WASM_RT_USE_SEGUE
// POSIX uses FS for TLS, GS is free
-#define WASM_RT_SEGUE_READ_BASE() __builtin_ia32_rdgsbase64()
-#define WASM_RT_SEGUE_WRITE_BASE(base) \
- __builtin_ia32_wrgsbase64((uintptr_t)base)
+static inline void* wasm_rt_segue_read_base() {
+ if (wasm_rt_fsgsbase_inst_supported) {
+ return (void*)__builtin_ia32_rdgsbase64();
+ } else {
+ return wasm_rt_syscall_get_segue_base();
+ }
+}
+static inline void wasm_rt_segue_write_base(void* base) {
+ if (wasm_rt_fsgsbase_inst_supported) {
+ __builtin_ia32_wrgsbase64((uintptr_t)base);
+ } else {
+ wasm_rt_syscall_set_segue_base(base);
+ }
+}
#define MEM_ADDR_MEMOP(mem, addr, n) ((uint8_t __seg_gs*)(uintptr_t)addr)
#else
#define MEM_ADDR_MEMOP(mem, addr, n) MEM_ADDR(mem, addr, n)
@@ -194,7 +210,7 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
#if WASM_RT_USE_SEGUE && WASM_RT_SANITY_CHECKS
#include <stdio.h>
#define WASM_RT_CHECK_BASE(mem) \
- if (((uintptr_t)((mem)->data)) != ((uintptr_t)WASM_RT_SEGUE_READ_BASE())) { \
+ if (((uintptr_t)((mem)->data)) != ((uintptr_t)wasm_rt_segue_read_base())) { \
puts("Segment register mismatch\n"); \
abort(); \
}
@@ -780,60 +796,60 @@ static void init_memories(w2c_test* instance) {
/* export: '' */
void w2c_test_(w2c_test* instance) {
#if WASM_RT_USE_SEGUE
- uintptr_t segue_saved_base = WASM_RT_SEGUE_READ_BASE();
- WASM_RT_SEGUE_WRITE_BASE((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
+ void* segue_saved_base = wasm_rt_segue_read_base();
+ wasm_rt_segue_write_base((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
#endif
w2c_test__0(instance);
#if WASM_RT_USE_SEGUE
- WASM_RT_SEGUE_WRITE_BASE(segue_saved_base);
+ wasm_rt_segue_write_base(segue_saved_base);
#endif
}
/* export: '*\2F' */
void w2c_test_0x2A0x2F(w2c_test* instance) {
#if WASM_RT_USE_SEGUE
- uintptr_t segue_saved_base = WASM_RT_SEGUE_READ_BASE();
- WASM_RT_SEGUE_WRITE_BASE((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
+ void* segue_saved_base = wasm_rt_segue_read_base();
+ wasm_rt_segue_write_base((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
#endif
w2c_test__0(instance);
#if WASM_RT_USE_SEGUE
- WASM_RT_SEGUE_WRITE_BASE(segue_saved_base);
+ wasm_rt_segue_write_base(segue_saved_base);
#endif
}
/* export: '\3F\3F\2F' */
void w2c_test_0x3F0x3F0x2F(w2c_test* instance) {
#if WASM_RT_USE_SEGUE
- uintptr_t segue_saved_base = WASM_RT_SEGUE_READ_BASE();
- WASM_RT_SEGUE_WRITE_BASE((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
+ void* segue_saved_base = wasm_rt_segue_read_base();
+ wasm_rt_segue_write_base((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
#endif
w2c_test__0(instance);
#if WASM_RT_USE_SEGUE
- WASM_RT_SEGUE_WRITE_BASE(segue_saved_base);
+ wasm_rt_segue_write_base(segue_saved_base);
#endif
}
/* export: '\0A' */
void w2c_test_0x0A(w2c_test* instance) {
#if WASM_RT_USE_SEGUE
- uintptr_t segue_saved_base = WASM_RT_SEGUE_READ_BASE();
- WASM_RT_SEGUE_WRITE_BASE((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
+ void* segue_saved_base = wasm_rt_segue_read_base();
+ wasm_rt_segue_write_base((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
#endif
w2c_test__0(instance);
#if WASM_RT_USE_SEGUE
- WASM_RT_SEGUE_WRITE_BASE(segue_saved_base);
+ wasm_rt_segue_write_base(segue_saved_base);
#endif
}
/* export: '\E2\9D\A4\EF\B8\8F' */
void w2c_test_0xE20x9D0xA40xEF0xB80x8F(w2c_test* instance) {
#if WASM_RT_USE_SEGUE
- uintptr_t segue_saved_base = WASM_RT_SEGUE_READ_BASE();
- WASM_RT_SEGUE_WRITE_BASE((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
+ void* segue_saved_base = wasm_rt_segue_read_base();
+ wasm_rt_segue_write_base((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
#endif
w2c_test__0(instance);
#if WASM_RT_USE_SEGUE
- WASM_RT_SEGUE_WRITE_BASE(segue_saved_base);
+ wasm_rt_segue_write_base(segue_saved_base);
#endif
}
@@ -850,11 +866,11 @@ void wasm2c_test_instantiate(w2c_test* instance, struct w2c_0x5Cmodule* w2c_0x5C
init_instance_import(instance, w2c_0x5Cmodule_instance);
init_memories(instance);
#if WASM_RT_USE_SEGUE
- uintptr_t segue_saved_base = WASM_RT_SEGUE_READ_BASE();
- WASM_RT_SEGUE_WRITE_BASE((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
+ void* segue_saved_base = wasm_rt_segue_read_base();
+ wasm_rt_segue_write_base((*instance->w2c_0x5Cmodule_import0x200x2A0x2F).data);
#endif
#if WASM_RT_USE_SEGUE
- WASM_RT_SEGUE_WRITE_BASE(segue_saved_base);
+ wasm_rt_segue_write_base(segue_saved_base);
#endif
}