summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Drivers/ArmGic
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2014-11-13 16:41:51 +0000
committeroliviermartin <oliviermartin@Edk2>2014-11-13 16:41:51 +0000
commit37ec4d9af79197dcc93810f230af7a3fe2d0d243 (patch)
tree114e0390b491db4159daa3ea6fa8607c180a14a3 /ArmPkg/Drivers/ArmGic
parent77d5dac5c62ec8c8e732571ed70c9204bddf7695 (diff)
downloadedk2-37ec4d9af79197dcc93810f230af7a3fe2d0d243.tar.gz
edk2-37ec4d9af79197dcc93810f230af7a3fe2d0d243.tar.bz2
edk2-37ec4d9af79197dcc93810f230af7a3fe2d0d243.zip
ArmPkg/ArmGicLib: select GICv2 mode if SRE is present but unavailable
Even if the CPU id registers indicate hardware support for the System Register interface to the GIC, higher exception levels may disable that interface and only allow access through MMIO. So move the enabling of the SRE bit to the GIC version detection routine: if we trigger an exception, we would have anyway at a later stage, so the net effect is the same. However, if setting the bit doesn't stick, it means we can switch to MMIO and proceed normally otherwise. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16344 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Drivers/ArmGic')
-rw-r--r--ArmPkg/Drivers/ArmGic/AArch64/ArmGicArchLib.c14
-rw-r--r--ArmPkg/Drivers/ArmGic/Arm/ArmGicArchLib.c14
-rw-r--r--ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c8
3 files changed, 26 insertions, 10 deletions
diff --git a/ArmPkg/Drivers/ArmGic/AArch64/ArmGicArchLib.c b/ArmPkg/Drivers/ArmGic/AArch64/ArmGicArchLib.c
index 5a7837f43d..9da69b2131 100644
--- a/ArmPkg/Drivers/ArmGic/AArch64/ArmGicArchLib.c
+++ b/ArmPkg/Drivers/ArmGic/AArch64/ArmGicArchLib.c
@@ -15,6 +15,8 @@
#include <Library/ArmLib.h>
#include <Library/ArmGicLib.h>
+#include "GicV3/ArmGicV3Lib.h"
+
ARM_GIC_ARCH_REVISION
EFIAPI
ArmGicGetSupportedArchRevision (
@@ -28,7 +30,17 @@ ArmGicGetSupportedArchRevision (
// driver requires SRE. If only Memory mapped access is available we try to
// drive the GIC as a v2.
if (ArmReadIdPfr0 () & AARCH64_PFR0_GIC) {
- return ARM_GIC_ARCH_REVISION_3;
+ // Make sure System Register access is enabled (SRE). This depends on the
+ // higher privilege level giving us permission, otherwise we will either
+ // cause an exception here, or the write doesn't stick in which case we need
+ // to fall back to the GICv2 MMIO interface.
+ // Note: We do not need to set ICC_SRE_EL2.Enable because the OS is started
+ // at the same exception level.
+ // It is the OS responsibility to set this bit.
+ ArmGicV3SetControlSystemRegisterEnable (ArmGicV3GetControlSystemRegisterEnable () | ICC_SRE_EL2_SRE);
+ if (ArmGicV3GetControlSystemRegisterEnable () & ICC_SRE_EL2_SRE) {
+ return ARM_GIC_ARCH_REVISION_3;
+ }
}
return ARM_GIC_ARCH_REVISION_2;
diff --git a/ArmPkg/Drivers/ArmGic/Arm/ArmGicArchLib.c b/ArmPkg/Drivers/ArmGic/Arm/ArmGicArchLib.c
index 668858f79a..f360a40583 100644
--- a/ArmPkg/Drivers/ArmGic/Arm/ArmGicArchLib.c
+++ b/ArmPkg/Drivers/ArmGic/Arm/ArmGicArchLib.c
@@ -15,6 +15,8 @@
#include <Library/ArmLib.h>
#include <Library/ArmGicLib.h>
+#include "GicV3/ArmGicV3Lib.h"
+
ARM_GIC_ARCH_REVISION
EFIAPI
ArmGicGetSupportedArchRevision (
@@ -28,7 +30,17 @@ ArmGicGetSupportedArchRevision (
// driver requires SRE. If only Memory mapped access is available we try to
// drive the GIC as a v2.
if (ArmReadIdPfr1 () & ARM_PFR1_GIC) {
- return ARM_GIC_ARCH_REVISION_3;
+ // Make sure System Register access is enabled (SRE). This depends on the
+ // higher privilege level giving us permission, otherwise we will either
+ // cause an exception here, or the write doesn't stick in which case we need
+ // to fall back to the GICv2 MMIO interface.
+ // Note: We do not need to set ICC_SRE_EL2.Enable because the OS is started
+ // at the same exception level.
+ // It is the OS responsibility to set this bit.
+ ArmGicV3SetControlSystemRegisterEnable (ArmGicV3GetControlSystemRegisterEnable () | ICC_SRE_EL2_SRE);
+ if (ArmGicV3GetControlSystemRegisterEnable () & ICC_SRE_EL2_SRE) {
+ return ARM_GIC_ARCH_REVISION_3;
+ }
}
return ARM_GIC_ARCH_REVISION_2;
diff --git a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
index 8042f718f5..f756d30803 100644
--- a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
+++ b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
@@ -281,14 +281,6 @@ GicV3DxeInitialize (
}
}
- // Make sure System Register access is enabled (SRE). This depends on the
- // lower levels giving us permission, otherwise we will cause an exception
- // here.
- // Note: We do not need to set ICC_SRE_EL2.Enable because the OS is started at the
- // same exception level.
- // It is the OS responsibility to set this bit.
- ArmGicV3SetControlSystemRegisterEnable (ArmGicV3GetControlSystemRegisterEnable () | ICC_SRE_EL2_SRE);
-
// Set binary point reg to 0x7 (no preemption)
ArmGicV3SetBinaryPointer (0x7);