diff --git a/src/coreclr/inc/clrconfigvalues.h b/src/coreclr/inc/clrconfigvalues.h index ddc7c79506ad4..acf983668b3ee 100644 --- a/src/coreclr/inc/clrconfigvalues.h +++ b/src/coreclr/inc/clrconfigvalues.h @@ -790,6 +790,10 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableArm64Sha256, W("EnableArm64Sh RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableArm64Rcpc, W("EnableArm64Rcpc"), 1, "Allows Arm64 Rcpc+ hardware intrinsics to be disabled") RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableArm64Rcpc2, W("EnableArm64Rcpc2"), 1, "Allows Arm64 Rcpc2+ hardware intrinsics to be disabled") RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableArm64Sve, W("EnableArm64Sve"), 1, "Allows Arm64 SVE hardware intrinsics to be disabled") +#if defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG)) +// TODO-SVE: Once coreclr supports vector lengths >16bytes, the default should be -1. +RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_MaxVectorLength, W("MaxVectorLength"), 16, "Specifies maximum size of the vector length in bytes while using SVE on Arm64", CLRConfig::LookupOptions::ParseIntegerAsBase10) +#endif //defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG)) #endif /// diff --git a/src/coreclr/vm/codeman.cpp b/src/coreclr/vm/codeman.cpp index 3bb10ac6c6bb6..e1b52ec336b46 100644 --- a/src/coreclr/vm/codeman.cpp +++ b/src/coreclr/vm/codeman.cpp @@ -4,7 +4,10 @@ // // codeman.cpp - a managment class for handling multiple code managers // - +#if defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG)) +#include +#include +#endif // defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG)) #include "common.h" #include "jitinterface.h" #include "corjit.h" @@ -1525,6 +1528,18 @@ void EEJitManager::SetCpuInfo() if (((cpuFeatures & ARM64IntrinsicConstants_Sve) != 0) && CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableArm64Sve)) { +#if defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG)) + int maxVectorLength = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_MaxVectorLength); + + // Limit the SVE vector length to 'maxVectorLength' if the underlying hardware offers longer vectors. + if ((prctl(PR_SVE_GET_VL, 0,0,0,0) & PR_SVE_VL_LEN_MASK) > maxVectorLength) + { + if (prctl(PR_SVE_SET_VL, (maxVectorLength | PR_SVE_VL_INHERIT), 0, 0, 0) == -1) + { + LogErrorToHost("LoadAndInitializeJIT: prctl() FAILED - unable to set maxVectorLength to %d", maxVectorLength); + } + } +#endif // defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG)) CPUCompileFlags.Set(InstructionSet_Sve); }