Possible Typo in virt/timeout.cpp
I found a possible typo in virt/timeout.cpp, line 131:
int res = (int)PIN_GetSyscallNumber(ctxt, std);
I suspect the correct PIN interface to call should be PIN_GetSyscallReturn, because later on in line 134 to 139 the value of res is used as if it were a return value of the system call:
bool timedOut;
if (syscall == SYS_futex) {
timedOut = (res == -ETIMEDOUT);
} else {
timedOut = (res == 0);
}
A similar typo can be found in line 200 - 203:
int res = (int) PIN_GetSyscallNumber(ctxt, std);
if (isFutexWaitOp(fi.op) && res == 0) {
zinfo->sched->notifyFutexWaitWoken(procIdx, tid);
} else if (isFutexWakeOp(fi.op) && res >= 0) {
Again the value of res is compared with zero as if it were the return value of SYS_futex system call.
I can submit a simple pull request to fix this, if this is indeed a typo.
This bug won't affect anything on x86 systems. In x86-64, syscall number and syscall return value use the same register. So when you get the syscall number after the syscall, you will automatically get the syscall return value. See http://man7.org/linux/man-pages/man2/syscall.2.html. However, I think use PIN_GetSyscallReturn will be more standard and readable.