From eecf59dd0077f3cd9d7d2d2addc6dfe3009f2dbb Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 22 Jul 2020 18:03:12 -0700 Subject: [PATCH] kern: fix bugs in interrupt permittance, DpcManager init --- .../include/mesosphere/kern_k_capabilities.hpp | 2 +- .../source/board/nintendo/nx/kern_k_system_control.cpp | 6 ------ libraries/libmesosphere/source/kern_k_dpc_manager.cpp | 4 ++-- libraries/libmesosphere/source/svc/kern_svc_lock.cpp | 2 -- libraries/libmesosphere/source/svc/kern_svc_memory.cpp | 3 --- 5 files changed, 3 insertions(+), 14 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_capabilities.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_capabilities.hpp index 6dff162d6..f8f022b94 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_capabilities.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_capabilities.hpp @@ -233,7 +233,7 @@ namespace ams::kern { bool SetInterruptPermitted(u32 id) { constexpr size_t BitsPerWord = BITSIZEOF(this->irq_access_flags[0]); if (id < BITSIZEOF(this->irq_access_flags)) { - this->irq_access_flags[id / BitsPerWord] = (1ul << (id % BitsPerWord)); + this->irq_access_flags[id / BitsPerWord] |= (1ul << (id % BitsPerWord)); return true; } else { return false; diff --git a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp index 001f525e6..4adaa63f2 100644 --- a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp +++ b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_system_control.cpp @@ -431,8 +431,6 @@ namespace ams::kern::board::nintendo::nx { /* Get the function id for the current call. */ u64 function_id = args->r[0]; - MESOSPHERE_LOG("CallSecureMonitor(%lx, %lx, %lx, %lx, %lx, %lx, %lx, %lx);\n", args->r[0], args->r[1], args->r[2], args->r[3], args->r[4], args->r[5], args->r[6], args->r[7]); - /* We'll need to map in pages if arguments are pointers. Prepare page groups to do so. */ auto &page_table = GetCurrentProcess().GetPageTable(); auto *bim = page_table.GetBlockInfoManager(); @@ -455,10 +453,8 @@ namespace ams::kern::board::nintendo::nx { KPhysicalAddress phys_addr = page_table.GetHeapPhysicalAddress(it->GetAddress()); args->r[reg_id] = GetInteger(phys_addr) | (GetInteger(virt_addr) & (PageSize - 1)); - MESOSPHERE_LOG("Mapped arg %zu\n", reg_id); } else { /* If we couldn't map, we should clear the address. */ - MESOSPHERE_LOG("Failed to map arg %zu\n", reg_id); args->r[reg_id] = 0; } } @@ -467,8 +463,6 @@ namespace ams::kern::board::nintendo::nx { /* Invoke the secure monitor. */ smc::CallSecureMonitorFromUser(args); - MESOSPHERE_LOG("Secure Monitor Returned: (%lx, %lx, %lx, %lx, %lx, %lx, %lx, %lx);\n", args->r[0], args->r[1], args->r[2], args->r[3], args->r[4], args->r[5], args->r[6], args->r[7]); - /* Make sure that we close any pages that we opened. */ for (size_t i = 0; i < MaxMappedRegisters; i++) { page_groups[i].Close(); diff --git a/libraries/libmesosphere/source/kern_k_dpc_manager.cpp b/libraries/libmesosphere/source/kern_k_dpc_manager.cpp index bef4397aa..1113d5590 100644 --- a/libraries/libmesosphere/source/kern_k_dpc_manager.cpp +++ b/libraries/libmesosphere/source/kern_k_dpc_manager.cpp @@ -126,9 +126,9 @@ namespace ams::kern { /* Launch the new thread. */ g_preemption_priorities[core_id] = priority; if (core_id == cpu::NumCores - 1) { - MESOSPHERE_R_ABORT_UNLESS(KThread::InitializeKernelThread(new_thread, DpcManagerNormalThreadFunction, 0, DpcManagerThreadPriority, core_id)); - } else { MESOSPHERE_R_ABORT_UNLESS(KThread::InitializeKernelThread(new_thread, DpcManagerPreemptionThreadFunction, 0, DpcManagerThreadPriority, core_id)); + } else { + MESOSPHERE_R_ABORT_UNLESS(KThread::InitializeKernelThread(new_thread, DpcManagerNormalThreadFunction, 0, DpcManagerThreadPriority, core_id)); } /* Register the new thread. */ diff --git a/libraries/libmesosphere/source/svc/kern_svc_lock.cpp b/libraries/libmesosphere/source/svc/kern_svc_lock.cpp index a0e02deb1..32c6a67b1 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_lock.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_lock.cpp @@ -30,7 +30,6 @@ namespace ams::kern::svc { R_UNLESS(!IsKernelAddress(address), svc::ResultInvalidCurrentMemory()); R_UNLESS(util::IsAligned(address, sizeof(u32)), svc::ResultInvalidAddress()); - MESOSPHERE_LOG("%lx: ArbitrateLock(%08x, %lx, %08x)\n", GetCurrentThread().GetId(), thread_handle, address, tag); return GetCurrentProcess().WaitForAddress(thread_handle, address, tag); } @@ -39,7 +38,6 @@ namespace ams::kern::svc { R_UNLESS(!IsKernelAddress(address), svc::ResultInvalidCurrentMemory()); R_UNLESS(util::IsAligned(address, sizeof(u32)), svc::ResultInvalidAddress()); - MESOSPHERE_LOG("%lx: ArbitrateUnlock(%lx)\n", GetCurrentThread().GetId(), address); return GetCurrentProcess().SignalToAddress(address); } diff --git a/libraries/libmesosphere/source/svc/kern_svc_memory.cpp b/libraries/libmesosphere/source/svc/kern_svc_memory.cpp index dc6b643c1..e15bd6bcb 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_memory.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_memory.cpp @@ -22,9 +22,6 @@ namespace ams::kern::svc { namespace { Result MapMemory(uintptr_t dst_address, uintptr_t src_address, size_t size) { - /* Log the call parameters for debugging. */ - MESOSPHERE_LOG("MapMemory(%zx, %zx, %zx)\n", dst_address, src_address, size); - /* Validate that addresses are page aligned. */ R_UNLESS(util::IsAligned(dst_address, PageSize), svc::ResultInvalidAddress()); R_UNLESS(util::IsAligned(src_address, PageSize), svc::ResultInvalidAddress());