mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 19:00:17 +02:00
This is an interesting vdso implementation because it only exists in x86-64 with kernel v6.11. For Arm64 the implementation is likely to land in a couple kernel versions from now. Some differences with vdso_getrandom versus the regular getrandom syscall - Has two additional arguments, opaque_state and opaque_len - Expects the userspace to mmap/munmap this opaque state structure - Lets userspace query information about this structure upfront - If the opaque data structure isn't provided then it falls back to regular SYS_getrandom With the "glibc" implementation, we can tell the interface to allocate a single page that gets unused (otherwise glibc ends up not using the interface), and fallback to the regular SYS_getrandom. In the case of the vdso interface, currently the arguments just get passed through. Keeping this as a WIP until the ARM64 kernel patches land and I can actually test the things. Running the "glibc" path works today with the selftest, but the vdso path is currently completely untested.
33 lines
761 B
C++
33 lines
761 B
C++
#include <common/GeneratorInterface.h>
|
|
|
|
#include <sched.h>
|
|
#include <sys/time.h>
|
|
#include <sys/types.h>
|
|
#include <time.h>
|
|
|
|
#include "Types.h"
|
|
|
|
template<auto>
|
|
struct fex_gen_config {};
|
|
|
|
template<>
|
|
struct fex_gen_config<time> {};
|
|
template<>
|
|
struct fex_gen_config<gettimeofday> {};
|
|
template<>
|
|
struct fex_gen_config<clock_gettime> {};
|
|
template<>
|
|
struct fex_gen_config<clock_getres> {};
|
|
template<>
|
|
struct fex_gen_config<getcpu> {};
|
|
|
|
#if __SIZEOF_POINTER__ == 4
|
|
extern int clock_gettime64(clockid_t __clock_id, struct timespec64* __tp) __THROW;
|
|
template<>
|
|
struct fex_gen_config<clock_gettime64> {};
|
|
#else
|
|
extern ssize_t getrandom(void* buffer, size_t len, uint32_t flags, void* opaque_state, size_t opaque_len);
|
|
template<>
|
|
struct fex_gen_config<getrandom> {};
|
|
#endif
|