qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

linux-user/syscall: Add support for clock_gettime64/clock_settime64

Add support for the clock_gettime64/clock_settime64 syscalls.

If your host is 64-bit or is 32-bit with the *_time64 syscall then the
timespec will correctly be a 64-bit time_t. Otherwise the host will
return a 32-bit time_t which will be rounded to 64-bits. This will be
incorrect after y2038.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <4a7fd05532400d10aa0f684c9043e2ac7b34d91c.1584051142.git.alistair.francis@wdc.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>

authored by

Alistair Francis and committed by
Laurent Vivier
c6c8d102 859e8a89

+39
+39
linux-user/syscall.c
··· 1229 1229 } 1230 1230 #endif 1231 1231 1232 + #if defined(TARGET_NR_clock_settime64) 1233 + static inline abi_long target_to_host_timespec64(struct timespec *host_ts, 1234 + abi_ulong target_addr) 1235 + { 1236 + struct target__kernel_timespec *target_ts; 1237 + 1238 + if (!lock_user_struct(VERIFY_READ, target_ts, target_addr, 1)) { 1239 + return -TARGET_EFAULT; 1240 + } 1241 + __get_user(host_ts->tv_sec, &target_ts->tv_sec); 1242 + __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); 1243 + unlock_user_struct(target_ts, target_addr, 0); 1244 + return 0; 1245 + } 1246 + #endif 1247 + 1232 1248 static inline abi_long host_to_target_timespec(abi_ulong target_addr, 1233 1249 struct timespec *host_ts) 1234 1250 { ··· 11458 11474 return ret; 11459 11475 } 11460 11476 #endif 11477 + #ifdef TARGET_NR_clock_settime64 11478 + case TARGET_NR_clock_settime64: 11479 + { 11480 + struct timespec ts; 11481 + 11482 + ret = target_to_host_timespec64(&ts, arg2); 11483 + if (!is_error(ret)) { 11484 + ret = get_errno(clock_settime(arg1, &ts)); 11485 + } 11486 + return ret; 11487 + } 11488 + #endif 11461 11489 #ifdef TARGET_NR_clock_gettime 11462 11490 case TARGET_NR_clock_gettime: 11463 11491 { ··· 11465 11493 ret = get_errno(clock_gettime(arg1, &ts)); 11466 11494 if (!is_error(ret)) { 11467 11495 ret = host_to_target_timespec(arg2, &ts); 11496 + } 11497 + return ret; 11498 + } 11499 + #endif 11500 + #ifdef TARGET_NR_clock_gettime64 11501 + case TARGET_NR_clock_gettime64: 11502 + { 11503 + struct timespec ts; 11504 + ret = get_errno(clock_gettime(arg1, &ts)); 11505 + if (!is_error(ret)) { 11506 + ret = host_to_target_timespec64(arg2, &ts); 11468 11507 } 11469 11508 return ret; 11470 11509 }