summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Li <lichao@loongson.cn>2024-12-18 10:45:24 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-12-23 03:18:13 +0000
commit0fdffb71df7c99301c6430a95af207159cbe9655 (patch)
treea797cdaa32db706a8b34e45c447f798576c34d8b
parentfbbf4206c13e95d54ace7646d508523adae4b126 (diff)
downloadedk2-0fdffb71df7c99301c6430a95af207159cbe9655.tar.gz
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>
-rw-r--r--UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/DxeExceptionLib.c15
-rw-r--r--UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/LoongArch64/ArchExceptionHandler.c2
-rw-r--r--UefiCpuPkg/Library/CpuExceptionHandlerLib/LoongArch/SecPeiExceptionLib.c7
3 files changed, 8 insertions, 16 deletions
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);