mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
Fix /proc/PID/stack in the new per-process page directory world.
I added an RAII helper called OtherTaskPagingScope. While present, it switches the kernel over to using another task's page directory. This is perfect for e.g walking the stack in /proc/PID/stack.
This commit is contained in:
parent
c45f166c63
commit
5891691640
Notes:
sideshowbarker
2024-07-19 18:35:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5891691640a
4 changed files with 12 additions and 32 deletions
|
@ -346,20 +346,6 @@ bool MemoryManager::unmapSubregion(Task& task, Task::Subregion& subregion)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool MemoryManager::unmapRegionsForTask(Task& task)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
for (auto& region : task.m_regions) {
|
||||
if (!unmapRegion(task, *region))
|
||||
return false;
|
||||
}
|
||||
for (auto& subregion : task.m_subregions) {
|
||||
if (!unmapSubregion(task, *subregion))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MemoryManager::mapSubregion(Task& task, Task::Subregion& subregion)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
|
|
@ -54,13 +54,10 @@ public:
|
|||
|
||||
bool mapSubregion(Task&, Task::Subregion&);
|
||||
bool unmapSubregion(Task&, Task::Subregion&);
|
||||
bool mapSubregionsForTask(Task&);
|
||||
bool unmapSubregionsForTask(Task&);
|
||||
|
||||
bool mapRegion(Task&, Task::Region&);
|
||||
bool unmapRegion(Task&, Task::Region&);
|
||||
bool mapRegionsForTask(Task&);
|
||||
bool unmapRegionsForTask(Task&);
|
||||
|
||||
void registerZone(Zone&);
|
||||
void unregisterZone(Zone&);
|
||||
|
@ -182,3 +179,13 @@ private:
|
|||
|
||||
Vector<PhysicalAddress> m_freePages;
|
||||
};
|
||||
|
||||
struct KernelPagingScope {
|
||||
KernelPagingScope() { MM.enter_kernel_paging_scope(); }
|
||||
~KernelPagingScope() { MM.enter_task_paging_scope(*current); }
|
||||
};
|
||||
|
||||
struct OtherTaskPagingScope {
|
||||
OtherTaskPagingScope(Task& task) { MM.enter_task_paging_scope(task); }
|
||||
~OtherTaskPagingScope() { MM.enter_task_paging_scope(*current); }
|
||||
};
|
||||
|
|
|
@ -61,11 +61,7 @@ ByteBuffer procfs$pid_vm(const Task& task)
|
|||
ByteBuffer procfs$pid_stack(Task& task)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ASSERT(false);
|
||||
if (current != &task) {
|
||||
MM.unmapRegionsForTask(*current);
|
||||
MM.mapRegionsForTask(task);
|
||||
}
|
||||
OtherTaskPagingScope pagingScope(task);
|
||||
struct RecognizedSymbol {
|
||||
dword address;
|
||||
const KSym* ksym;
|
||||
|
@ -91,10 +87,6 @@ ByteBuffer procfs$pid_stack(Task& task)
|
|||
bufptr += ksprintf(bufptr, "%p %s +%u\n", symbol.address, symbol.ksym->name.characters(), offset);
|
||||
}
|
||||
buffer.trim(bufptr - (char*)buffer.pointer());
|
||||
if (current != &task) {
|
||||
MM.unmapRegionsForTask(task);
|
||||
MM.mapRegionsForTask(*current);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,11 +228,6 @@ int Task::sys$spawn(const char* path, const char** args)
|
|||
return error;
|
||||
}
|
||||
|
||||
struct KernelPagingScope {
|
||||
KernelPagingScope() { MM.enter_kernel_paging_scope(); }
|
||||
~KernelPagingScope() { MM.enter_task_paging_scope(*current); }
|
||||
};
|
||||
|
||||
Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t parentPID, int& error, const char** args, TTY* tty)
|
||||
{
|
||||
auto parts = path.split('/');
|
||||
|
@ -281,7 +276,7 @@ Task* Task::createUserTask(const String& path, uid_t uid, gid_t gid, pid_t paren
|
|||
taskEnvironment.append("HOME=/");
|
||||
|
||||
InterruptDisabler disabler; // FIXME: Get rid of this, jesus christ. This "critical" section is HUGE.
|
||||
KernelPagingScope kernelScope;
|
||||
KernelPagingScope pagingScope;
|
||||
Task* t = new Task(parts.takeLast(), uid, gid, parentPID, Ring3, move(cwd), handle->vnode(), tty);
|
||||
|
||||
t->m_arguments = move(taskArguments);
|
||||
|
|
Loading…
Add table
Reference in a new issue