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>
This commit is contained in:
Ard Biesheuvel 2024-05-13 18:43:11 +02:00 committed by mergify[bot]
parent 865229bcc8
commit c98f7f7550
6 changed files with 26 additions and 0 deletions

View File

@ -201,6 +201,9 @@
[PcdsDynamicHii] [PcdsDynamicHii]
gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gOvmfVariableGuid|0x0|FALSE|NV,BS gUefiOvmfPkgTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gOvmfVariableGuid|0x0|FALSE|NV,BS
[PcdsPatchableInModule.common]
gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE
################################################################################ ################################################################################
# #
# Components Section - list of all EDK II Modules needed by this Platform # Components Section - list of all EDK II Modules needed by this Platform

View File

@ -293,6 +293,10 @@
gEfiNetworkPkgTokenSpaceGuid.PcdIPv4PXESupport|0x01 gEfiNetworkPkgTokenSpaceGuid.PcdIPv4PXESupport|0x01
gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01 gEfiNetworkPkgTokenSpaceGuid.PcdIPv6PXESupport|0x01
# whether to use HVC or SMC to issue monitor calls - this typically depends
# on the exception level at which the UEFI system firmware executes
gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE
# #
# TPM2 support # TPM2 support
# #

View File

@ -203,6 +203,8 @@
gArmTokenSpaceGuid.PcdFdBaseAddress|0x0 gArmTokenSpaceGuid.PcdFdBaseAddress|0x0
gArmTokenSpaceGuid.PcdFvBaseAddress|0x0 gArmTokenSpaceGuid.PcdFvBaseAddress|0x0
gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE
[PcdsDynamicDefault.common] [PcdsDynamicDefault.common]
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3 gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3

View File

@ -120,6 +120,8 @@
gArmTokenSpaceGuid.PcdFdBaseAddress|0x0 gArmTokenSpaceGuid.PcdFdBaseAddress|0x0
gArmTokenSpaceGuid.PcdFvBaseAddress|0x0 gArmTokenSpaceGuid.PcdFvBaseAddress|0x0
gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE
[PcdsDynamicDefault.common] [PcdsDynamicDefault.common]
gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0 gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0

View File

@ -18,6 +18,8 @@
#include <Library/FdtSerialPortAddressLib.h> #include <Library/FdtSerialPortAddressLib.h>
#include <libfdt.h> #include <libfdt.h>
#include <Chipset/AArch64.h>
#include <Guid/EarlyPL011BaseAddress.h> #include <Guid/EarlyPL011BaseAddress.h>
#include <Guid/FdtHob.h> #include <Guid/FdtHob.h>
@ -224,5 +226,17 @@ PlatformPeim (
BuildFvHob (PcdGet64 (PcdFvBaseAddress), PcdGet32 (PcdFvSize)); 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; return EFI_SUCCESS;
} }

View File

@ -45,6 +45,7 @@
[Pcd] [Pcd]
gArmTokenSpaceGuid.PcdFvBaseAddress gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdMonitorConduitHvc
gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress ## SOMETIMES_PRODUCES gEfiSecurityPkgTokenSpaceGuid.PcdTpmBaseAddress ## SOMETIMES_PRODUCES
gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress gUefiOvmfPkgTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress