summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKun Qin <kuqin@microsoft.com>2024-10-10 15:48:31 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-12-11 18:21:29 +0000
commite8b7d7a238e89992c029d951d10c40730f0deeab (patch)
treea0f0a0ba5036ee6ffa017f6c5a6adbfb823bea58
parentb689c387e21b6624ed1067ccfa7d2eeadca059df (diff)
downloadedk2-e8b7d7a238e89992c029d951d10c40730f0deeab.tar.gz
ArmPkg: ArmExceptionLib: Fixing exception vector and type casting
The current VectorBase is taking value from a 64bit PCD into a UINTN value, which could have truncated value for 32bit system. In addition, the comparison between UINTN and INTN could lead to undesired comparison outcome or compiler complaints. This change updates all of them to be UINT64 based operation. Cc: Leif Lindholm <quic_llindhol@quicinc.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Kun Qin <kun.qin@microsoft.com>
-rw-r--r--ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
index a521c33f32..03ed24794a 100644
--- a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
+++ b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
@@ -91,7 +91,7 @@ InitializeCpuExceptionHandlers (
)
{
RETURN_STATUS Status;
- UINTN VectorBase;
+ UINT64 VectorBase;
Status = EFI_SUCCESS;
@@ -113,7 +113,7 @@ InitializeCpuExceptionHandlers (
// We do not copy the Exception Table at PcdGet64(PcdCpuVectorBaseAddress). We just set Vector
// Base Address to point into CpuDxe code.
- VectorBase = (UINTN)ExceptionHandlersStart;
+ VectorBase = (UINT64)(UINTN)ExceptionHandlersStart;
Status = RETURN_SUCCESS;
}
@@ -121,9 +121,9 @@ InitializeCpuExceptionHandlers (
if (!RETURN_ERROR (Status)) {
// call the architecture-specific routine to prepare for the new vector
// configuration to take effect
- ArchVectorConfig (VectorBase);
+ ArchVectorConfig ((UINTN)VectorBase);
- ArmWriteVBar (VectorBase);
+ ArmWriteVBar ((UINTN)VectorBase);
}
return RETURN_SUCCESS;
@@ -172,7 +172,7 @@ CopyExceptionHandlers (
}
// Copy our assembly code into the page that contains the exception vectors.
- CopyMem ((VOID *)VectorBase, (VOID *)ExceptionHandlersStart, Length);
+ CopyMem ((VOID *)VectorBase, (VOID *)(UINTN)ExceptionHandlersStart, Length);
//
// Initialize the C entry points for interrupts
@@ -226,7 +226,7 @@ RegisterCpuInterruptHandler (
IN EFI_CPU_INTERRUPT_HANDLER ExceptionHandler
)
{
- if (ExceptionType > gMaxExceptionNumber) {
+ if ((UINTN)ExceptionType > gMaxExceptionNumber) {
return RETURN_UNSUPPORTED;
}
@@ -273,7 +273,7 @@ CommonCExceptionHandler (
IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
- if (ExceptionType <= gMaxExceptionNumber) {
+ if ((UINTN)ExceptionType <= gMaxExceptionNumber) {
if (gExceptionHandlers[ExceptionType]) {
gExceptionHandlers[ExceptionType](ExceptionType, SystemContext);
return;