UserspaceEmulator: Emulate the sys$get_stack_bounds() syscall

This commit is contained in:
Andreas Kling 2020-11-13 10:37:26 +01:00
parent 04d9af79ac
commit ae81ced21c
Notes: sideshowbarker 2024-07-19 01:24:45 +09:00
2 changed files with 13 additions and 0 deletions

View File

@ -252,6 +252,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$chdir(arg1, arg2);
case SC_dup2:
return virt$dup2(arg1, arg2);
case SC_get_stack_bounds:
return virt$get_stack_bounds(arg1, arg2);
case SC_access:
return virt$access(arg1, arg2, arg3);
case SC_waitid:
@ -549,6 +551,16 @@ int Emulator::virt$setsockopt(FlatPtr params_addr)
TODO();
}
int Emulator::virt$get_stack_bounds(FlatPtr base, FlatPtr size)
{
auto* region = mmu().find_region({ m_cpu.ss(), m_cpu.esp().value() });
FlatPtr b = region->base();
size_t s = region->size();
mmu().copy_to_vm(base, &b, sizeof(b));
mmu().copy_to_vm(size, &s, sizeof(s));
return 0;
}
int Emulator::virt$accept(int sockfd, FlatPtr address, FlatPtr address_length)
{
socklen_t host_address_length = 0;

View File

@ -134,6 +134,7 @@ private:
int virt$getsockopt(FlatPtr);
int virt$setsockopt(FlatPtr);
int virt$select(FlatPtr);
int virt$get_stack_bounds(FlatPtr, FlatPtr);
int virt$accept(int sockfd, FlatPtr address, FlatPtr address_length);
int virt$bind(int sockfd, FlatPtr address, socklen_t address_length);
int virt$recvmsg(int sockfd, FlatPtr msg_addr, int flags);