diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_assembly_offsets.h b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_assembly_offsets.h index 410fda5d0..3ca96a713 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_assembly_offsets.h +++ b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_assembly_offsets.h @@ -23,7 +23,7 @@ #define THREAD_KERNEL_STACK_TOP 0x280 /* ams::kern::KThread::StackParameters, https://github.com/Atmosphere-NX/Atmosphere/blob/master/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp */ -#define THREAD_STACK_PARAMETERS_SIZE 0x130 +#define THREAD_STACK_PARAMETERS_SIZE 0x140 #define THREAD_STACK_PARAMETERS_SVC_PERMISSION 0x00 #define THREAD_STACK_PARAMETERS_CALLER_SAVE_FPU_REGISTERS 0x18 #define THREAD_STACK_PARAMETERS_CUR_THREAD 0x20 @@ -34,7 +34,8 @@ #define THREAD_STACK_PARAMETERS_EXCEPTION_FLAGS 0x2D #define THREAD_STACK_PARAMETERS_IS_PINNED 0x2E #define THREAD_STACK_PARAMETERS_RESERVED_2F 0x2F -#define THREAD_STACK_PARAMETERS_THREAD_CONTEXT 0x30 +#define THREAD_STACK_PARAMETERS_RESERVED_30 0x30 +#define THREAD_STACK_PARAMETERS_THREAD_CONTEXT 0x40 #define THREAD_EXCEPTION_FLAG_BIT_INDEX_IS_CALLING_SVC (0) #define THREAD_EXCEPTION_FLAG_BIT_INDEX_IS_IN_EXCEPTION_HANDLER (1) diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp index b2664d4f0..a5e8db8d1 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp @@ -108,10 +108,12 @@ namespace ams::kern { u8 exception_flags; bool is_pinned; u8 reserved_2f; + u8 reserved_30[0x10]; KThreadContext context; }; static_assert(util::IsAligned(AMS_OFFSETOF(StackParameters, context), 0x10)); + static_assert(sizeof(StackParameters) == THREAD_STACK_PARAMETERS_SIZE); static_assert(AMS_OFFSETOF(StackParameters, svc_access_flags) == THREAD_STACK_PARAMETERS_SVC_PERMISSION); static_assert(AMS_OFFSETOF(StackParameters, caller_save_fpu_registers) == THREAD_STACK_PARAMETERS_CALLER_SAVE_FPU_REGISTERS); @@ -123,8 +125,10 @@ namespace ams::kern { static_assert(AMS_OFFSETOF(StackParameters, exception_flags) == THREAD_STACK_PARAMETERS_EXCEPTION_FLAGS); static_assert(AMS_OFFSETOF(StackParameters, is_pinned) == THREAD_STACK_PARAMETERS_IS_PINNED); static_assert(AMS_OFFSETOF(StackParameters, reserved_2f) == THREAD_STACK_PARAMETERS_RESERVED_2F); + static_assert(AMS_OFFSETOF(StackParameters, reserved_30) == THREAD_STACK_PARAMETERS_RESERVED_30); static_assert(AMS_OFFSETOF(StackParameters, context) == THREAD_STACK_PARAMETERS_THREAD_CONTEXT); + static_assert(ExceptionFlag_IsCallingSvc == THREAD_EXCEPTION_FLAG_IS_CALLING_SVC); static_assert(ExceptionFlag_IsInExceptionHandler == THREAD_EXCEPTION_FLAG_IS_IN_EXCEPTION_HANDLER); static_assert(ExceptionFlag_IsFpuContextRestoreNeeded == THREAD_EXCEPTION_FLAG_IS_FPU_CONTEXT_RESTORE_NEEDED); diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp index 321f43565..926300601 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp @@ -96,8 +96,8 @@ namespace ams::kern::arch::arm64 { /* SP */ /* | */ /* v */ - /* | u64 argument | u64 entrypoint | KThread::StackParameters (size 0x130) | */ - static_assert(sizeof(KThread::StackParameters) == 0x130); + /* | u64 argument | u64 entrypoint | KThread::StackParameters (size 0x140) | */ + static_assert(sizeof(KThread::StackParameters) == 0x140); u64 *stack = GetPointer(sp); *(--stack) = GetInteger(pc);