diff options
| author | 2020-03-03 11:04:37 -0400 | |
|---|---|---|
| committer | 2020-06-27 11:35:21 -0400 | |
| commit | de5b521c0900bbd4d7012ffa3dfd63cc8f3d4371 (patch) | |
| tree | 94658db3f559c6bdda21a4306620d5cacb2cdf6d /src/core/hle/kernel/process.cpp | |
| parent | General: Add Asserts (diff) | |
| download | yuzu-de5b521c0900bbd4d7012ffa3dfd63cc8f3d4371.tar.gz yuzu-de5b521c0900bbd4d7012ffa3dfd63cc8f3d4371.tar.xz yuzu-de5b521c0900bbd4d7012ffa3dfd63cc8f3d4371.zip | |
Process: Protect TLS region and Modules.
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index ea5fe5b29..f9d7c024d 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include "core/hle/kernel/resource_limit.h" | 22 | #include "core/hle/kernel/resource_limit.h" |
| 23 | #include "core/hle/kernel/scheduler.h" | 23 | #include "core/hle/kernel/scheduler.h" |
| 24 | #include "core/hle/kernel/thread.h" | 24 | #include "core/hle/kernel/thread.h" |
| 25 | #include "core/hle/lock.h" | ||
| 25 | #include "core/memory.h" | 26 | #include "core/memory.h" |
| 26 | #include "core/settings.h" | 27 | #include "core/settings.h" |
| 27 | 28 | ||
| @@ -345,6 +346,7 @@ static auto FindTLSPageWithAvailableSlots(std::vector<TLSPage>& tls_pages) { | |||
| 345 | } | 346 | } |
| 346 | 347 | ||
| 347 | VAddr Process::CreateTLSRegion() { | 348 | VAddr Process::CreateTLSRegion() { |
| 349 | SchedulerLock lock(system.Kernel()); | ||
| 348 | if (auto tls_page_iter{FindTLSPageWithAvailableSlots(tls_pages)}; | 350 | if (auto tls_page_iter{FindTLSPageWithAvailableSlots(tls_pages)}; |
| 349 | tls_page_iter != tls_pages.cend()) { | 351 | tls_page_iter != tls_pages.cend()) { |
| 350 | return *tls_page_iter->ReserveSlot(); | 352 | return *tls_page_iter->ReserveSlot(); |
| @@ -375,6 +377,7 @@ VAddr Process::CreateTLSRegion() { | |||
| 375 | } | 377 | } |
| 376 | 378 | ||
| 377 | void Process::FreeTLSRegion(VAddr tls_address) { | 379 | void Process::FreeTLSRegion(VAddr tls_address) { |
| 380 | SchedulerLock lock(system.Kernel()); | ||
| 378 | const VAddr aligned_address = Common::AlignDown(tls_address, Core::Memory::PAGE_SIZE); | 381 | const VAddr aligned_address = Common::AlignDown(tls_address, Core::Memory::PAGE_SIZE); |
| 379 | auto iter = | 382 | auto iter = |
| 380 | std::find_if(tls_pages.begin(), tls_pages.end(), [aligned_address](const auto& page) { | 383 | std::find_if(tls_pages.begin(), tls_pages.end(), [aligned_address](const auto& page) { |
| @@ -389,6 +392,7 @@ void Process::FreeTLSRegion(VAddr tls_address) { | |||
| 389 | } | 392 | } |
| 390 | 393 | ||
| 391 | void Process::LoadModule(CodeSet code_set, VAddr base_addr) { | 394 | void Process::LoadModule(CodeSet code_set, VAddr base_addr) { |
| 395 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 392 | const auto ReprotectSegment = [&](const CodeSet::Segment& segment, | 396 | const auto ReprotectSegment = [&](const CodeSet::Segment& segment, |
| 393 | Memory::MemoryPermission permission) { | 397 | Memory::MemoryPermission permission) { |
| 394 | page_table->SetCodeMemoryPermission(segment.addr + base_addr, segment.size, permission); | 398 | page_table->SetCodeMemoryPermission(segment.addr + base_addr, segment.size, permission); |