summaryrefslogtreecommitdiffstats
path: root/ArmVirtPkg/Library
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2024-05-13 18:43:11 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-05-24 15:48:52 +0000
commitc98f7f75508912c086158892fc56b0c3b85abcf1 (patch)
treedcf8ee3f141bbfb76a75c0b88d03e91b4b83e890 /ArmVirtPkg/Library
parent865229bcc8939c7a69d525f2b0627ef1532d5bc6 (diff)
downloadedk2-c98f7f75508912c086158892fc56b0c3b85abcf1.tar.gz
edk2-c98f7f75508912c086158892fc56b0c3b85abcf1.tar.bz2
edk2-c98f7f75508912c086158892fc56b0c3b85abcf1.zip
ArmVirtPkg: Use dynamic PCD to set the SMCCC conduit
On ARM systems, whether SMC or HVC instructions need to be used to issue monitor calls is typically dependent on the exception level, but there are also cases where EL1 might use SMC instructions, so there is no hard and fast rule. For ArmVirtQemu, this does depend strictly on the exception level, so set the default to HVC (for EL1 execution) and override it to SMC when booted at EL2. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Leif Lindholm <quic_llindhol@quicinc.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Committed-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'ArmVirtPkg/Library')
-rw-r--r--ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c14
-rw-r--r--ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf1
2 files changed, 15 insertions, 0 deletions
diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
index 7ab4aa2d6b..b8e9208301 100644
--- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
+++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
@@ -18,6 +18,8 @@
#include <Library/FdtSerialPortAddressLib.h>
#include <libfdt.h>
+#include <Chipset/AArch64.h>
+
#include <Guid/EarlyPL011BaseAddress.h>
#include <Guid/FdtHob.h>
@@ -224,5 +226,17 @@ PlatformPeim (
BuildFvHob (PcdGet64 (PcdFvBaseAddress), PcdGet32 (PcdFvSize));
+ #ifdef MDE_CPU_AARCH64
+ //
+ // Set the SMCCC conduit to SMC if executing at EL2, which is typically the
+ // exception level that services HVCs rather than the one that invokes them.
+ //
+ if (ArmReadCurrentEL () == AARCH64_EL2) {
+ Status = PcdSetBoolS (PcdMonitorConduitHvc, FALSE);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ #endif
+
return EFI_SUCCESS;
}
diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
index e9a34b6e2e..a38b89c103 100644
--- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
+++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
@@ -45,6 +45,7 @@
[Pcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
+ gArmTokenSpaceGuid.PcdMonitorConduitHvc
gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress ## SOMETIMES_PRODUCES
gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress