From 329c574f5ceb98e4946394d7eeeb35c7a3495203 Mon Sep 17 00:00:00 2001 From: Roman Zagorowski Date: Wed, 12 Jun 2024 11:47:47 +0200 Subject: [PATCH 1/2] Disable EnableWriteXorExecute by default on riscv64 architectue On riscv64 architectue any dotnet process that loads corossgened assembly without DOTNET_EnableWriteXorExecute=0 environment variable set crashes with "Segmentation fault" error. For example System.Private.CoreLib.dll is compiled with crossgen2 by default during build phase so this crash applies to any processes that loads it. Setting EnableWriteXorExecute=0 disables this options on riscv64 architecure and prevents these crashes. Co-authored-by: Dong-Heon Jung --- src/coreclr/inc/clrconfigvalues.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/inc/clrconfigvalues.h b/src/coreclr/inc/clrconfigvalues.h index 07fa685484f02..591b3cd4bae06 100644 --- a/src/coreclr/inc/clrconfigvalues.h +++ b/src/coreclr/inc/clrconfigvalues.h @@ -722,7 +722,11 @@ RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_LTTng, W("LTTng"), 1, "If DOTNET_LTTng is s // // Executable code // +#ifdef TARGET_RISCV64 +RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableWriteXorExecute, W("EnableWriteXorExecute"), 0, "Enable W^X for executable memory."); +#else RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableWriteXorExecute, W("EnableWriteXorExecute"), 1, "Enable W^X for executable memory."); +#endif // TARGET_RISCV64 #ifdef FEATURE_GDBJIT /// From 838e0cd300956eedf120f816926d6d2b40748ddb Mon Sep 17 00:00:00 2001 From: Roman Zagorowski Date: Fri, 14 Jun 2024 10:08:59 +0200 Subject: [PATCH 2/2] Add a link to an issue about re-enabling WriteXorExecute on riscv64 arch. Co-authored-by: Jan Kotas --- src/coreclr/inc/clrconfigvalues.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/inc/clrconfigvalues.h b/src/coreclr/inc/clrconfigvalues.h index 591b3cd4bae06..dfdea7746bced 100644 --- a/src/coreclr/inc/clrconfigvalues.h +++ b/src/coreclr/inc/clrconfigvalues.h @@ -722,6 +722,7 @@ RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_LTTng, W("LTTng"), 1, "If DOTNET_LTTng is s // // Executable code // +// TODO: https://github.com/dotnet/runtime/issues/103465 #ifdef TARGET_RISCV64 RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableWriteXorExecute, W("EnableWriteXorExecute"), 0, "Enable W^X for executable memory."); #else