mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:57:35 +00:00
UserspaceEmulator: Add the getrandom() syscall
This commit is contained in:
parent
1873b8f3e4
commit
33e3e8d63d
2 changed files with 14 additions and 3 deletions
|
@ -198,9 +198,6 @@ void Emulator::dump_backtrace()
|
||||||
|
|
||||||
u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
||||||
{
|
{
|
||||||
(void)arg2;
|
|
||||||
(void)arg3;
|
|
||||||
|
|
||||||
#ifdef DEBUG_SPAM
|
#ifdef DEBUG_SPAM
|
||||||
dbgprintf("Syscall: %s (%x)\n", Syscall::to_string((Syscall::Function)function), function);
|
dbgprintf("Syscall: %s (%x)\n", Syscall::to_string((Syscall::Function)function), function);
|
||||||
#endif
|
#endif
|
||||||
|
@ -296,6 +293,9 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
||||||
return virt$gettimeofday(arg1);
|
return virt$gettimeofday(arg1);
|
||||||
case SC_clock_gettime:
|
case SC_clock_gettime:
|
||||||
return virt$clock_gettime(arg1, arg2);
|
return virt$clock_gettime(arg1, arg2);
|
||||||
|
case SC_getrandom:
|
||||||
|
return virt$getrandom(arg1, arg2, arg3) ;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
warn() << "Unimplemented syscall: " << Syscall::to_string((Syscall::Function)function);
|
warn() << "Unimplemented syscall: " << Syscall::to_string((Syscall::Function)function);
|
||||||
dump_backtrace();
|
dump_backtrace();
|
||||||
|
@ -738,4 +738,14 @@ void Emulator::virt$exit(int status)
|
||||||
m_shutdown = true;
|
m_shutdown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t Emulator::virt$getrandom(FlatPtr buffer, size_t buffer_size, unsigned int flags)
|
||||||
|
{
|
||||||
|
auto host_buffer = ByteBuffer::create_uninitialized(buffer_size);
|
||||||
|
int rc = syscall(SC_getrandom, host_buffer.data(), host_buffer.size(), flags);
|
||||||
|
if (rc < 0)
|
||||||
|
return rc;
|
||||||
|
mmu().copy_to_vm(buffer, host_buffer.data(), host_buffer.size());
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ private:
|
||||||
int virt$recvfrom(FlatPtr);
|
int virt$recvfrom(FlatPtr);
|
||||||
int virt$connect(int sockfd, FlatPtr address, socklen_t address_size);
|
int virt$connect(int sockfd, FlatPtr address, socklen_t address_size);
|
||||||
void virt$exit(int);
|
void virt$exit(int);
|
||||||
|
ssize_t virt$getrandom(FlatPtr buffer, size_t buffer_size, unsigned int flags);
|
||||||
|
|
||||||
FlatPtr allocate_vm(size_t size, size_t alignment);
|
FlatPtr allocate_vm(size_t size, size_t alignment);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue