From fe38405b1dc41f935122c20a8a9782d3834a0fae Mon Sep 17 00:00:00 2001
From: David Kontyko <33853225+dkontyko@users.noreply.github.com>
Date: Mon, 22 Apr 2024 19:03:42 -0400
Subject: [PATCH] Separate DSC configuration parser check for ARM processor
(#21395)
---
.../engine/parser/Parser.cs | 15 +++++++++++++--
.../resources/ParserStrings.resx | 3 +++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/System.Management.Automation/engine/parser/Parser.cs b/src/System.Management.Automation/engine/parser/Parser.cs
index 45529b2de8..464231c040 100644
--- a/src/System.Management.Automation/engine/parser/Parser.cs
+++ b/src/System.Management.Automation/engine/parser/Parser.cs
@@ -2984,8 +2984,8 @@ namespace System.Management.Automation.Language
Runspaces.Runspace.DefaultRunspace = localRunspace;
}
- // Configuration is not supported on ARM or in ConstrainedLanguage
- if (PsUtils.IsRunningOnProcessorArchitectureARM() || Runspace.DefaultRunspace?.ExecutionContext?.LanguageMode == PSLanguageMode.ConstrainedLanguage)
+ // Configuration is not supported in ConstrainedLanguage
+ if (Runspace.DefaultRunspace?.ExecutionContext?.LanguageMode == PSLanguageMode.ConstrainedLanguage)
{
if (SystemPolicy.GetSystemLockdownPolicy() != SystemEnforcementMode.Audit)
{
@@ -3004,6 +3004,17 @@ namespace System.Management.Automation.Language
dropIntoDebugger: true);
}
+ // Configuration is not supported on ARM64
+ if (PsUtils.IsRunningOnProcessorArchitectureARM())
+ {
+ ReportError(
+ configurationToken.Extent,
+ nameof(ParserStrings.ConfigurationNotAllowedOnArm64),
+ ParserStrings.ConfigurationNotAllowedOnArm64,
+ configurationToken.Kind.Text());
+ return null;
+ }
+
// Configuration is not supported on WinPE
if (Utils.IsWinPEHost())
{
diff --git a/src/System.Management.Automation/resources/ParserStrings.resx b/src/System.Management.Automation/resources/ParserStrings.resx
index aaf7d75860..a76527cfba 100644
--- a/src/System.Management.Automation/resources/ParserStrings.resx
+++ b/src/System.Management.Automation/resources/ParserStrings.resx
@@ -1370,4 +1370,7 @@ ModuleVersion : Version of module to import. If used, ModuleName must represent
Creating a steppable pipeline from a script block may require evaluating some expressions within the script block. The expression evaluation will silently fail and return 'null' in Constrained Language mode, unless the expression represents a constant value.
+
+ Configuration keyword is not supported on ARM64 processors.
+