diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_scheduler.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_scheduler.hpp index c1048ef16..f555f7837 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_scheduler.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_scheduler.hpp @@ -70,6 +70,11 @@ namespace ams::kern { NOINLINE void Initialize(KThread *idle_thread); NOINLINE void Activate(); + ALWAYS_INLINE void SetInterruptTaskRunnable() { + this->state.interrupt_task_thread_runnable = true; + this->state.needs_scheduling = true; + } + ALWAYS_INLINE void RequestScheduleOnInterrupt() { SetSchedulerUpdateNeeded(); @@ -85,13 +90,13 @@ namespace ams::kern { static ALWAYS_INLINE KSchedulerPriorityQueue &GetPriorityQueue() { return s_priority_queue; } static NOINLINE u64 UpdateHighestPriorityThreadsImpl(); + + static NOINLINE void InterruptTaskThreadToRunnable(); public: /* Static public API. */ static ALWAYS_INLINE bool CanSchedule() { return GetCurrentThread().GetDisableDispatchCount() == 0; } static ALWAYS_INLINE bool IsSchedulerLockedByCurrentThread() { return s_scheduler_lock.IsLockedByCurrentThread(); } - static NOINLINE void SetInterruptTaskThreadRunnable(); - static ALWAYS_INLINE void DisableScheduling() { MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() >= 0); GetCurrentThread().DisableDispatch(); diff --git a/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp b/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp index 37fefefb4..b56945781 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp @@ -38,6 +38,8 @@ namespace ams::kern::arch::arm64 { KProcess *cur_process = GetCurrentProcessPointer(); bool should_process_user_exception = KTargetSystem::IsUserExceptionHandlersEnabled(); + MESOSPHERE_LOG("User Exception occurred in %s\n", cur_process->GetName()); + const u64 ec = (esr >> 26) & 0x3F; switch (ec) { case 0x0: /* Unknown */ diff --git a/libraries/libmesosphere/source/kern_k_interrupt_task_manager.cpp b/libraries/libmesosphere/source/kern_k_interrupt_task_manager.cpp index 83722e1b4..492516a25 100644 --- a/libraries/libmesosphere/source/kern_k_interrupt_task_manager.cpp +++ b/libraries/libmesosphere/source/kern_k_interrupt_task_manager.cpp @@ -91,7 +91,7 @@ namespace ams::kern { /* Enqueue the task and signal the scheduler. */ this->task_queue.Enqueue(task); - Kernel::GetScheduler().SetInterruptTaskThreadRunnable(); + Kernel::GetScheduler().SetInterruptTaskRunnable(); } } diff --git a/libraries/libmesosphere/source/kern_k_scheduler.cpp b/libraries/libmesosphere/source/kern_k_scheduler.cpp index b98aa4490..46bfc8957 100644 --- a/libraries/libmesosphere/source/kern_k_scheduler.cpp +++ b/libraries/libmesosphere/source/kern_k_scheduler.cpp @@ -199,7 +199,7 @@ namespace ams::kern { return cores_needing_scheduling; } - void KScheduler::SetInterruptTaskThreadRunnable() { + void KScheduler::InterruptTaskThreadToRunnable() { MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() == 1); KThread *task_thread = Kernel::GetInterruptTaskManager().GetThread(); @@ -252,7 +252,7 @@ namespace ams::kern { /* Switch the current process, if we're switching processes. */ if (KProcess *next_process = next_thread->GetOwnerProcess(); next_process != cur_process) { - MESOSPHERE_LOG("!!! PROCESS SWITCH !!! %s -> %s\n", cur_process != nullptr ? cur_process->GetName() : nullptr, next_process != nullptr ? next_process->GetName() : nullptr); + /* MESOSPHERE_LOG("!!! PROCESS SWITCH !!! %s -> %s\n", cur_process != nullptr ? cur_process->GetName() : nullptr, next_process != nullptr ? next_process->GetName() : nullptr); */ KProcess::Switch(cur_process, next_process); } diff --git a/libraries/libmesosphere/source/kern_panic.cpp b/libraries/libmesosphere/source/kern_panic.cpp index a60e88093..fc4322e7d 100644 --- a/libraries/libmesosphere/source/kern_panic.cpp +++ b/libraries/libmesosphere/source/kern_panic.cpp @@ -120,6 +120,9 @@ namespace ams::kern { ::std::va_list vl; va_start(vl, format); MESOSPHERE_RELEASE_LOG("Core[%d]: Kernel Panic at %s:%d\n", GetCurrentCoreId(), file, line); + if (KProcess *cur_process = GetCurrentProcessPointer(); cur_process != nullptr) { + MESOSPHERE_RELEASE_LOG("Core[%d]: Current Process: %s\n", GetCurrentCoreId(), cur_process->GetName()); + } MESOSPHERE_RELEASE_VLOG(format, vl); MESOSPHERE_RELEASE_LOG("\n"); va_end(vl); diff --git a/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s b/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s index 8d860876d..64e27a656 100644 --- a/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s +++ b/mesosphere/kernel/source/arch/arm64/kern_k_scheduler_asm.s @@ -115,10 +115,10 @@ _ZN3ams4kern10KScheduler12ScheduleImplEv: ldrb w3, [x1, #1] cbz w3, 0f - /* If it is, we want to call KScheduler::SetInterruptTaskThreadRunnable() to note it runnable. */ + /* If it is, we want to call KScheduler::InterruptTaskThreadToRunnable() to change its state to runnable. */ stp x0, x1, [sp, #-16]! stp x30, xzr, [sp, #-16]! - bl _ZN3ams4kern10KScheduler30SetInterruptTaskThreadRunnableEv + bl _ZN3ams4kern10KScheduler29InterruptTaskThreadToRunnableEv ldp x30, xzr, [sp], 16 ldp x0, x1, [sp], 16 @@ -271,7 +271,7 @@ _ZN3ams4kern10KScheduler12ScheduleImplEv: cbz w3, 4b /* It does, so do so. We're using the idle thread stack so no register state preserve needed. */ - bl _ZN3ams4kern10KScheduler30SetInterruptTaskThreadRunnableEv + bl _ZN3ams4kern10KScheduler29InterruptTaskThreadToRunnableEv /* Clear the interrupt task thread as runnable. */ strb wzr, [x20, #1]