Add cmake variable to disable writing gs register (#2284)

Support to disable writing x86-64 GS segment register by
  `cmake -DWAMR_DISABLE_WRITE_GS_BASE=1`
and update document. Issue was reported in #2273.
This commit is contained in:
Wenyong Huang
2023-06-13 10:26:25 +08:00
committed by GitHub
parent 7ec77598dd
commit fe830d805d
4 changed files with 21 additions and 1 deletions

View File

@ -449,4 +449,11 @@
#define WASM_ENABLE_STATIC_PGO 0
#endif
/* Disable writing linear memory base address to GS segment register,
by default only in linux x86-64, linear memory base addr is written
to GS segment register before calling wasm/aot function. */
#ifndef WASM_DISABLE_WRITE_GS_BASE
#define WASM_DISABLE_WRITE_GS_BASE 0
#endif
#endif /* end of _CONFIG_H_ */

View File

@ -63,6 +63,7 @@ typedef sem_t korp_sem;
#define bh_socket_t int
#if WASM_DISABLE_WRITE_GS_BASE == 0
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
#define os_writegsbase(base_addr) \
do { \
@ -76,6 +77,7 @@ typedef sem_t korp_sem;
_writegsbase_u64(((uint64)(uintptr_t)base_addr))
#endif
#endif
#endif
#if WASM_DISABLE_HW_BOUND_CHECK == 0
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \