mirror of
https://github.com/RGBCube/serenity
synced 2025-06-30 10:12:07 +00:00
Kernel: Add sys$get_stack_bounds() for finding the stack base & size
This will be useful when implementing conservative garbage collection.
This commit is contained in:
parent
086f68e878
commit
ad92a1e4bc
5 changed files with 33 additions and 1 deletions
|
@ -4838,4 +4838,25 @@ OwnPtr<Process::ELFBundle> Process::elf_bundle() const
|
|||
return bundle;
|
||||
}
|
||||
|
||||
int Process::sys$get_stack_bounds(FlatPtr* user_stack_base, size_t* user_stack_size)
|
||||
{
|
||||
if (!validate_write_typed(user_stack_base))
|
||||
return -EFAULT;
|
||||
if (!validate_write_typed(user_stack_size))
|
||||
return -EFAULT;
|
||||
|
||||
FlatPtr stack_pointer = Thread::current->get_register_dump_from_stack().userspace_esp;
|
||||
auto* stack_region = MM.region_from_vaddr(*this, VirtualAddress(stack_pointer));
|
||||
if (!stack_region) {
|
||||
ASSERT_NOT_REACHED();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
FlatPtr stack_base = stack_region->range().base().get();
|
||||
size_t stack_size = stack_region->size();
|
||||
copy_to_user(user_stack_base, &stack_base);
|
||||
copy_to_user(user_stack_size, &stack_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue