UefiCpuPkg: Adjust the exception handler logic on LoongArch64

There is a problem with LoongArch64 exception handler, it returns a
unhandled value when we get an exception type, the correct value should
be right shifted 16 bits, so fix it.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
This commit is contained in:
Chao Li 2024-12-18 10:45:24 +08:00 committed by mergify[bot]
parent fbbf4206c1
commit 0fdffb71df
3 changed files with 8 additions and 16 deletions

View File

@ -115,23 +115,22 @@ CommonExceptionHandler (
// Interrupt // Interrupt
// //
InterruptType = GetInterruptType (SystemContext); InterruptType = GetInterruptType (SystemContext);
if (InterruptType == 0xFF) { if (InterruptType != 0xFF) {
ExceptionType = InterruptType;
} else {
if ((ExternalInterruptHandler != NULL) && (ExternalInterruptHandler[InterruptType] != NULL)) { if ((ExternalInterruptHandler != NULL) && (ExternalInterruptHandler[InterruptType] != NULL)) {
ExternalInterruptHandler[InterruptType](InterruptType, SystemContext); ExternalInterruptHandler[InterruptType](InterruptType, SystemContext);
return; return;
} }
} }
} else if (ExceptionType == EXCEPT_LOONGARCH_FPD) {
EnableFloatingPointUnits ();
InitializeFloatingPointUnits ();
return;
} else { } else {
// //
// Exception // Exception
// //
ExceptionType >>= CSR_ESTAT_EXC_SHIFT; if (ExceptionType == EXCEPT_LOONGARCH_FPD) {
EnableFloatingPointUnits ();
InitializeFloatingPointUnits ();
return;
}
if ((ExceptionHandler != NULL) && (ExceptionHandler[ExceptionType] != NULL)) { if ((ExceptionHandler != NULL) && (ExceptionHandler[ExceptionType] != NULL)) {
ExceptionHandler[ExceptionType](ExceptionType, SystemContext); ExceptionHandler[ExceptionType](ExceptionType, SystemContext);
return; return;

View File

@ -27,7 +27,7 @@ GetExceptionType (
{ {
EFI_EXCEPTION_TYPE ExceptionType; EFI_EXCEPTION_TYPE ExceptionType;
ExceptionType = (SystemContext.SystemContextLoongArch64->ESTAT & CSR_ESTAT_EXC); ExceptionType = (SystemContext.SystemContextLoongArch64->ESTAT & CSR_ESTAT_EXC) >> CSR_ESTAT_EXC_SHIFT;
return ExceptionType; return ExceptionType;
} }

View File

@ -68,14 +68,7 @@ CommonExceptionHandler (
// //
IpiInterruptHandler (InterruptType, SystemContext); IpiInterruptHandler (InterruptType, SystemContext);
return; return;
} else {
ExceptionType = InterruptType;
} }
} else {
//
// Exception
//
ExceptionType >>= CSR_ESTAT_EXC_SHIFT;
} }
DefaultExceptionHandler (ExceptionType, SystemContext); DefaultExceptionHandler (ExceptionType, SystemContext);