mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-23 12:29:19 +01:00
Remove guard-page from main thread stack
This was erroneously included while migrating from older code where stack creation was entirely handled with host constructs such as `mmap` directly to using `KPrivateMemory` to manage it, we would create a guard page with `mprotect` that the guest was unaware about and would cause a segfault when a guest accessed the extents of the stack as reported to the guest.
This commit is contained in:
parent
de81d28b1d
commit
ad0005f398
@ -70,8 +70,6 @@ namespace skyline::kernel::type {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
if (!stackTop && threads.empty()) { //!< Main thread stack is created by the kernel and owned by the process
|
if (!stackTop && threads.empty()) { //!< Main thread stack is created by the kernel and owned by the process
|
||||||
mainThreadStack = std::make_shared<KPrivateMemory>(state, reinterpret_cast<u8 *>(state.process->memory.stack.address), state.process->npdm.meta.mainThreadStackSize, memory::Permission{true, true, false}, memory::states::Stack);
|
mainThreadStack = std::make_shared<KPrivateMemory>(state, reinterpret_cast<u8 *>(state.process->memory.stack.address), state.process->npdm.meta.mainThreadStackSize, memory::Permission{true, true, false}, memory::states::Stack);
|
||||||
if (mprotect(mainThreadStack->ptr, PAGE_SIZE, PROT_NONE))
|
|
||||||
throw exception("Failed to create guard page for thread stack at 0x{:X}", mainThreadStack->ptr);
|
|
||||||
stackTop = mainThreadStack->ptr + mainThreadStack->size;
|
stackTop = mainThreadStack->ptr + mainThreadStack->size;
|
||||||
}
|
}
|
||||||
auto thread{NewHandle<KThread>(this, threads.size(), entry, argument, stackTop, priority ? *priority : state.process->npdm.meta.mainThreadPriority, idealCore ? *idealCore : state.process->npdm.meta.idealCore).item};
|
auto thread{NewHandle<KThread>(this, threads.size(), entry, argument, stackTop, priority ? *priority : state.process->npdm.meta.mainThreadPriority, idealCore ? *idealCore : state.process->npdm.meta.idealCore).item};
|
||||||
|
Loading…
Reference in New Issue
Block a user