linux-user: Sink call to do_safe_futex
Leave only the argument adjustments within the shift, and sink the actual syscall to the end. Sink the timespec conversion as well, as there will be more users. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220829021006.67305-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
parent
0fbc0f8da1
commit
57b9ccd4c0
@ -7773,11 +7773,11 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr,
|
|||||||
int op, int val, target_ulong timeout,
|
int op, int val, target_ulong timeout,
|
||||||
target_ulong uaddr2, int val3)
|
target_ulong uaddr2, int val3)
|
||||||
{
|
{
|
||||||
struct timespec ts, *pts;
|
struct timespec ts, *pts = NULL;
|
||||||
|
void *haddr2 = NULL;
|
||||||
int base_op;
|
int base_op;
|
||||||
|
|
||||||
/* ??? We assume FUTEX_* constants are the same on both host
|
/* We assume FUTEX_* constants are the same on both host and target. */
|
||||||
and target. */
|
|
||||||
#ifdef FUTEX_CMD_MASK
|
#ifdef FUTEX_CMD_MASK
|
||||||
base_op = op & FUTEX_CMD_MASK;
|
base_op = op & FUTEX_CMD_MASK;
|
||||||
#else
|
#else
|
||||||
@ -7786,39 +7786,41 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr,
|
|||||||
switch (base_op) {
|
switch (base_op) {
|
||||||
case FUTEX_WAIT:
|
case FUTEX_WAIT:
|
||||||
case FUTEX_WAIT_BITSET:
|
case FUTEX_WAIT_BITSET:
|
||||||
if (timeout) {
|
val = tswap32(val);
|
||||||
pts = &ts;
|
break;
|
||||||
if (time64
|
|
||||||
? target_to_host_timespec64(pts, timeout)
|
|
||||||
: target_to_host_timespec(pts, timeout)) {
|
|
||||||
return -TARGET_EFAULT;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pts = NULL;
|
|
||||||
}
|
|
||||||
return do_safe_futex(g2h(cpu, uaddr),
|
|
||||||
op, tswap32(val), pts, NULL, val3);
|
|
||||||
case FUTEX_WAKE:
|
case FUTEX_WAKE:
|
||||||
return do_safe_futex(g2h(cpu, uaddr),
|
timeout = 0;
|
||||||
op, val, NULL, NULL, 0);
|
break;
|
||||||
case FUTEX_FD:
|
case FUTEX_FD:
|
||||||
return do_safe_futex(g2h(cpu, uaddr),
|
timeout = 0;
|
||||||
op, val, NULL, NULL, 0);
|
break;
|
||||||
case FUTEX_REQUEUE:
|
|
||||||
case FUTEX_CMP_REQUEUE:
|
case FUTEX_CMP_REQUEUE:
|
||||||
|
val3 = tswap32(val3);
|
||||||
|
/* fall through */
|
||||||
|
case FUTEX_REQUEUE:
|
||||||
case FUTEX_WAKE_OP:
|
case FUTEX_WAKE_OP:
|
||||||
/* For FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, and FUTEX_WAKE_OP, the
|
/*
|
||||||
TIMEOUT parameter is interpreted as a uint32_t by the kernel.
|
* For these, the 4th argument is not TIMEOUT, but VAL2.
|
||||||
But the prototype takes a `struct timespec *'; insert casts
|
* But the prototype of do_safe_futex takes a pointer, so
|
||||||
to satisfy the compiler. We do not need to tswap TIMEOUT
|
* insert casts to satisfy the compiler. We do not need
|
||||||
since it's not compared to guest memory. */
|
* to tswap VAL2 since it's not compared to guest memory.
|
||||||
pts = (struct timespec *)(uintptr_t) timeout;
|
*/
|
||||||
return do_safe_futex(g2h(cpu, uaddr), op, val, pts, g2h(cpu, uaddr2),
|
pts = (struct timespec *)(uintptr_t)timeout;
|
||||||
(base_op == FUTEX_CMP_REQUEUE
|
timeout = 0;
|
||||||
? tswap32(val3) : val3));
|
haddr2 = g2h(cpu, uaddr2);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -TARGET_ENOSYS;
|
return -TARGET_ENOSYS;
|
||||||
}
|
}
|
||||||
|
if (timeout) {
|
||||||
|
pts = &ts;
|
||||||
|
if (time64
|
||||||
|
? target_to_host_timespec64(pts, timeout)
|
||||||
|
: target_to_host_timespec(pts, timeout)) {
|
||||||
|
return -TARGET_EFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return do_safe_futex(g2h(cpu, uaddr), op, val, pts, haddr2, val3);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user