summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Lindholm <leif.lindholm@oss.qualcomm.com>2025-04-08 18:18:08 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-04-11 12:48:56 +0000
commit6952d1fa901a9053abe46c317ee820fc28a2835d (patch)
treec0934c152a45a83b3e4ae0a64af0633a64066194
parent03686872996a06dc119c520feef95a933ef4dee3 (diff)
downloadedk2-6952d1fa901a9053abe46c317ee820fc28a2835d.zip
edk2-6952d1fa901a9053abe46c317ee820fc28a2835d.tar.gz
edk2-6952d1fa901a9053abe46c317ee820fc28a2835d.tar.bz2
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>
-rw-r--r--ArmPlatformPkg/PeilessSec/AArch64/ArchPeilessSec.c5
-rw-r--r--ArmPlatformPkg/PeilessSec/AArch64/ModuleEntryPoint.S4
-rw-r--r--ArmPlatformPkg/PeilessSec/Arm/ArchPeilessSec.c4
-rw-r--r--ArmPlatformPkg/PeilessSec/Arm/ModuleEntryPoint.S6
-rw-r--r--ArmPlatformPkg/PeilessSec/PeilessSec.inf4
-rw-r--r--ArmPlatformPkg/Sec/Arm/ModuleEntryPoint.S6
-rw-r--r--ArmPlatformPkg/Sec/Sec.c5
-rw-r--r--ArmPlatformPkg/Sec/Sec.inf4
8 files changed, 22 insertions, 16 deletions
diff --git a/ArmPlatformPkg/PeilessSec/AArch64/ArchPeilessSec.c b/ArmPlatformPkg/PeilessSec/AArch64/ArchPeilessSec.c
index ccc9cde..22148f0 100644
--- a/ArmPlatformPkg/PeilessSec/AArch64/ArchPeilessSec.c
+++ b/ArmPlatformPkg/PeilessSec/AArch64/ArchPeilessSec.c
@@ -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);
diff --git a/ArmPlatformPkg/PeilessSec/AArch64/ModuleEntryPoint.S b/ArmPlatformPkg/PeilessSec/AArch64/ModuleEntryPoint.S
index c6b7093..5f285f3 100644
--- a/ArmPlatformPkg/PeilessSec/AArch64/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PeilessSec/AArch64/ModuleEntryPoint.S
@@ -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)
diff --git a/ArmPlatformPkg/PeilessSec/Arm/ArchPeilessSec.c b/ArmPlatformPkg/PeilessSec/Arm/ArchPeilessSec.c
index 3c3cef6..e2f6f67 100644
--- a/ArmPlatformPkg/PeilessSec/Arm/ArchPeilessSec.c
+++ b/ArmPlatformPkg/PeilessSec/Arm/ArchPeilessSec.c
@@ -18,8 +18,4 @@ ArchInitialize (
{
// Enable program flow prediction, if supported.
ArmEnableBranchPrediction ();
-
- if (FixedPcdGet32 (PcdVFPEnabled)) {
- ArmEnableVFP ();
- }
}
diff --git a/ArmPlatformPkg/PeilessSec/Arm/ModuleEntryPoint.S b/ArmPlatformPkg/PeilessSec/Arm/ModuleEntryPoint.S
index 6b38b86..9043d86 100644
--- a/ArmPlatformPkg/PeilessSec/Arm/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PeilessSec/Arm/ModuleEntryPoint.S
@@ -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)
diff --git a/ArmPlatformPkg/PeilessSec/PeilessSec.inf b/ArmPlatformPkg/PeilessSec/PeilessSec.inf
index 7f67adf..e210d01 100644
--- a/ArmPlatformPkg/PeilessSec/PeilessSec.inf
+++ b/ArmPlatformPkg/PeilessSec/PeilessSec.inf
@@ -70,9 +70,11 @@
gArmTokenSpaceGuid.PcdFdSize
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdFvSize
- gArmTokenSpaceGuid.PcdVFPEnabled
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
+[FixedPcd.ARM]
+ gArmTokenSpaceGuid.PcdVFPEnabled
+
[Pcd]
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
diff --git a/ArmPlatformPkg/Sec/Arm/ModuleEntryPoint.S b/ArmPlatformPkg/Sec/Arm/ModuleEntryPoint.S
index 1207497..7cb3de7 100644
--- a/ArmPlatformPkg/Sec/Arm/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/Sec/Arm/ModuleEntryPoint.S
@@ -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))
diff --git a/ArmPlatformPkg/Sec/Sec.c b/ArmPlatformPkg/Sec/Sec.c
index 9a700e5..4535ae7 100644
--- a/ArmPlatformPkg/Sec/Sec.c
+++ b/ArmPlatformPkg/Sec/Sec.c
@@ -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 ();
diff --git a/ArmPlatformPkg/Sec/Sec.inf b/ArmPlatformPkg/Sec/Sec.inf
index b5af19e..a75ce8d 100644
--- a/ArmPlatformPkg/Sec/Sec.inf
+++ b/ArmPlatformPkg/Sec/Sec.inf
@@ -58,9 +58,11 @@
[FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdFvSize
- gArmTokenSpaceGuid.PcdVFPEnabled
gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize
gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack
+
+[FixedPcd.ARM]
+ gArmTokenSpaceGuid.PcdVFPEnabled