From 2490bbf4f919f5e35f7d52193d4501830e34f341 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 23 Oct 2021 17:44:30 -0700 Subject: [PATCH] kern: KCacheHelper: better reflect nintendo coremask clearing logic --- libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp b/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp index c050a3b19..6225f28a8 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp @@ -104,12 +104,12 @@ namespace ams::kern::arch::arm64::cpu { } void ThreadFunctionImpl() { - const s32 core_id = GetCurrentCoreId(); + const u64 core_mask = (1ul << GetCurrentCoreId()); while (true) { /* Wait for a request to come in. */ { KScopedLightLock lk(m_cv_lock); - while ((m_target_cores.Load() & (1ul << core_id)) == 0) { + while ((m_target_cores.Load() & core_mask) == 0) { m_cv.Wait(std::addressof(m_cv_lock)); } } @@ -120,6 +120,8 @@ namespace ams::kern::arch::arm64::cpu { /* Broadcast, if there's nothing pending. */ { KScopedLightLock lk(m_cv_lock); + + m_target_cores &= ~core_mask; if (m_target_cores.Load() == 0) { m_cv.Broadcast(); } @@ -150,6 +152,7 @@ namespace ams::kern::arch::arm64::cpu { virtual KInterruptTask *OnInterrupt(s32 interrupt_id) override { MESOSPHERE_UNUSED(interrupt_id); this->ProcessOperation(); + m_target_cores &= ~(1ul << GetCurrentCoreId()); return nullptr; } @@ -286,8 +289,6 @@ namespace ams::kern::arch::arm64::cpu { FlushDataCacheBySetWay(0); break; } - - m_target_cores &= (~(1ul << GetCurrentCoreId())); } ALWAYS_INLINE void SetEventLocally() {