bunnei
cc4cbff1ca
hle: kernel: KThread: Rename thread_type_for_debugging -> thread_type.
...
- This will be used to ensure that we do not schedule dummy threads.
2022-01-20 17:08:00 -08:00
bunnei
70b2b91f71
Merge pull request #7701 from bunnei/clear-mem-pages
...
Kernel Memory Updates (Part 3): Clear KMemoryManager pages & other fixes
2022-01-18 21:20:42 -08:00
bunnei
74407b1348
Merge pull request #7712 from bunnei/fix-thread-exit
...
Accurately implement thread exit
2022-01-17 18:08:24 -08:00
Valeri
01852ee857
hle: remove no-op code
...
Found by static analysis with PVS-Studio. Nobody seems to really know what was it doing there.
2022-01-17 13:51:12 +03:00
bunnei
4148fde355
hle: kernel: k_memory_manager: Clear pages on allocation & free.
...
- Heap pages should be zero'd.
- Also explicitly passed along heap allocation option.
2022-01-14 21:16:33 -08:00
bunnei
b52516263d
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.
2022-01-14 16:44:14 -08:00
bunnei
18969b5d8e
core: hle: kernel: KProcess: Integrate with KWorkerTask and add unimplemented DoWorkerTaskImpl.
2022-01-14 16:44:14 -08:00
bunnei
914431487b
core: hle: kernel: KThread: Replace Suspend with UpdateState & various updates.
...
- This makes our implementations of these more closely match HOS.
2022-01-14 16:44:14 -08:00
bunnei
b6bf119a43
core: hle: kernel: Instantiate a kernel instance of KWorkerTaskManager.
2022-01-14 16:44:14 -08:00
bunnei
b722faaf7a
core: hle: kernel: Add KWorkerTask and KWorkerTaskManager.
...
- These primitives are used to dispatch asynchronous kernel tasks from KThread and KProcess.
2022-01-14 16:43:59 -08:00
bunnei
fbab3dc017
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.
2022-01-14 16:02:57 -08:00
Mai M
8fb335ff3f
Merge pull request #7699 from bunnei/fix-service-thread-race
...
hle: kernel: Fix service_threads access to be thread safe.
2022-01-14 00:46:16 -05:00
bunnei
ef9186172f
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.
2022-01-13 21:26:10 -08:00
bunnei
d45b65b4d9
hle: kernel: k_page_table: Update SetProcessMemoryPermission.
2022-01-11 16:28:11 -08:00
bunnei
84a61db25b
hle: kernel: k_page_table: ReadAndWrite -> UserReadWrite.
2022-01-11 16:28:11 -08:00
bunnei
0942533d2f
hle: kernel: k_page_table: Rename *ProcessCodeMemory -> *CodeMemory.
2022-01-11 16:28:11 -08:00
bunnei
b227426ae5
core: hle: kernel: svc: Updates to SetMemoryAttribute and SetMemoryPermission.
2022-01-08 12:18:14 -08:00
bunnei
090f1c400e
core: hle: kernel: k_page_table: Update CheckMemoryState.
2022-01-08 03:20:57 -08:00
bunnei
b12695ddc4
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 .
2021-12-30 15:50:45 -08:00
bunnei
714dcea191
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 .
2021-12-28 01:25:20 -08:00
bunnei
5217285536
Merge pull request #7621 from bunnei/set-mem-perm
...
core: hle: kernel: Implement SetMemoryPermission.
2021-12-27 23:33:11 -08:00
bunnei
555481005d
core: hle: kernel: Implement SetMemoryPermission.
...
- Not seen in any games yet, but validated with kernel tests.
2021-12-23 01:10:36 -08:00
bunnei
bc45d0fc1a
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.
2021-12-23 00:03:39 -08:00
bunnei
a1f637a6d0
hle: kernel: svc: GetInfo: Fix error checking with IdleTickCount.
...
- Enforce tha the supplied handle is invalid, not valid.
- This gets Witcher 3 booting.
2021-12-21 22:41:23 -08:00
bunnei
3f3eb16bc9
Merge pull request #7597 from bunnei/remove-global-lock
...
core: hle: Remove global HLE lock.
2021-12-20 14:24:50 -08:00
ameerj
1fff9ea35e
kernel: Manually destroy the current process during shut down
...
Avoids a memory leak.
2021-12-19 01:38:25 -05:00
bunnei
5192e8e092
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.
2021-12-17 16:05:51 -08:00
Valeri
295b676fe6
Remove erroneous #pragma once
2021-12-13 16:49:01 +03:00
bunnei
5273e0665e
Merge pull request #7462 from bunnei/kernel-improve-scheduling
...
Kernel: Improve threading & scheduling V3
2021-12-12 22:43:25 -08:00
itsmeft24
9a28199c5a
Update k_code_memory.h
2021-12-07 16:58:23 -05:00
itsmeft24
4b0b2d7d1d
make KCodeMemory::GetSourceAddress const
...
Co-authored-by: Mai M. <mathew1800@gmail.com>
2021-12-07 07:58:33 -05:00
bunnei
5788e077cd
hle: kernel k_scheduler: EnableScheduling: Remove redundant GetCurrentThreadPointer calls.
2021-12-06 16:39:18 -08:00
bunnei
1b1ed86ec7
hle: kernel k_process: Remove unnecessary .at usage with thread pinning methods.
2021-12-06 16:39:18 -08:00
bunnei
38a6477770
hle: kernel: Remove unnecessary virtual specifier on NotifyAvailable.
2021-12-06 16:39:18 -08:00
bunnei
829c4b6144
hle: kernel: Remove unnecessary virtual specifier on EndWait.
2021-12-06 16:39:18 -08:00
bunnei
1457a75a40
hle: kernel: k_light_condition_variable: Revert unnecessary license comment changes.
2021-12-06 16:39:18 -08:00
bunnei
cd4582dc8b
hle: kernel: k_condition_variable: Revert unnecessary style changes.
2021-12-06 16:39:18 -08:00
bunnei
4b2aa52da9
hle: kernel: Remove unnecessary virtual specifier on CancelWait.
2021-12-06 16:39:18 -08:00
bunnei
273223d5f1
hle: kernel: service_thread: Force stop threads on destruction.
2021-12-06 16:39:18 -08:00
bunnei
0231cbd79f
hle: kernel: k_light_lock: Implement CancelWait.
...
- Fixes a crash in Megadimension Neptunia VII.
2021-12-06 16:39:18 -08:00
bunnei
d17b7268f6
hle: kernel: service_thread: Use std::jthread.
...
- Fixes a potential deadlock on service thread shutdown.
2021-12-06 16:39:18 -08:00
bunnei
b5970145a5
hle: kernel: k_thread: Skip reschedule on DisableDispatch with SC.
2021-12-06 16:39:18 -08:00
bunnei
6d2bf18df9
hle: kernel: k_thread: Rename sleeping_queue -> wait_queue.
2021-12-06 16:39:18 -08:00
bunnei
43d706c7d2
hle: kernel: svc: Fix deadlock that can occur with single core.
2021-12-06 16:39:18 -08:00
bunnei
826b07162a
hle: kernel: k_thread: Treat dummy threads as a special type.
2021-12-06 16:39:18 -08:00
FernandoS27
8a38790bd3
hle: kernel: fix timing on thread preemption
2021-12-06 16:39:18 -08:00
FernandoS27
2a7b4489a0
hle: kernel: fix scheduling ops from HLE host thread.
2021-12-06 16:39:17 -08:00
bunnei
58da4d5a6e
hle: kernel: Add a flag for indicating that the kernel is currently shutting down.
2021-12-06 16:39:17 -08:00
bunnei
975a4f786b
hle: kernel: KSynchronizationObject: Fix variable shadowing.
2021-12-06 16:39:17 -08:00
bunnei
eb34276885
hle: kernel: Cleanup to match coding style.
2021-12-06 16:39:17 -08:00