[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 38/44] linux-user: Use safe_syscall wrapper for semop
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 38/44] linux-user: Use safe_syscall wrapper for semop |
Date: |
Wed, 8 Jun 2016 16:30:19 +0300 |
From: Peter Maydell <address@hidden>
Use the safe_syscall wrapper for the semop syscall or IPC operation.
(We implement via the semtimedop syscall to make it easier to
implement the guest semtimedop syscall later.)
Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a193849..3ccb367 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -732,6 +732,8 @@ safe_syscall4(int, msgsnd, int, msgid, const void *, msgp,
size_t, sz,
int, flags)
safe_syscall5(int, msgrcv, int, msgid, void *, msgp, size_t, sz,
long, msgtype, int, flags)
+safe_syscall4(int, semtimedop, int, semid, struct sembuf *, tsops,
+ unsigned, nsops, const struct timespec *, timeout)
#else
/* This host kernel architecture uses a single ipc syscall; fake up
* wrappers for the sub-operations to hide this implementation detail.
@@ -740,6 +742,7 @@ safe_syscall5(int, msgrcv, int, msgid, void *, msgp,
size_t, sz,
* sys/ipc.h ones. So we just define them here, and rely on them being
* the same for all host architectures.
*/
+#define Q_SEMTIMEDOP 4
#define Q_MSGSND 11
#define Q_MSGRCV 12
#define Q_IPCCALL(VERSION, OP) ((VERSION) << 16 | (OP))
@@ -754,6 +757,12 @@ static int safe_msgrcv(int msgid, void *msgp, size_t sz,
long type, int flags)
{
return safe_ipc(Q_IPCCALL(1, Q_MSGRCV), msgid, sz, flags, msgp, type);
}
+static int safe_semtimedop(int semid, struct sembuf *tsops, unsigned nsops,
+ const struct timespec *timeout)
+{
+ return safe_ipc(Q_IPCCALL(0, Q_SEMTIMEDOP), semid, nsops, 0, tsops,
+ (long)timeout);
+}
#endif
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr,
@@ -3680,7 +3689,7 @@ static inline abi_long do_semop(int semid, abi_long ptr,
unsigned nsops)
if (target_to_host_sembuf(sops, ptr, nsops))
return -TARGET_EFAULT;
- return get_errno(semop(semid, sops, nsops));
+ return get_errno(safe_semtimedop(semid, sops, nsops, NULL));
}
struct target_msqid_ds
--
2.1.4
- [Qemu-devel] [PULL 26/44] linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests, (continued)
- [Qemu-devel] [PULL 26/44] linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 33/44] linux-user: Use safe_syscall wrapper for flock, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 30/44] linux-user: Use safe_syscall wrapper for send* and recv* syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 29/44] linux-user: Use safe_syscall wrapper for connect syscall, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 37/44] linux-user: Use safe_syscall wrapper for epoll_wait syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 27/44] linux-user: Fix error conversion in 64-bit fadvise syscall, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 36/44] linux-user: Use safe_syscall wrapper for poll and ppoll syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 32/44] linux-user: Use safe_syscall wrapper for mq_timedsend and mq_timedreceive, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 35/44] linux-user: Use safe_syscall wrapper for sleep syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 31/44] linux-user: Use safe_syscall wrapper for msgsnd and msgrcv, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 38/44] linux-user: Use safe_syscall wrapper for semop,
riku . voipio <=
- [Qemu-devel] [PULL 39/44] linux-user: Use safe_syscall wrapper for accept and accept4 syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 41/44] linux-user: Correct signedness of target_flock l_start and l_len fields, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 43/44] linux-user: Special-case ERESTARTSYS in target_strerror(), riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 34/44] linux-user: Use safe_syscall wrapper for rt_sigtimedwait syscall, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 40/44] linux-user: Use safe_syscall wrapper for ioctl, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 42/44] linux-user: Make target_strerror() return 'const char *', riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 44/44] linux-user: In fork_end(), remove correct CPUs from CPU list, riku . voipio, 2016/06/08
- Re: [Qemu-devel] [PULL 00/44] linux-user update, Peter Maydell, 2016/06/08
- Re: [Qemu-devel] [PULL 00/44] linux-user update, Laurent Vivier, 2016/06/09