mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 12:18:25 +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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user