ArmPlatformPkg/Sec: clean up FP enabling code

UEFI defines that FP support is required on AArch64, whereas many
platforms enable it anyway on Arm. But when it's enabled, C code can
generate instructions targeting FP registers, so:

- move ArmEnableVFP call to asm
- make it unconditional on AArch64

Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
This commit is contained in:
Leif Lindholm 2025-04-08 18:18:08 +01:00 committed by mergify[bot]
parent 0368687299
commit 6952d1fa90
8 changed files with 22 additions and 16 deletions

View file

@ -18,11 +18,6 @@ ArchInitialize (
VOID
)
{
// Enable Floating Point
if (FixedPcdGet32 (PcdVFPEnabled)) {
ArmEnableVFP ();
}
if (ArmReadCurrentEL () == AARCH64_EL2) {
// Trap General Exceptions. All exceptions that would be routed to EL1 are routed to EL2
ArmWriteHcr (ARM_HCR_TGE);

View file

@ -11,6 +11,10 @@ ASM_FUNC(_ModuleEntryPoint)
// Do early platform specific actions
bl ASM_PFX(ArmPlatformPeiBootAction)
// Enable Floating Point. This needs to be done before entering C code, which
// may use FP/SIMD registers.
bl ArmEnableVFP
// Check if we can install the stack at the top of the System Memory or if we need
// to install the stacks at the bottom of the Firmware Device (case the FD is located
// at the top of the DRAM)

View file

@ -18,8 +18,4 @@ ArchInitialize (
{
// Enable program flow prediction, if supported.
ArmEnableBranchPrediction ();
if (FixedPcdGet32 (PcdVFPEnabled)) {
ArmEnableVFP ();
}
}

View file

@ -13,6 +13,12 @@ ASM_FUNC(_ModuleEntryPoint)
// Do early platform specific actions
bl ASM_PFX(ArmPlatformPeiBootAction)
#if (FixedPcdGet32 (PcdVFPEnabled))
// Enable Floating Point. This needs to be done before entering C code, which
// may use FP/SIMD registers.
bl ArmEnableVFP
#endif
// Check if we can install the stack at the top of the System Memory or if we need
// to install the stacks at the bottom of the Firmware Device (case the FD is located
// at the top of the DRAM)

View file

@ -70,9 +70,11 @@
gArmTokenSpaceGuid.PcdFdSize
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdFvSize
gArmTokenSpaceGuid.PcdVFPEnabled
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
[FixedPcd.ARM]
gArmTokenSpaceGuid.PcdVFPEnabled
[Pcd]
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize

View file

@ -11,6 +11,12 @@ ASM_FUNC(_ModuleEntryPoint)
// Do early platform specific actions
bl ASM_PFX(ArmPlatformPeiBootAction)
#if (FixedPcdGet32 (PcdVFPEnabled))
// Enable Floating Point. This needs to be done before entering C code, which
// may use FP/SIMD registers.
bl ArmEnableVFP
#endif
// Get the top of the primary stacks (and the base of the secondary stacks)
MOV32 (r1, FixedPcdGet64(PcdCPUCoresStackBase) + FixedPcdGet32(PcdCPUCorePrimaryStackSize))

View file

@ -223,11 +223,6 @@ CEntryPoint (
ASSERT (((UINTN)PeiVectorTable & ARM_VECTOR_TABLE_ALIGNMENT) == 0);
ArmWriteVBar ((UINTN)PeiVectorTable);
// Enable Floating Point
if (FixedPcdGet32 (PcdVFPEnabled)) {
ArmEnableVFP ();
}
// Invoke "ProcessLibraryConstructorList" to have all library constructors
// called.
ProcessLibraryConstructorList ();

View file

@ -58,9 +58,11 @@
[FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdFvSize
gArmTokenSpaceGuid.PcdVFPEnabled
gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack
[FixedPcd.ARM]
gArmTokenSpaceGuid.PcdVFPEnabled