bunnei
46a620f9d7
hle: kernel: KThread: Decrease DummyThread priority to ensure it is never scheduled.
4 years ago
bunnei
0b37e7cb39
hle: kernel: service_thread: Ensure dummy thread is closed & destroyed on thread exit.
4 years ago
bunnei
384e24d3e9
hle: kernel: KServerSession: Remove hack for CompleteSyncRequest.
- This does not appear to be necessary anymore.
4 years ago
bunnei
ad53dc22fd
hle: kernel: KServerSession: Simplify CompleteSyncRequest EndWait.
- Considering is_thread_waiting is never set, so we can remove IsThreadWaiting.
- KThread::EndWait will take the scheduler lock, so we can remove the redundant lock.
4 years ago
bunnei
5ffec69dc7
hle: kernel: KThread: Ensure dummy threads never call EndWait.
- These are only used by host threads for locking and will never have a wait_queue.
4 years ago
bunnei
11a380c3da
hle: kernel: KScheduler: Ensure dummy threads are never scheduled.
- These are only used by host threads for locking.
4 years ago
bunnei
f6cbb14dce
hle: kernel: KThread: Rename thread_type_for_debugging -> thread_type.
- This will be used to ensure that we do not schedule dummy threads.
4 years ago
Valeri
84786dde00
hle: remove no-op code
Found by static analysis with PVS-Studio. Nobody seems to really know what was it doing there.
4 years ago
bunnei
b54cbc985e
hle: kernel: k_memory_manager: Clear pages on allocation & free.
- Heap pages should be zero'd.
- Also explicitly passed along heap allocation option.
4 years ago
bunnei
f499c8177e
core: hle: kernel: KThread: Integrate with KWorkerTask and implement DoWorkerTaskImpl.
- This is used to terminate a thread asynchronously after it has been exited.
- This fixes a crash that can occur in Pokemon Sword/Shield because a thread is incorrectly closed on svcExitThread, then, the thread is destroyed on svcCloseHandle while it is still scheduled.
- Instead, we now wait for the thread to no longer be scheduled on all cores before destroying it from KWorkerTaskManager, which is accurate to HOS behavior.
4 years ago
bunnei
d8b3f665db
core: hle: kernel: KProcess: Integrate with KWorkerTask and add unimplemented DoWorkerTaskImpl.
4 years ago
bunnei
03884b7ea6
core: hle: kernel: KThread: Replace Suspend with UpdateState & various updates.
- This makes our implementations of these more closely match HOS.
4 years ago
bunnei
c905044e1b
core: hle: kernel: Instantiate a kernel instance of KWorkerTaskManager.
4 years ago
bunnei
bf32fcc817
core: hle: kernel: Add KWorkerTask and KWorkerTaskManager.
- These primitives are used to dispatch asynchronous kernel tasks from KThread and KProcess.
4 years ago
bunnei
cc112f971e
hle: kernel: Fix service_threads access to be thread safe V2.
- PR #7699 attempted to fix CreateServiceThread and ReleaseServiceThread to be thread safe, but inadvertently introduced a possible dead-lock.
- With this PR, we use a worker thread to manage the service thread list, allowing it only to be accessed by a single thread, and guaranteeing threads will not destroy themselves.
- Fixes a rare crash in Pokemon Sword/Shield, I've now run this game for ~12 hours non-stop and am quite confident this is a good solution for this issue.
4 years ago
bunnei
2147240e47
hle: kernel: Fix service_threads access to be thread safe.
- CreateServiceThread and ReleaseServiceThread can be accessed by different threads, uses a lock to make this thread safe.
- Fixes a rare crash in Pokemon Sword/Shield that can occur when a new service thread is being created while an old one is being destroyed.
4 years ago
bunnei
49a0e4330e
hle: kernel: k_page_table: Update SetProcessMemoryPermission.
4 years ago
bunnei
6123b6ea45
hle: kernel: k_page_table: ReadAndWrite -> UserReadWrite.
4 years ago
bunnei
081669c334
hle: kernel: k_page_table: Rename *ProcessCodeMemory -> *CodeMemory.
4 years ago
bunnei
af4696657c
core: hle: kernel: svc: Updates to SetMemoryAttribute and SetMemoryPermission.
4 years ago
bunnei
b9a313057e
core: hle: kernel: k_page_table: Update CheckMemoryState.
4 years ago
bunnei
3a89723d97
core: hle: kernel: Implement thread pinning.
- We largely had the mechanics in place for thread pinning, this change hooks these up.
- Validated with tests https://github.com/Atmosphere-NX/Atmosphere/blob/master/tests/TestSvc/source/test_thread_pinning.cpp .
4 years ago
bunnei
091463a429
core: hle: kernel: Updated implementation of svcSetHeapSize.
- Updates our svcSetHeapSize with latest HOS, furthermore allowing heap size to properly be extended/shrunk.
- Validated with tests https://github.com/Atmosphere-NX/Atmosphere/blob/master/tests/TestSvc/source/test_set_heap_size.cpp .
4 years ago
bunnei
4e7a6639d2
core: hle: kernel: Implement SetMemoryPermission.
- Not seen in any games yet, but validated with kernel tests.
4 years ago
bunnei
a0c7d93b84
core: hle: kernel: KThread: X18 should be a cryptographically random number.
- This was added with firmware 11.0.0 (https://switchbrew.org/wiki/11.0.0 ).
- X18 is OR'd by kernel with 1, to make sure it is odd.
4 years ago
bunnei
49e3c073a5
hle: kernel: svc: GetInfo: Fix error checking with IdleTickCount.
- Enforce tha the supplied handle is invalid, not valid.
- This gets Witcher 3 booting.
4 years ago
ameerj
55650c5b75
kernel: Manually destroy the current process during shut down
Avoids a memory leak.
4 years ago
bunnei
c73841500a
core: hle: Remove global HLE lock.
- This was added early on as a hack to protect against some concurrency issues.
- It's not clear that this serves any purpose anymore, and if it does, individual components should be fixed rather than using a global recursive mutex.
4 years ago
Valeri
04301e1a8a
Remove erroneous #pragma once
4 years ago
itsmeft24
e05c86aa3c
Update k_code_memory.h
4 years ago
itsmeft24
d197246880
make KCodeMemory::GetSourceAddress const
Co-authored-by: Mai M. <mathew1800@gmail.com>
4 years ago
bunnei
257d3c9ecf
hle: kernel k_scheduler: EnableScheduling: Remove redundant GetCurrentThreadPointer calls.
4 years ago
bunnei
9a9e7dd78b
hle: kernel k_process: Remove unnecessary .at usage with thread pinning methods.
4 years ago
bunnei
834c25f4d9
hle: kernel: Remove unnecessary virtual specifier on NotifyAvailable.
4 years ago
bunnei
a63af9860b
hle: kernel: Remove unnecessary virtual specifier on EndWait.
4 years ago
bunnei
3f8eb44e7d
hle: kernel: k_light_condition_variable: Revert unnecessary license comment changes.
4 years ago
bunnei
2e8d737a96
hle: kernel: k_condition_variable: Revert unnecessary style changes.
4 years ago
bunnei
0d1bdfc1d4
hle: kernel: Remove unnecessary virtual specifier on CancelWait.
4 years ago
bunnei
d7f6d516ce
hle: kernel: service_thread: Force stop threads on destruction.
4 years ago
bunnei
e596fac6ee
hle: kernel: k_light_lock: Implement CancelWait.
- Fixes a crash in Megadimension Neptunia VII.
4 years ago
bunnei
efb5de1c5f
hle: kernel: service_thread: Use std::jthread.
- Fixes a potential deadlock on service thread shutdown.
5 years ago
bunnei
a2384a18fa
hle: kernel: k_thread: Skip reschedule on DisableDispatch with SC.
5 years ago
bunnei
42697527ba
hle: kernel: k_thread: Rename sleeping_queue -> wait_queue.
5 years ago
bunnei
e3d156ab0e
hle: kernel: svc: Fix deadlock that can occur with single core.
5 years ago
bunnei
0d9afdedc4
hle: kernel: k_thread: Treat dummy threads as a special type.
5 years ago
FernandoS27
894ed14ebc
hle: kernel: fix timing on thread preemption
5 years ago
FernandoS27
3c2a451f47
hle: kernel: fix scheduling ops from HLE host thread.
5 years ago
bunnei
abbea575cf
hle: kernel: Add a flag for indicating that the kernel is currently shutting down.
5 years ago
bunnei
2c49a65d2b
hle: kernel: KSynchronizationObject: Fix variable shadowing.
5 years ago
bunnei
8f4ff06c4c
hle: kernel: Cleanup to match coding style.
5 years ago