diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2024-02-28 03:44:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-27 20:44:34 +0100 |
| commit | d658c47cd02823bee50adebf8580537031ef7026 (patch) | |
| tree | 13dde73cbf719499a32c874112b4b66fae587059 /src/wrapped | |
| parent | 21b06ace43adb3bc8b88eea8d0e1db79110d4e9c (diff) | |
| download | box64-d658c47cd02823bee50adebf8580537031ef7026.tar.gz box64-d658c47cd02823bee50adebf8580537031ef7026.zip | |
[RV64_DYNAREC] Fixed RDTSC handling (#1291)
* [LIBWRAP] Fixed a typo in the clocksource wrapping * [RV64_DYNAREC] Added hardware timer support for RDTSC * [INTERP] Optmize RV64 ReadTSC using rdtime * [RV64_DYNAREC] Added 0F 01 F9 RDTSCP opcode * Fixed typo * Fixed another typo
Diffstat (limited to 'src/wrapped')
| -rw-r--r-- | src/wrapped/wrappedlibc.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 77d9ff45..c8f23d0c 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1626,7 +1626,7 @@ void CreateCPUPresentFile(int fd) void CreateClocksourceFile(int fd) { size_t dummy; - write(fd, "tsc", strlen("tsc")); + write(fd, "tsc\n", strlen("tsc\n")); } #ifdef ANDROID @@ -1690,7 +1690,7 @@ EXPORT int32_t my_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mo // special case to say tsc as current clocksource int tmp = shm_open(TMP_CLOCKSOURCE, O_RDWR | O_CREAT, S_IRWXU); if(tmp<0) return open(pathname, flags, mode); // error fallback - shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use + shm_unlink(TMP_CLOCKSOURCE); // remove the shm file, but it will still exist because it's currently in use CreateClocksourceFile(tmp); lseek(tmp, 0, SEEK_SET); return tmp; @@ -1782,6 +1782,15 @@ EXPORT int32_t my_open64(x64emu_t* emu, void* pathname, int32_t flags, uint32_t lseek(tmp, 0, SEEK_SET); return tmp; } + if(!strcmp((const char*)pathname, "/sys/bus/clocksource/devices/clocksource0/current_clocksource")) { + // special case to say tsc as current clocksource + int tmp = shm_open(TMP_CLOCKSOURCE, O_RDWR | O_CREAT, S_IRWXU); + if(tmp<0) return open64(pathname, flags, mode); // error fallback + shm_unlink(TMP_CLOCKSOURCE); // remove the shm file, but it will still exist because it's currently in use + CreateClocksourceFile(tmp); + lseek(tmp, 0, SEEK_SET); + return tmp; + } #endif return open64(pathname, flags, mode); } @@ -1817,10 +1826,10 @@ EXPORT FILE* my_fopen64(x64emu_t* emu, const char* path, const char* mode) return fdopen(tmp, mode); } if(strcmp(path, "/sys/bus/clocksource/devices/clocksource0/current_clocksource")==0) { - // special case for cpuinfo + // special case to say tsc as current clocksource int tmp = shm_open(TMP_CLOCKSOURCE, O_RDWR | O_CREAT, S_IRWXU); if(tmp<0) return fopen64(path, mode); // error fallback - shm_unlink(TMP_CPUINFO); // remove the shm file, but it will still exist because it's currently in use + shm_unlink(TMP_CLOCKSOURCE); // remove the shm file, but it will still exist because it's currently in use CreateClocksourceFile(tmp); lseek(tmp, 0, SEEK_SET); return fdopen(tmp, mode); |