diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c index eed5644552..1c60be8312 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c @@ -115,23 +115,22 @@ CommonExceptionHandler ( // Interrupt // InterruptType = GetInterruptType (SystemContext); - if (InterruptType == 0xFF) { - ExceptionType = InterruptType; - } else { + if (InterruptType != 0xFF) { if ((ExternalInterruptHandler != NULL) && (ExternalInterruptHandler[InterruptType] != NULL)) { ExternalInterruptHandler[InterruptType](InterruptType, SystemContext); return; } } - } else if (ExceptionType == EXCEPT_LOONGARCH_FPD) { - EnableFloatingPointUnits (); - InitializeFloatingPointUnits (); - return; } else { // // Exception // - ExceptionType >>= CSR_ESTAT_EXC_SHIFT; + if (ExceptionType == EXCEPT_LOONGARCH_FPD) { + EnableFloatingPointUnits (); + InitializeFloatingPointUnits (); + return; + } + if ((ExceptionHandler != NULL) && (ExceptionHandler[ExceptionType] != NULL)) { ExceptionHandler[ExceptionType](ExceptionType, SystemContext); return; diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c index 519fe1e24e..ea299475f5 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c @@ -27,7 +27,7 @@ GetExceptionType ( { EFI_EXCEPTION_TYPE ExceptionType; - ExceptionType = (SystemContext.SystemContextLoongArch64->ESTAT & CSR_ESTAT_EXC); + ExceptionType = (SystemContext.SystemContextLoongArch64->ESTAT & CSR_ESTAT_EXC) >> CSR_ESTAT_EXC_SHIFT; return ExceptionType; } diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/SecPeiExceptionLib.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/SecPeiExceptionLib.c index 7588d2050b..dc395c092c 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/SecPeiExceptionLib.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/SecPeiExceptionLib.c @@ -68,14 +68,7 @@ CommonExceptionHandler ( // IpiInterruptHandler (InterruptType, SystemContext); return; - } else { - ExceptionType = InterruptType; } - } else { - // - // Exception - // - ExceptionType >>= CSR_ESTAT_EXC_SHIFT; } DefaultExceptionHandler (ExceptionType, SystemContext);