From 03d859792ef701c1e7ceb38af7b9aca02e5e4673 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 9 Oct 2024 22:01:45 -0700 Subject: [PATCH] kern: invoke supervisor mode thread functions from C++ context with valid stack frame --- .../source/arch/arm64/kern_k_thread_context.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp b/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp index b3cef675..76e91cff 100644 --- a/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp +++ b/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp @@ -21,6 +21,15 @@ namespace ams::kern::arch::arm64 { void UserModeThreadStarter(); void SupervisorModeThreadStarter(); + void InvokeSupervisorModeThread(uintptr_t argument, uintptr_t entrypoint) { + /* Invoke the function. */ + using SupervisorModeFunctionType = void (*)(uintptr_t); + reinterpret_cast(entrypoint)(argument); + + /* Wait forever. */ + AMS_INFINITE_LOOP(); + } + void OnThreadStart() { MESOSPHERE_ASSERT(!KInterruptManager::AreInterruptsEnabled()); /* Send KDebug event for this thread's creation. */