From 48e86f0406712ea268f96f8c6068e538fb9c064d Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 28 Mar 2024 02:52:32 -0700 Subject: [PATCH] kern: return ExceptionType_UnalignedData on data abort caused by alignment fault --- .../source/arch/arm64/kern_exception_handlers.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp b/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp index c5d319811..d55e217e3 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp @@ -223,6 +223,13 @@ namespace ams::kern::arch::arm64 { type = ams::svc::ExceptionType_InstructionAbort; break; case EsrEc_DataAbortEl0: + /* If esr.IFSC is "Alignment Fault", return UnalignedData instead of DataAbort. */ + if ((esr & 0x3F) == 0b100001) { + type = ams::svc::ExceptionType_UnalignedData; + } else { + type = ams::svc::ExceptionType_DataAbort; + } + break; default: type = ams::svc::ExceptionType_DataAbort; break;