mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-26 16:52:46 +01:00
Process: Protect TLS region and Modules.
This commit is contained in:
parent
2a8837ff51
commit
de5b521c09
1 changed files with 4 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
|||
#include "core/hle/kernel/resource_limit.h"
|
||||
#include "core/hle/kernel/scheduler.h"
|
||||
#include "core/hle/kernel/thread.h"
|
||||
#include "core/hle/lock.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
|
@ -345,6 +346,7 @@ static auto FindTLSPageWithAvailableSlots(std::vector<TLSPage>& tls_pages) {
|
|||
}
|
||||
|
||||
VAddr Process::CreateTLSRegion() {
|
||||
SchedulerLock lock(system.Kernel());
|
||||
if (auto tls_page_iter{FindTLSPageWithAvailableSlots(tls_pages)};
|
||||
tls_page_iter != tls_pages.cend()) {
|
||||
return *tls_page_iter->ReserveSlot();
|
||||
|
@ -375,6 +377,7 @@ VAddr Process::CreateTLSRegion() {
|
|||
}
|
||||
|
||||
void Process::FreeTLSRegion(VAddr tls_address) {
|
||||
SchedulerLock lock(system.Kernel());
|
||||
const VAddr aligned_address = Common::AlignDown(tls_address, Core::Memory::PAGE_SIZE);
|
||||
auto iter =
|
||||
std::find_if(tls_pages.begin(), tls_pages.end(), [aligned_address](const auto& page) {
|
||||
|
@ -389,6 +392,7 @@ void Process::FreeTLSRegion(VAddr tls_address) {
|
|||
}
|
||||
|
||||
void Process::LoadModule(CodeSet code_set, VAddr base_addr) {
|
||||
std::lock_guard lock{HLE::g_hle_lock};
|
||||
const auto ReprotectSegment = [&](const CodeSet::Segment& segment,
|
||||
Memory::MemoryPermission permission) {
|
||||
page_table->SetCodeMemoryPermission(segment.addr + base_addr, segment.size, permission);
|
||||
|
|
Loading…
Reference in a new issue